mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-05-20 00:32:15 +00:00
Lock individual items for better UX
This commit is contained in:
parent
776b8e410d
commit
479139a5b3
@ -14,8 +14,22 @@
|
||||
SelectedValuesChanged="@this.OptionChanged">
|
||||
@foreach (var data in this.Data)
|
||||
{
|
||||
<MudSelectItemExtended Value="@data.Value">
|
||||
@data.Name
|
||||
var isLockedValue = this.IsLockedValue(data.Value);
|
||||
<MudSelectItemExtended Value="@data.Value" Disabled="@isLockedValue">
|
||||
@if (isLockedValue)
|
||||
{
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center" Justify="Justify.FlexStart" Wrap="Wrap.NoWrap">
|
||||
@* MudTooltip.RootStyle is set as a workaround for issue -> https://github.com/MudBlazor/MudBlazor/issues/10882 *@
|
||||
<MudTooltip Text="@this.LockedTooltip()" Arrow="true" Placement="Placement.Right" RootStyle="display:inline-flex;">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Lock" Color="Color.Error" Size="Size.Small" Class="mr-1"/>
|
||||
</MudTooltip>
|
||||
@data.Name
|
||||
</MudStack>
|
||||
}
|
||||
else
|
||||
{
|
||||
@data.Name
|
||||
}
|
||||
</MudSelectItemExtended>
|
||||
}
|
||||
</MudSelectExtended>
|
||||
@ -27,6 +27,12 @@ public partial class ConfigurationMultiSelect<TData> : ConfigurationBaseCore
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public Action<HashSet<TData>> SelectionUpdate { get; set; } = _ => { };
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether a specific item is locked by a configuration plugin.
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public Func<TData, bool> IsItemLocked { get; set; } = _ => false;
|
||||
|
||||
#region Overrides of ConfigurationBase
|
||||
|
||||
@ -62,4 +68,12 @@ public partial class ConfigurationMultiSelect<TData> : ConfigurationBaseCore
|
||||
|
||||
return string.Format(T("You have selected {0} preview features."), selectedValues.Count);
|
||||
}
|
||||
|
||||
private bool IsLockedValue(TData value) => this.IsItemLocked(value);
|
||||
|
||||
private string LockedTooltip() =>
|
||||
this.T(
|
||||
"This feature is managed by your organization and has therefore been disabled.",
|
||||
typeof(ConfigurationBase).Namespace,
|
||||
nameof(ConfigurationBase));
|
||||
}
|
||||
@ -25,7 +25,7 @@
|
||||
var availablePreviewFeatures = ConfigurationSelectDataFactory.GetPreviewFeaturesData(this.SettingsManager).ToList();
|
||||
if (availablePreviewFeatures.Count > 0)
|
||||
{
|
||||
<ConfigurationMultiSelect OptionDescription="@T("Select preview features")" SelectedValues="@this.GetSelectedPreviewFeatures" Data="@availablePreviewFeatures" SelectionUpdate="@this.UpdateEnabledPreviewFeatures" OptionHelp="@T("Which preview features would you like to enable?")" IsLocked="() => ManagedConfiguration.TryGet(x => x.App, x => x.EnabledPreviewFeatures, out var meta) && meta.IsLocked"/>
|
||||
<ConfigurationMultiSelect OptionDescription="@T("Select preview features")" SelectedValues="@this.GetSelectedPreviewFeatures" Data="@availablePreviewFeatures" SelectionUpdate="@this.UpdateEnabledPreviewFeatures" OptionHelp="@T("Which preview features would you like to enable?")" IsItemLocked="@this.IsPluginContributedPreviewFeature" IsLocked="() => ManagedConfiguration.TryGet(x => x.App, x => x.EnabledPreviewFeatures, out var meta) && meta.IsLocked"/>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -40,6 +40,17 @@ public partial class SettingsPanelApp : SettingsPanelBase
|
||||
return [];
|
||||
}
|
||||
|
||||
private bool IsPluginContributedPreviewFeature(PreviewFeatures feature)
|
||||
{
|
||||
if (feature.IsReleased())
|
||||
return false;
|
||||
|
||||
if (!ManagedConfiguration.TryGet(x => x.App, x => x.EnabledPreviewFeatures, out var meta) || !meta.HasPluginContribution)
|
||||
return false;
|
||||
|
||||
return meta.PluginContribution.Contains(feature);
|
||||
}
|
||||
|
||||
private HashSet<PreviewFeatures> GetSelectedPreviewFeatures()
|
||||
{
|
||||
var enabled = this.SettingsManager.ConfigurationData.App.EnabledPreviewFeatures.Where(x => !x.IsReleased()).ToHashSet();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user