mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-08-24 20:52:11 +00:00
Replaced ManagedFeatureLock with LockableButton
This commit is contained in:
parent
294d242986
commit
e0057b67ae
@ -3280,9 +3280,6 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::HALLUZINATIONREMINDER::T3528806904"] = "L
|
|||||||
-- Issues
|
-- Issues
|
||||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ISSUES::T3229841001"] = "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.
|
-- Your Pandoc installation meets the requirements.
|
||||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANAGEPANDOCDEPENDENCY::T1167365374"] = "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.
|
-- An error occurred while sharing the plugin.
|
||||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3184210266"] = "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
|
-- Import assistant plugin
|
||||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3246593895"] = "Import assistant plugin"
|
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3246593895"] = "Import assistant plugin"
|
||||||
|
|
||||||
|
|||||||
@ -56,7 +56,13 @@ public abstract partial class ConfigurationBase : MSGComponentBase
|
|||||||
|
|
||||||
protected bool IsDisabled => this.Disabled() || this.IsLocked();
|
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}";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The bottom margin of the option. Options inside settings panels need the default
|
||||||
|
/// spacing; standalone usages like toolbar buttons can remove it.
|
||||||
|
/// </summary>
|
||||||
|
protected virtual string MarginClass => MARGIN_CLASS;
|
||||||
|
|
||||||
private protected virtual RenderFragment? Body => null;
|
private protected virtual RenderFragment? Body => null;
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,8 @@
|
|||||||
@inherits ConfigurationBaseCore
|
@inherits ConfigurationBaseCore
|
||||||
|
|
||||||
<MudButton Variant="Variant.Filled" Color="@Color.Primary" StartIcon="@this.Icon" Disabled="@this.IsDisabled" OnClick="@(async () => await this.ClickAsync())">
|
@* The tooltip is suppressed while the button is locked, so that the lock icon's tooltip is the only one shown: *@
|
||||||
@this.Text
|
<MudTooltip Text="@this.Tooltip" Disabled="@(this.IsLocked() || string.IsNullOrWhiteSpace(this.Tooltip))" RootStyle="display:inline-flex;">
|
||||||
</MudButton>
|
<MudButton Variant="@this.ButtonVariant" Color="@this.ButtonColor" StartIcon="@this.Icon" Disabled="@this.IsDisabled" OnClick="@(async () => await this.ClickAsync())">
|
||||||
|
@this.Text
|
||||||
|
</MudButton>
|
||||||
|
</MudTooltip>
|
||||||
@ -18,7 +18,33 @@ public partial class LockableButton : ConfigurationBaseCore
|
|||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public string Class { get; set; } = string.Empty;
|
public string Class { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
[Parameter]
|
||||||
|
public string Tooltip { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The visual variant of the button.
|
||||||
|
/// </summary>
|
||||||
|
[Parameter]
|
||||||
|
public Variant ButtonVariant { get; set; } = Variant.Filled;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The color of the button.
|
||||||
|
/// </summary>
|
||||||
|
[Parameter]
|
||||||
|
public Color ButtonColor { get; set; } = Color.Primary;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Should the default bottom margin be removed? Useful when the button is placed in a
|
||||||
|
/// toolbar instead of a settings panel.
|
||||||
|
/// </summary>
|
||||||
|
[Parameter]
|
||||||
|
public bool NoMargin { get; set; }
|
||||||
|
|
||||||
#region Overrides of ConfigurationBase
|
#region Overrides of ConfigurationBase
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -26,6 +52,8 @@ public partial class LockableButton : ConfigurationBaseCore
|
|||||||
|
|
||||||
protected override string GetClassForBase => this.Class;
|
protected override string GetClassForBase => this.Class;
|
||||||
|
|
||||||
|
protected override string MarginClass => this.NoMargin ? string.Empty : base.MarginClass;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private async Task ClickAsync()
|
private async Task ClickAsync()
|
||||||
|
|||||||
@ -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 *@
|
|
||||||
<MudTooltip Text="@this.LockTextOrDefault" Arrow="true" Placement="@this.Placement" RootStyle="display:inline-flex;">
|
|
||||||
<MudIcon Icon="@Icons.Material.Filled.Lock" Color="Color.Error" Size="Size.Small" Class="@this.Class"/>
|
|
||||||
</MudTooltip>
|
|
||||||
}
|
|
||||||
@ -1,65 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Components;
|
|
||||||
|
|
||||||
namespace AIStudio.Components;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 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.
|
|
||||||
/// </summary>
|
|
||||||
public partial class ManagedFeatureLock : MSGComponentBase
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Is the feature locked by a configuration plugin?
|
|
||||||
/// </summary>
|
|
||||||
[Parameter]
|
|
||||||
public Func<bool> IsLocked { get; set; } = () => false;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// An optional text that explains the lock. Without it, the generic explanation is used.
|
|
||||||
/// </summary>
|
|
||||||
[Parameter]
|
|
||||||
public string LockText { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Where should the tooltip be placed?
|
|
||||||
/// </summary>
|
|
||||||
[Parameter]
|
|
||||||
public Placement Placement { get; set; } = Placement.Left;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The CSS class to apply to the lock icon.
|
|
||||||
/// </summary>
|
|
||||||
[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<T>(ComponentBase? sendingComponent, Event triggeredEvent, T? data) where T : default
|
|
||||||
{
|
|
||||||
switch (triggeredEvent)
|
|
||||||
{
|
|
||||||
case Event.CONFIGURATION_CHANGED:
|
|
||||||
this.StateHasChanged();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
@ -10,12 +10,16 @@
|
|||||||
@T("Plugins")
|
@T("Plugins")
|
||||||
</MudText>
|
</MudText>
|
||||||
<MudSpacer />
|
<MudSpacer />
|
||||||
<ManagedFeatureLock IsLocked="@(() => !this.AllowPluginImport)" LockText="@T("Your organization has disabled importing plugins.")"/>
|
<LockableButton Text="@T("Import")"
|
||||||
<MudTooltip Text="@T("Import assistant plugin")">
|
Tooltip="@T("Import assistant plugin")"
|
||||||
<MudButton Variant="Variant.Outlined" StartIcon="@IMPORT_ICON" OnClick="@this.ImportAssistantPluginAsync" Disabled="@(this.isImportingAssistantPlugin || !this.AllowPluginImport)">
|
Icon="@IMPORT_ICON"
|
||||||
@T("Import")
|
ButtonVariant="Variant.Outlined"
|
||||||
</MudButton>
|
ButtonColor="Color.Default"
|
||||||
</MudTooltip>
|
NoMargin="@true"
|
||||||
|
Class="flex-none"
|
||||||
|
Disabled="@(() => this.isImportingAssistantPlugin)"
|
||||||
|
IsLocked="@(() => !this.AllowPluginImport)"
|
||||||
|
OnClickAsync="@this.ImportAssistantPluginAsync"/>
|
||||||
</MudStack>
|
</MudStack>
|
||||||
|
|
||||||
<InnerScrolling>
|
<InnerScrolling>
|
||||||
@ -74,12 +78,13 @@
|
|||||||
</MudStack>
|
</MudStack>
|
||||||
</MudTd>
|
</MudTd>
|
||||||
<MudTd>
|
<MudTd>
|
||||||
<MudStack Row="true" Spacing="0" AlignItems="AlignItems.Center">
|
<MudStack Row="true" Spacing="0" AlignItems="AlignItems.Center" Justify="Justify.FlexEnd">
|
||||||
@if (context.Type is PluginType.ASSISTANT)
|
@if (context.Type is PluginType.ASSISTANT)
|
||||||
{
|
{
|
||||||
var assistantPlugin = PluginFactory.RunningPlugins.OfType<PluginAssistants>().FirstOrDefault(x => x.Id == context.Id);
|
var assistantPlugin = PluginFactory.RunningPlugins.OfType<PluginAssistants>().FirstOrDefault(x => x.Id == context.Id);
|
||||||
<AssistantPluginSecurityCard Plugin="@assistantPlugin" Compact="@true"/>
|
<AssistantPluginSecurityCard Plugin="@assistantPlugin" Compact="@true"/>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (context is { IsInternal: false, Type: not PluginType.CONFIGURATION })
|
@if (context is { IsInternal: false, Type: not PluginType.CONFIGURATION })
|
||||||
{
|
{
|
||||||
var isEnabled = this.SettingsManager.IsPluginEnabled(context);
|
var isEnabled = this.SettingsManager.IsPluginEnabled(context);
|
||||||
@ -89,7 +94,7 @@
|
|||||||
</MudTooltip>
|
</MudTooltip>
|
||||||
}
|
}
|
||||||
|
|
||||||
<MudButtonGroup Class="ms-3">
|
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="0" Class="ms-3" Style="gap: 4px;">
|
||||||
@if (context is { IsInternal: false } && !string.IsNullOrWhiteSpace(context.SourceURL))
|
@if (context is { IsInternal: false } && !string.IsNullOrWhiteSpace(context.SourceURL))
|
||||||
{
|
{
|
||||||
var sourceUrl = context.SourceURL;
|
var sourceUrl = context.SourceURL;
|
||||||
@ -119,8 +124,7 @@
|
|||||||
|
|
||||||
@if (context is IAvailablePlugin shareablePlugin && CanSharePlugin(shareablePlugin))
|
@if (context is IAvailablePlugin shareablePlugin && CanSharePlugin(shareablePlugin))
|
||||||
{
|
{
|
||||||
<ManagedFeatureLock IsLocked="@(() => !this.AllowPluginSharing)" LockText="@this.SharePluginLockText"/>
|
<MudTooltip Text="@(this.AllowPluginSharing ? this.SharePluginTooltip : this.SharePluginLockText)">
|
||||||
<MudTooltip Text="@this.SharePluginTooltip">
|
|
||||||
<MudIconButton Icon="@SharePluginIcon" Size="Size.Medium" OnClick="@(() => this.SharePluginAsync(shareablePlugin))" Disabled="@(!this.AllowPluginSharing || !CanSharePlugin(shareablePlugin))"/>
|
<MudIconButton Icon="@SharePluginIcon" Size="Size.Medium" OnClick="@(() => this.SharePluginAsync(shareablePlugin))" Disabled="@(!this.AllowPluginSharing || !CanSharePlugin(shareablePlugin))"/>
|
||||||
</MudTooltip>
|
</MudTooltip>
|
||||||
}
|
}
|
||||||
@ -136,7 +140,7 @@
|
|||||||
{
|
{
|
||||||
<AssistantPluginDeleteAction Plugin="@availablePlugin" />
|
<AssistantPluginDeleteAction Plugin="@availablePlugin" />
|
||||||
}
|
}
|
||||||
</MudButtonGroup>
|
</MudStack>
|
||||||
</MudStack>
|
</MudStack>
|
||||||
</MudTd>
|
</MudTd>
|
||||||
</RowTemplate>
|
</RowTemplate>
|
||||||
|
|||||||
@ -3282,9 +3282,6 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::HALLUZINATIONREMINDER::T3528806904"] = "L
|
|||||||
-- Issues
|
-- Issues
|
||||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ISSUES::T3229841001"] = "Probleme"
|
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.
|
-- Your Pandoc installation meets the requirements.
|
||||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANAGEPANDOCDEPENDENCY::T1167365374"] = "Ihre Pandoc-Installation erfüllt die Anforderungen."
|
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.
|
-- An error occurred while sharing the plugin.
|
||||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3184210266"] = "Beim Teilen des Plugins ist ein Fehler aufgetreten."
|
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
|
-- Import assistant plugin
|
||||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3246593895"] = "Assistenten-Plugin importieren"
|
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"
|
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3355474457"] = "Plugin-Archiv teilen"
|
||||||
|
|
||||||
-- Your organization has disabled sharing plugins.
|
-- 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
|
-- Close
|
||||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3448155331"] = "Schließen"
|
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3448155331"] = "Schließen"
|
||||||
|
|||||||
@ -3282,9 +3282,6 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::HALLUZINATIONREMINDER::T3528806904"] = "L
|
|||||||
-- Issues
|
-- Issues
|
||||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ISSUES::T3229841001"] = "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.
|
-- Your Pandoc installation meets the requirements.
|
||||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANAGEPANDOCDEPENDENCY::T1167365374"] = "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.
|
-- An error occurred while sharing the plugin.
|
||||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3184210266"] = "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
|
-- Import assistant plugin
|
||||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3246593895"] = "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"
|
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3355474457"] = "Share plugin archive"
|
||||||
|
|
||||||
-- Your organization has disabled sharing plugins.
|
-- 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
|
-- Close
|
||||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3448155331"] = "Close"
|
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3448155331"] = "Close"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user