From e0057b67aeac291614a159e184285dc7cbbfba83 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Wed, 5 Aug 2026 09:40:47 +0200 Subject: [PATCH] Replaced `ManagedFeatureLock` with `LockableButton` --- .../Assistants/I18N/allTexts.lua | 6 -- .../Components/ConfigurationBase.razor.cs | 8 ++- .../Components/LockableButton.razor | 9 ++- .../Components/LockableButton.razor.cs | 30 ++++++++- .../Components/ManagedFeatureLock.razor | 9 --- .../Components/ManagedFeatureLock.razor.cs | 65 ------------------- app/MindWork AI Studio/Pages/Plugins.razor | 26 ++++---- .../plugin.lua | 8 +-- .../plugin.lua | 8 +-- 9 files changed, 59 insertions(+), 110 deletions(-) delete mode 100644 app/MindWork AI Studio/Components/ManagedFeatureLock.razor delete mode 100644 app/MindWork AI Studio/Components/ManagedFeatureLock.razor.cs diff --git a/app/MindWork AI Studio/Assistants/I18N/allTexts.lua b/app/MindWork AI Studio/Assistants/I18N/allTexts.lua index 85fb943d..1ead6621 100644 --- a/app/MindWork AI Studio/Assistants/I18N/allTexts.lua +++ b/app/MindWork AI Studio/Assistants/I18N/allTexts.lua @@ -3280,9 +3280,6 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::HALLUZINATIONREMINDER::T3528806904"] = "L -- Issues UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ISSUES::T3229841001"] = "Issues" --- This feature is managed by your organization and has therefore been disabled. -UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANAGEDFEATURELOCK::T1416426626"] = "This feature is managed by your organization and has therefore been disabled." - -- Your Pandoc installation meets the requirements. UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANAGEPANDOCDEPENDENCY::T1167365374"] = "Your Pandoc installation meets the requirements." @@ -7951,9 +7948,6 @@ UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3143506997"] = "The assistant plugin -- An error occurred while sharing the plugin. UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3184210266"] = "An error occurred while sharing the plugin." --- Your organization has disabled importing plugins. -UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3212529834"] = "Your organization has disabled importing plugins." - -- Import assistant plugin UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3246593895"] = "Import assistant plugin" diff --git a/app/MindWork AI Studio/Components/ConfigurationBase.razor.cs b/app/MindWork AI Studio/Components/ConfigurationBase.razor.cs index 33c896d1..20471d4d 100644 --- a/app/MindWork AI Studio/Components/ConfigurationBase.razor.cs +++ b/app/MindWork AI Studio/Components/ConfigurationBase.razor.cs @@ -56,7 +56,13 @@ public abstract partial class ConfigurationBase : MSGComponentBase protected bool IsDisabled => this.Disabled() || this.IsLocked(); - private string Classes => $"{this.GetClassForBase} {JUSTIFIED_HELP_CLASS} {MARGIN_CLASS}"; + private string Classes => $"{this.GetClassForBase} {JUSTIFIED_HELP_CLASS} {this.MarginClass}"; + + /// + /// The bottom margin of the option. Options inside settings panels need the default + /// spacing; standalone usages like toolbar buttons can remove it. + /// + protected virtual string MarginClass => MARGIN_CLASS; private protected virtual RenderFragment? Body => null; diff --git a/app/MindWork AI Studio/Components/LockableButton.razor b/app/MindWork AI Studio/Components/LockableButton.razor index 825c5a62..6434a449 100644 --- a/app/MindWork AI Studio/Components/LockableButton.razor +++ b/app/MindWork AI Studio/Components/LockableButton.razor @@ -1,5 +1,8 @@ @inherits ConfigurationBaseCore - - @this.Text - \ No newline at end of file +@* The tooltip is suppressed while the button is locked, so that the lock icon's tooltip is the only one shown: *@ + + + @this.Text + + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/LockableButton.razor.cs b/app/MindWork AI Studio/Components/LockableButton.razor.cs index cbfbd910..ddec0bc1 100644 --- a/app/MindWork AI Studio/Components/LockableButton.razor.cs +++ b/app/MindWork AI Studio/Components/LockableButton.razor.cs @@ -18,7 +18,33 @@ public partial class LockableButton : ConfigurationBaseCore [Parameter] public string Class { get; set; } = string.Empty; - + + /// + /// An optional tooltip for the button. It is not shown while the button is locked, + /// because the lock icon explains the situation in that case. + /// + [Parameter] + public string Tooltip { get; set; } = string.Empty; + + /// + /// The visual variant of the button. + /// + [Parameter] + public Variant ButtonVariant { get; set; } = Variant.Filled; + + /// + /// The color of the button. + /// + [Parameter] + public Color ButtonColor { get; set; } = Color.Primary; + + /// + /// Should the default bottom margin be removed? Useful when the button is placed in a + /// toolbar instead of a settings panel. + /// + [Parameter] + public bool NoMargin { get; set; } + #region Overrides of ConfigurationBase /// @@ -26,6 +52,8 @@ public partial class LockableButton : ConfigurationBaseCore protected override string GetClassForBase => this.Class; + protected override string MarginClass => this.NoMargin ? string.Empty : base.MarginClass; + #endregion private async Task ClickAsync() diff --git a/app/MindWork AI Studio/Components/ManagedFeatureLock.razor b/app/MindWork AI Studio/Components/ManagedFeatureLock.razor deleted file mode 100644 index 7301f705..00000000 --- a/app/MindWork AI Studio/Components/ManagedFeatureLock.razor +++ /dev/null @@ -1,9 +0,0 @@ -@inherits MSGComponentBase - -@if (this.IsLocked()) -{ - @* MudTooltip.RootStyle is set as a workaround for issue -> https://github.com/MudBlazor/MudBlazor/issues/10882 *@ - - - -} \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/ManagedFeatureLock.razor.cs b/app/MindWork AI Studio/Components/ManagedFeatureLock.razor.cs deleted file mode 100644 index a0bb46a1..00000000 --- a/app/MindWork AI Studio/Components/ManagedFeatureLock.razor.cs +++ /dev/null @@ -1,65 +0,0 @@ -using Microsoft.AspNetCore.Components; - -namespace AIStudio.Components; - -/// -/// Shows a lock icon for features that a configuration plugin has disabled. The related -/// control stays visible but must be disabled by the caller, so users still see that the -/// feature exists and learn that their organization has locked it. -/// -public partial class ManagedFeatureLock : MSGComponentBase -{ - /// - /// Is the feature locked by a configuration plugin? - /// - [Parameter] - public Func IsLocked { get; set; } = () => false; - - /// - /// An optional text that explains the lock. Without it, the generic explanation is used. - /// - [Parameter] - public string LockText { get; set; } = string.Empty; - - /// - /// Where should the tooltip be placed? - /// - [Parameter] - public Placement Placement { get; set; } = Placement.Left; - - /// - /// The CSS class to apply to the lock icon. - /// - [Parameter] - public string Class { get; set; } = "mr-1"; - - private string LockTextOrDefault => string.IsNullOrWhiteSpace(this.LockText) - ? this.T("This feature is managed by your organization and has therefore been disabled.") - : this.LockText; - - #region Overrides of ComponentBase - - protected override async Task OnInitializedAsync() - { - this.ApplyFilters([], [ Event.CONFIGURATION_CHANGED ]); - await base.OnInitializedAsync(); - } - - #endregion - - #region Overrides of MSGComponentBase - - protected override Task ProcessIncomingMessage(ComponentBase? sendingComponent, Event triggeredEvent, T? data) where T : default - { - switch (triggeredEvent) - { - case Event.CONFIGURATION_CHANGED: - this.StateHasChanged(); - break; - } - - return Task.CompletedTask; - } - - #endregion -} \ No newline at end of file diff --git a/app/MindWork AI Studio/Pages/Plugins.razor b/app/MindWork AI Studio/Pages/Plugins.razor index 20652c47..cb34fbe5 100644 --- a/app/MindWork AI Studio/Pages/Plugins.razor +++ b/app/MindWork AI Studio/Pages/Plugins.razor @@ -10,12 +10,16 @@ @T("Plugins") - - - - @T("Import") - - + @@ -74,12 +78,13 @@ - + @if (context.Type is PluginType.ASSISTANT) { var assistantPlugin = PluginFactory.RunningPlugins.OfType().FirstOrDefault(x => x.Id == context.Id); } + @if (context is { IsInternal: false, Type: not PluginType.CONFIGURATION }) { var isEnabled = this.SettingsManager.IsPluginEnabled(context); @@ -89,7 +94,7 @@ } - + @if (context is { IsInternal: false } && !string.IsNullOrWhiteSpace(context.SourceURL)) { var sourceUrl = context.SourceURL; @@ -119,8 +124,7 @@ @if (context is IAvailablePlugin shareablePlugin && CanSharePlugin(shareablePlugin)) { - - + } @@ -136,7 +140,7 @@ { } - + diff --git a/app/MindWork AI Studio/Plugins/languages/de-de-43065dbc-78d0-45b7-92be-f14c2926e2dc/plugin.lua b/app/MindWork AI Studio/Plugins/languages/de-de-43065dbc-78d0-45b7-92be-f14c2926e2dc/plugin.lua index e51615ae..4fbcf5ac 100644 --- a/app/MindWork AI Studio/Plugins/languages/de-de-43065dbc-78d0-45b7-92be-f14c2926e2dc/plugin.lua +++ b/app/MindWork AI Studio/Plugins/languages/de-de-43065dbc-78d0-45b7-92be-f14c2926e2dc/plugin.lua @@ -3282,9 +3282,6 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::HALLUZINATIONREMINDER::T3528806904"] = "L -- Issues UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ISSUES::T3229841001"] = "Probleme" --- This feature is managed by your organization and has therefore been disabled. -UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANAGEDFEATURELOCK::T1416426626"] = "Diese Funktion wird von Ihrer Organisation verwaltet und wurde daher deaktiviert." - -- Your Pandoc installation meets the requirements. UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANAGEPANDOCDEPENDENCY::T1167365374"] = "Ihre Pandoc-Installation erfüllt die Anforderungen." @@ -7953,9 +7950,6 @@ UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3143506997"] = "Das Assistent-Plugin -- An error occurred while sharing the plugin. UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3184210266"] = "Beim Teilen des Plugins ist ein Fehler aufgetreten." --- Your organization has disabled importing plugins. -UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3212529834"] = "Ihre Organisation hat das Importieren von Plugins deaktiviert." - -- Import assistant plugin UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3246593895"] = "Assistenten-Plugin importieren" @@ -7966,7 +7960,7 @@ UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3342440765"] = "Ihre Organisation ha UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3355474457"] = "Plugin-Archiv teilen" -- Your organization has disabled sharing plugins. -UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3379469503"] = "Ihre Organisation hat das Teilen von Plugins deaktiviert." +UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3379469503"] = "Ihre Organisation hat das Teilen von Plugins deaktiviert" -- Close UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3448155331"] = "Schließen" diff --git a/app/MindWork AI Studio/Plugins/languages/en-us-97dfb1ba-50c4-4440-8dfa-6575daf543c8/plugin.lua b/app/MindWork AI Studio/Plugins/languages/en-us-97dfb1ba-50c4-4440-8dfa-6575daf543c8/plugin.lua index 7ccd162f..f3492ec2 100644 --- a/app/MindWork AI Studio/Plugins/languages/en-us-97dfb1ba-50c4-4440-8dfa-6575daf543c8/plugin.lua +++ b/app/MindWork AI Studio/Plugins/languages/en-us-97dfb1ba-50c4-4440-8dfa-6575daf543c8/plugin.lua @@ -3282,9 +3282,6 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::HALLUZINATIONREMINDER::T3528806904"] = "L -- Issues UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ISSUES::T3229841001"] = "Issues" --- This feature is managed by your organization and has therefore been disabled. -UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANAGEDFEATURELOCK::T1416426626"] = "This feature is managed by your organization and has therefore been disabled." - -- Your Pandoc installation meets the requirements. UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANAGEPANDOCDEPENDENCY::T1167365374"] = "Your Pandoc installation meets the requirements." @@ -7953,9 +7950,6 @@ UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3143506997"] = "The assistant plugin -- An error occurred while sharing the plugin. UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3184210266"] = "An error occurred while sharing the plugin." --- Your organization has disabled importing plugins. -UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3212529834"] = "Your organization has disabled importing plugins." - -- Import assistant plugin UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3246593895"] = "Import assistant plugin" @@ -7966,7 +7960,7 @@ UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3342440765"] = "Your organization ha UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3355474457"] = "Share plugin archive" -- Your organization has disabled sharing plugins. -UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3379469503"] = "Your organization has disabled sharing plugins." +UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3379469503"] = "Your organization has disabled sharing plugins" -- Close UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3448155331"] = "Close"