diff --git a/app/MindWork AI Studio/Components/AssistantBlock.razor b/app/MindWork AI Studio/Components/AssistantBlock.razor index 754a9e24..372fae7e 100644 --- a/app/MindWork AI Studio/Components/AssistantBlock.razor +++ b/app/MindWork AI Studio/Components/AssistantBlock.razor @@ -1,30 +1,33 @@ @inherits MSGComponentBase @typeparam TSettings - - - - - - - @this.Name +@if (this.IsVisible) +{ + + + + + + + @this.Name + + + + + + + + @this.Description - - - - - - @this.Description - - - - - - - @this.ButtonText - - - - - \ No newline at end of file + + + + + @this.ButtonText + + + + + +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/AssistantBlock.razor.cs b/app/MindWork AI Studio/Components/AssistantBlock.razor.cs index ef0e7a4d..b06d3a94 100644 --- a/app/MindWork AI Studio/Components/AssistantBlock.razor.cs +++ b/app/MindWork AI Studio/Components/AssistantBlock.razor.cs @@ -1,3 +1,6 @@ +using AIStudio.Settings; +using AIStudio.Settings.DataModel; + using Microsoft.AspNetCore.Components; using DialogOptions = AIStudio.Dialogs.DialogOptions; @@ -20,6 +23,12 @@ public partial class AssistantBlock : MSGComponentBase where TSetting [Parameter] public string Link { get; set; } = string.Empty; + + [Parameter] + public Tools.Components Component { get; set; } = Tools.Components.NONE; + + [Parameter] + public PreviewFeatures? RequiredPreviewFeature { get; set; } [Inject] private MudTheme ColorTheme { get; init; } = null!; @@ -27,6 +36,9 @@ public partial class AssistantBlock : MSGComponentBase where TSetting [Inject] private IDialogService DialogService { get; init; } = null!; + [Inject] + private ILogger> Logger { get; init; } = null!; + private async Task OpenSettingsDialog() { var dialogParameters = new DialogParameters(); @@ -41,4 +53,71 @@ public partial class AssistantBlock : MSGComponentBase where TSetting }; private string BlockStyle => $"border-width: 2px; border-color: {this.BorderColor}; border-radius: 12px; border-style: solid; max-width: 20em;"; + + private bool IsVisible + { + get + { + // Check if a preview feature is required and enabled: + if (this.RequiredPreviewFeature is { } previewFeature && !previewFeature.IsEnabled(this.SettingsManager)) + { + this.Logger.LogInformation("Assistant '{AssistantName}' is not visible because the required preview feature '{PreviewFeature}' is not enabled.", this.Name, previewFeature); + return false; + } + + // Check if the assistant is visible based on the configuration: + return this.IsAssistantVisible(); + } + } + + /// + /// Checks if an assistant should be visible based on configuration. + /// + /// True if the assistant should be visible, false otherwise. + private bool IsAssistantVisible() + { + // If no component is specified, it's always visible: + if (this.Component is Tools.Components.NONE) + { + this.Logger.LogWarning("Assistant '{AssistantName}' is visible because no component is specified.", this.Name); + return true; + } + + // Map Components enum to ConfigurableAssistant enum: + var configurableAssistant = this.Component switch + { + Tools.Components.GRAMMAR_SPELLING_ASSISTANT => ConfigurableAssistant.GRAMMAR_SPELLING_ASSISTANT, + Tools.Components.ICON_FINDER_ASSISTANT => ConfigurableAssistant.ICON_FINDER_ASSISTANT, + Tools.Components.REWRITE_ASSISTANT => ConfigurableAssistant.REWRITE_ASSISTANT, + Tools.Components.TRANSLATION_ASSISTANT => ConfigurableAssistant.TRANSLATION_ASSISTANT, + Tools.Components.AGENDA_ASSISTANT => ConfigurableAssistant.AGENDA_ASSISTANT, + Tools.Components.CODING_ASSISTANT => ConfigurableAssistant.CODING_ASSISTANT, + Tools.Components.TEXT_SUMMARIZER_ASSISTANT => ConfigurableAssistant.TEXT_SUMMARIZER_ASSISTANT, + Tools.Components.EMAIL_ASSISTANT => ConfigurableAssistant.EMAIL_ASSISTANT, + Tools.Components.LEGAL_CHECK_ASSISTANT => ConfigurableAssistant.LEGAL_CHECK_ASSISTANT, + Tools.Components.SYNONYMS_ASSISTANT => ConfigurableAssistant.SYNONYMS_ASSISTANT, + Tools.Components.MY_TASKS_ASSISTANT => ConfigurableAssistant.MY_TASKS_ASSISTANT, + Tools.Components.JOB_POSTING_ASSISTANT => ConfigurableAssistant.JOB_POSTING_ASSISTANT, + Tools.Components.BIAS_DAY_ASSISTANT => ConfigurableAssistant.BIAS_DAY_ASSISTANT, + Tools.Components.ERI_ASSISTANT => ConfigurableAssistant.ERI_ASSISTANT, + Tools.Components.DOCUMENT_ANALYSIS_ASSISTANT => ConfigurableAssistant.DOCUMENT_ANALYSIS_ASSISTANT, + Tools.Components.I18N_ASSISTANT => ConfigurableAssistant.I18N_ASSISTANT, + + _ => ConfigurableAssistant.UNKNOWN, + }; + + // If the component doesn't map to a configurable assistant, it's always visible: + if (configurableAssistant is ConfigurableAssistant.UNKNOWN) + { + this.Logger.LogWarning("Assistant '{AssistantName}' is visible because its component '{Component}' does not map to a configurable assistant.", this.Name, this.Component); + return true; + } + + // Check if the assistant is hidden by any configuration plugin: + var isHidden = this.SettingsManager.ConfigurationData.App.HiddenAssistants.Contains(configurableAssistant); + if (isHidden) + this.Logger.LogInformation("Assistant '{AssistantName}' is hidden based on configuration.", this.Name); + + return !isHidden; + } } \ No newline at end of file diff --git a/app/MindWork AI Studio/Pages/Assistants.razor b/app/MindWork AI Studio/Pages/Assistants.razor index ae01923d..b9d34408 100644 --- a/app/MindWork AI Studio/Pages/Assistants.razor +++ b/app/MindWork AI Studio/Pages/Assistants.razor @@ -14,105 +14,46 @@ @T("General") - @if (this.IsAssistantVisible(Components.TEXT_SUMMARIZER_ASSISTANT)) - { - - } - - @if (this.IsAssistantVisible(Components.TRANSLATION_ASSISTANT)) - { - - } - - @if (this.IsAssistantVisible(Components.GRAMMAR_SPELLING_ASSISTANT)) - { - - } - - @if (this.IsAssistantVisible(Components.REWRITE_ASSISTANT)) - { - - } - - @if (this.IsAssistantVisible(Components.SYNONYMS_ASSISTANT)) - { - - } + + + + + @T("Business") - @if (this.IsAssistantVisible(Components.EMAIL_ASSISTANT)) - { - - } - - @if (PreviewFeatures.PRE_DOCUMENT_ANALYSIS_2025.IsEnabled(this.SettingsManager) && this.IsAssistantVisible(Components.DOCUMENT_ANALYSIS_ASSISTANT)) - { - - } - - @if (this.IsAssistantVisible(Components.MY_TASKS_ASSISTANT)) - { - - } - - @if (this.IsAssistantVisible(Components.AGENDA_ASSISTANT)) - { - - } - - @if (this.IsAssistantVisible(Components.JOB_POSTING_ASSISTANT)) - { - - } - - @if (this.IsAssistantVisible(Components.LEGAL_CHECK_ASSISTANT)) - { - - } - - @if (this.IsAssistantVisible(Components.ICON_FINDER_ASSISTANT)) - { - - } + + + + + + + @T("Learning") - @if (this.IsAssistantVisible(Components.BIAS_DAY_ASSISTANT)) - { - - } + @T("Software Engineering") - @if (this.IsAssistantVisible(Components.CODING_ASSISTANT)) - { - - } - - @if (PreviewFeatures.PRE_RAG_2024.IsEnabled(this.SettingsManager) && this.IsAssistantVisible(Components.ERI_ASSISTANT)) - { - - } + + @T("AI Studio Development") - @if (this.IsAssistantVisible(Components.I18N_ASSISTANT)) - { - - } + diff --git a/app/MindWork AI Studio/Pages/Assistants.razor.cs b/app/MindWork AI Studio/Pages/Assistants.razor.cs index 5c5d43c0..e2c2de49 100644 --- a/app/MindWork AI Studio/Pages/Assistants.razor.cs +++ b/app/MindWork AI Studio/Pages/Assistants.razor.cs @@ -1,45 +1,5 @@ using AIStudio.Components; -using AIStudio.Settings; namespace AIStudio.Pages; -public partial class Assistants : MSGComponentBase -{ - /// - /// Checks if an assistant should be visible based on configuration. - /// - /// The assistant component to check. - /// True if the assistant should be visible, false otherwise. - private bool IsAssistantVisible(Tools.Components component) - { - // Map Components enum to ConfigurableAssistant enum: - var configurableAssistant = component switch - { - Tools.Components.GRAMMAR_SPELLING_ASSISTANT => ConfigurableAssistant.GRAMMAR_SPELLING_ASSISTANT, - Tools.Components.ICON_FINDER_ASSISTANT => ConfigurableAssistant.ICON_FINDER_ASSISTANT, - Tools.Components.REWRITE_ASSISTANT => ConfigurableAssistant.REWRITE_ASSISTANT, - Tools.Components.TRANSLATION_ASSISTANT => ConfigurableAssistant.TRANSLATION_ASSISTANT, - Tools.Components.AGENDA_ASSISTANT => ConfigurableAssistant.AGENDA_ASSISTANT, - Tools.Components.CODING_ASSISTANT => ConfigurableAssistant.CODING_ASSISTANT, - Tools.Components.TEXT_SUMMARIZER_ASSISTANT => ConfigurableAssistant.TEXT_SUMMARIZER_ASSISTANT, - Tools.Components.EMAIL_ASSISTANT => ConfigurableAssistant.EMAIL_ASSISTANT, - Tools.Components.LEGAL_CHECK_ASSISTANT => ConfigurableAssistant.LEGAL_CHECK_ASSISTANT, - Tools.Components.SYNONYMS_ASSISTANT => ConfigurableAssistant.SYNONYMS_ASSISTANT, - Tools.Components.MY_TASKS_ASSISTANT => ConfigurableAssistant.MY_TASKS_ASSISTANT, - Tools.Components.JOB_POSTING_ASSISTANT => ConfigurableAssistant.JOB_POSTING_ASSISTANT, - Tools.Components.BIAS_DAY_ASSISTANT => ConfigurableAssistant.BIAS_DAY_ASSISTANT, - Tools.Components.ERI_ASSISTANT => ConfigurableAssistant.ERI_ASSISTANT, - Tools.Components.DOCUMENT_ANALYSIS_ASSISTANT => ConfigurableAssistant.DOCUMENT_ANALYSIS_ASSISTANT, - Tools.Components.I18N_ASSISTANT => ConfigurableAssistant.I18N_ASSISTANT, - - _ => ConfigurableAssistant.UNKNOWN, - }; - - // If the component doesn't map to a configurable assistant, it's always visible: - if (configurableAssistant is ConfigurableAssistant.UNKNOWN) - return true; - - // Check if the assistant is hidden by any configuration plugin: - return !this.SettingsManager.ConfigurationData.App.HiddenAssistants.Contains(configurableAssistant); - } -} \ No newline at end of file +public partial class Assistants : MSGComponentBase; \ No newline at end of file