AI-Studio/app/MindWork AI Studio/Pages/Assistants.razor.cs
Claude 509d57f69a
Add config plugin support to hide individual assistants
This change enables enterprise IT departments to hide specific assistants
via configuration plugins, providing better control over which features
are available to end users.

Changes:
- Created ConfigurableAssistant enum listing all hideable assistants
- Added HiddenAssistants property to DataApp settings (HashSet<ConfigurableAssistant>)
- Added IsAssistantVisible() method in Assistants.razor.cs to check visibility
- Updated Assistants.razor to conditionally render assistants based on configuration
- Extended plugin.lua template with HiddenAssistants configuration example

Example usage in configuration plugin:
CONFIG["SETTINGS"]["DataApp.HiddenAssistants"] = { "GRAMMAR_SPELLING_ASSISTANT", "SYNONYMS_ASSISTANT" }

The setting integrates with the existing ManagedConfiguration system and
is locked when managed by a config plugin, preventing user override.
2026-01-11 22:18:26 +00:00

45 lines
2.4 KiB
C#

using AIStudio.Components;
using AIStudio.Settings;
using AIStudio.Tools;
namespace AIStudio.Pages;
public partial class Assistants : MSGComponentBase
{
/// <summary>
/// Checks if an assistant should be visible based on configuration.
/// </summary>
/// <param name="component">The assistant component to check.</param>
/// <returns>True if the assistant should be visible, false otherwise.</returns>
private bool IsAssistantVisible(Components component)
{
// Map Components enum to ConfigurableAssistant enum
var configurableAssistant = component switch
{
Components.GRAMMAR_SPELLING_ASSISTANT => ConfigurableAssistant.GRAMMAR_SPELLING_ASSISTANT,
Components.ICON_FINDER_ASSISTANT => ConfigurableAssistant.ICON_FINDER_ASSISTANT,
Components.REWRITE_ASSISTANT => ConfigurableAssistant.REWRITE_ASSISTANT,
Components.TRANSLATION_ASSISTANT => ConfigurableAssistant.TRANSLATION_ASSISTANT,
Components.AGENDA_ASSISTANT => ConfigurableAssistant.AGENDA_ASSISTANT,
Components.CODING_ASSISTANT => ConfigurableAssistant.CODING_ASSISTANT,
Components.TEXT_SUMMARIZER_ASSISTANT => ConfigurableAssistant.TEXT_SUMMARIZER_ASSISTANT,
Components.EMAIL_ASSISTANT => ConfigurableAssistant.EMAIL_ASSISTANT,
Components.LEGAL_CHECK_ASSISTANT => ConfigurableAssistant.LEGAL_CHECK_ASSISTANT,
Components.SYNONYMS_ASSISTANT => ConfigurableAssistant.SYNONYMS_ASSISTANT,
Components.MY_TASKS_ASSISTANT => ConfigurableAssistant.MY_TASKS_ASSISTANT,
Components.JOB_POSTING_ASSISTANT => ConfigurableAssistant.JOB_POSTING_ASSISTANT,
Components.BIAS_DAY_ASSISTANT => ConfigurableAssistant.BIAS_DAY_ASSISTANT,
Components.ERI_ASSISTANT => ConfigurableAssistant.ERI_ASSISTANT,
Components.DOCUMENT_ANALYSIS_ASSISTANT => ConfigurableAssistant.DOCUMENT_ANALYSIS_ASSISTANT,
Components.I18N_ASSISTANT => ConfigurableAssistant.I18N_ASSISTANT,
_ => (ConfigurableAssistant?)null,
};
// If the component doesn't map to a configurable assistant, it's always visible
if (configurableAssistant is null)
return true;
// Check if the assistant is hidden in configuration
return !this.SettingsManager.ConfigurationData.App.HiddenAssistants.Contains(configurableAssistant.Value);
}
}