mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-05-21 17:12: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">
|
SelectedValuesChanged="@this.OptionChanged">
|
||||||
@foreach (var data in this.Data)
|
@foreach (var data in this.Data)
|
||||||
{
|
{
|
||||||
<MudSelectItemExtended Value="@data.Value">
|
var isLockedValue = this.IsLockedValue(data.Value);
|
||||||
@data.Name
|
<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>
|
</MudSelectItemExtended>
|
||||||
}
|
}
|
||||||
</MudSelectExtended>
|
</MudSelectExtended>
|
||||||
@ -28,6 +28,12 @@ public partial class ConfigurationMultiSelect<TData> : ConfigurationBaseCore
|
|||||||
[Parameter]
|
[Parameter]
|
||||||
public Action<HashSet<TData>> SelectionUpdate { get; set; } = _ => { };
|
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
|
#region Overrides of ConfigurationBase
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -62,4 +68,12 @@ public partial class ConfigurationMultiSelect<TData> : ConfigurationBaseCore
|
|||||||
|
|
||||||
return string.Format(T("You have selected {0} preview features."), selectedValues.Count);
|
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();
|
var availablePreviewFeatures = ConfigurationSelectDataFactory.GetPreviewFeaturesData(this.SettingsManager).ToList();
|
||||||
if (availablePreviewFeatures.Count > 0)
|
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 [];
|
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()
|
private HashSet<PreviewFeatures> GetSelectedPreviewFeatures()
|
||||||
{
|
{
|
||||||
var enabled = this.SettingsManager.ConfigurationData.App.EnabledPreviewFeatures.Where(x => !x.IsReleased()).ToHashSet();
|
var enabled = this.SettingsManager.ConfigurationData.App.EnabledPreviewFeatures.Where(x => !x.IsReleased()).ToHashSet();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user