mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-21 00:53:48 +00:00
Improved the assistants page with categories for assistant plugins (#1211)
This commit is contained in:
1 parent
ef059ffd15
commit
1db0f85898
74 files changed
+3392
-380
No files matched your search
@@ -2,6 +2,7 @@ using AIStudio.Dialogs.Settings;
|
||||
using AIStudio.Settings.DataModel;
|
||||
using AIStudio.Tools.AssistantSessions;
|
||||
using AIStudio.Tools.Media;
|
||||
using AIStudio.Tools.PluginSystem;
|
||||
using AIStudio.Tools.Services;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
@@ -62,7 +63,10 @@ public partial class AssistantBlock<TSettings> : MSGComponentBase, IAssistantCat
|
||||
/// Gets or sets the assistant category this block belongs to, if any.
|
||||
/// </summary>
|
||||
[CascadingParameter]
|
||||
public AssistantCategoryBlock? Category { get; set; }
|
||||
public AssistantCategoryBlock? CategoryBlock { get; set; }
|
||||
|
||||
[Inject]
|
||||
private ILogger<AssistantBlock<TSettings>> Logger { get; init; } = null!;
|
||||
|
||||
[Inject]
|
||||
private MudTheme ColorTheme { get; init; } = null!;
|
||||
@@ -160,10 +164,30 @@ public partial class AssistantBlock<TSettings> : MSGComponentBase, IAssistantCat
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
this.MediaTranscriptionService.StateChanged += this.OnMediaImportStateChanged;
|
||||
this.Category?.RegisterAssistant(this);
|
||||
this.CategoryBlock?.RegisterAssistant(this);
|
||||
this.WarnAboutAnotherCategory();
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reports a built-in assistant which the page shows in another section than its category.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The category of a built-in assistant is stated in code, see Components.Category, and everything
|
||||
/// which offers assistants outside the assistants page relies on it. The page, though, places the
|
||||
/// assistant by its markup. Should both ever differ, a user would find the assistant in one category
|
||||
/// and lose it with another one, so we make sure that a developer notices it.
|
||||
/// </remarks>
|
||||
private void WarnAboutAnotherCategory()
|
||||
{
|
||||
var category = this.Component.Category;
|
||||
if (category is PluginCategory.NONE || this.CategoryBlock is null)
|
||||
return;
|
||||
|
||||
if (new AssistantCategoryKey(category) != this.CategoryBlock.Category)
|
||||
this.Logger.LogError("The assistants page shows the assistant '{Component}' under the category '{PageCategory}', but its category is '{Category}'. Please move it into the section of its category.", this.Component, this.CategoryBlock.Category.Category, category);
|
||||
}
|
||||
|
||||
private void OnMediaImportStateChanged(MediaImportOwner owner)
|
||||
{
|
||||
if (this.OwnedByThisBlock(owner))
|
||||
@@ -173,7 +197,7 @@ public partial class AssistantBlock<TSettings> : MSGComponentBase, IAssistantCat
|
||||
protected override void DisposeResources()
|
||||
{
|
||||
this.MediaTranscriptionService.StateChanged -= this.OnMediaImportStateChanged;
|
||||
this.Category?.UnregisterAssistant(this);
|
||||
this.CategoryBlock?.UnregisterAssistant(this);
|
||||
base.DisposeResources();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
@if (this.HasVisibleAssistant)
|
||||
@if (!this.IsHidden)
|
||||
{
|
||||
<MudText Typo="Typo.h4" Class="@this.HeaderClass">
|
||||
@this.Title
|
||||
</MudText>
|
||||
}
|
||||
<CascadingValue Value="this" IsFixed="@true">
|
||||
<MudStack Row="@true" Wrap="@Wrap.Wrap" Class="@this.StackClass">
|
||||
@this.ChildContent
|
||||
</MudStack>
|
||||
</CascadingValue>
|
||||
if (this.HasVisibleAssistant)
|
||||
{
|
||||
<AssistantCategoryHeader Category="@this.Category" IsCollapsed="@this.IsCollapsed" OnToggleCollapsed="@this.ToggleCollapsedAsync" OnHide="@this.HideAsync" Class="@this.HeaderClass"/>
|
||||
}
|
||||
|
||||
<CascadingValue Value="this" IsFixed="@true">
|
||||
<div class="@this.CollapseClass">
|
||||
<MudStack Row="@true" Wrap="@Wrap.Wrap" Class="@this.StackClass">
|
||||
@this.ChildContent
|
||||
@foreach (var plugin in this.Plugins)
|
||||
{
|
||||
<AssistantPluginBlock @key="@plugin.Id" Plugin="@plugin"/>
|
||||
}
|
||||
</MudStack>
|
||||
</div>
|
||||
</CascadingValue>
|
||||
}
|
||||
@@ -1,3 +1,7 @@
|
||||
using AIStudio.Settings;
|
||||
using AIStudio.Tools.PluginSystem;
|
||||
using AIStudio.Tools.PluginSystem.Assistants;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace AIStudio.Components;
|
||||
@@ -8,17 +12,36 @@ namespace AIStudio.Components;
|
||||
/// <remarks>
|
||||
/// The heading is derived from the assistant blocks inside this category: it is rendered only when
|
||||
/// at least one of them is visible. Thus, hiding assistants by configuration can never leave an
|
||||
/// empty category heading behind.
|
||||
/// empty category heading behind. The built-in assistants of the category come as child content,
|
||||
/// followed by the assistant plugins which name this category.<br/><br/>
|
||||
/// A category the user hid renders nothing at all. One the user collapsed keeps rendering its blocks
|
||||
/// and only hides them, so that its heading stays. Each block reports to the registry of the page
|
||||
/// after rendering, so that the page knows which categories it shows.
|
||||
/// </remarks>
|
||||
public partial class AssistantCategoryBlock : ComponentBase
|
||||
public partial class AssistantCategoryBlock : ComponentBase, IDisposable
|
||||
{
|
||||
private readonly HashSet<IAssistantCategoryMember> members = [];
|
||||
|
||||
[Inject]
|
||||
private SettingsManager SettingsManager { get; init; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// The heading of this category.
|
||||
/// The registry of the assistants page, which learns which categories the page shows.
|
||||
/// </summary>
|
||||
[CascadingParameter]
|
||||
public AssistantCategoryRegistry? Registry { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The category of this block. Its name is the heading.
|
||||
/// </summary>
|
||||
[Parameter, EditorRequired]
|
||||
public AssistantCategoryKey Category { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// The assistant plugins which name this category, in the order to show them.
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public IReadOnlyList<PluginAssistants> Plugins { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// The CSS classes used for the heading.
|
||||
@@ -58,6 +81,42 @@ public partial class AssistantCategoryBlock : ComponentBase
|
||||
/// </remarks>
|
||||
private bool HasVisibleAssistant => this.members.Any(member => member.IsVisible);
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether this category shows at least one assistant right now, collapsed or not.
|
||||
/// </summary>
|
||||
internal bool IsShowingAssistants => !this.IsHidden && this.HasVisibleAssistant;
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the user collapsed this category.
|
||||
/// </summary>
|
||||
private bool IsCollapsed => this.SettingsManager.ConfigurationData.AssistantsPage.IsCategoryCollapsed(this.Category);
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the user hid this category.
|
||||
/// </summary>
|
||||
private bool IsHidden => this.SettingsManager.ConfigurationData.AssistantsPage.IsCategoryHidden(this.Category);
|
||||
|
||||
#region Overrides of ComponentBase
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
this.Registry?.Register(this);
|
||||
base.OnInitialized();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnAfterRender(bool firstRender)
|
||||
{
|
||||
this.Registry?.ReportChange();
|
||||
base.OnAfterRender(firstRender);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose() => this.Registry?.Unregister(this);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the CSS classes used for the assistant stack.
|
||||
/// </summary>
|
||||
@@ -67,4 +126,41 @@ public partial class AssistantCategoryBlock : ComponentBase
|
||||
/// that a hidden category leaves no gap behind.
|
||||
/// </remarks>
|
||||
private string StackClass => this.HasVisibleAssistant ? "mb-3" : string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the CSS classes of the element around the assistant stack, which hide a collapsed category.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A collapsed category keeps rendering its blocks, since they register themselves while rendering,
|
||||
/// and only hides them, so that its heading stays. The class sits on a plain element around the stack:
|
||||
/// MudStack always carries the class d-flex, which MudBlazor declares after d-none and with the same
|
||||
/// weight, so d-none on the stack itself has no effect.
|
||||
/// </remarks>
|
||||
private string CollapseClass => this.IsCollapsed ? "d-none" : string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Collapses this category or expands it again, and remembers that.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The user clicks once, so storing the settings right away costs nothing noticeable.
|
||||
/// </remarks>
|
||||
private async Task ToggleCollapsedAsync()
|
||||
{
|
||||
this.SettingsManager.ConfigurationData.AssistantsPage.SetCategoryCollapsed(this.Category, !this.IsCollapsed);
|
||||
await this.SettingsManager.StoreSettings();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hides this category and remembers that.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The heading asked the user before, and told them how to get the category back. The whole app learns
|
||||
/// about it, since a hidden category may also take its assistants out of the "Send to ..." menu.
|
||||
/// </remarks>
|
||||
private async Task HideAsync()
|
||||
{
|
||||
this.SettingsManager.ConfigurationData.AssistantsPage.SetCategoryHidden(this.Category, true);
|
||||
await this.SettingsManager.StoreSettings();
|
||||
await MessageBus.INSTANCE.SendMessage<bool>(this, Event.CONFIGURATION_CHANGED);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
@inherits MSGComponentBase
|
||||
<MudStack Row="@true" AlignItems="AlignItems.Center" Spacing="1" Class="@this.Class">
|
||||
<MudTooltip Text="@this.ToggleTooltip" Placement="Placement.Top">
|
||||
<MudButton Variant="Variant.Text" Color="Color.Default" Class="px-1" Style="min-width:auto; text-transform:none;" OnClick="@this.OnToggleCollapsed">
|
||||
<MudStack Row="@true" AlignItems="AlignItems.Center" Spacing="2">
|
||||
<MudText Typo="Typo.h4">
|
||||
@this.Category.Name
|
||||
</MudText>
|
||||
<MudIcon Icon="@(this.IsCollapsed ? AppIcons.EXPAND_MORE : AppIcons.EXPAND_LESS)"/>
|
||||
</MudStack>
|
||||
</MudButton>
|
||||
</MudTooltip>
|
||||
<MudTooltip Text="@T("Hide this category")" Placement="Placement.Top">
|
||||
<MudIconButton Icon="@AppIcons.HIDDEN" Size="Size.Small" Color="Color.Default" OnClick="@this.ConfirmHideAsync"/>
|
||||
</MudTooltip>
|
||||
</MudStack>
|
||||
@@ -0,0 +1,86 @@
|
||||
using AIStudio.Dialogs;
|
||||
using AIStudio.Settings.DataModel;
|
||||
using AIStudio.Tools.PluginSystem;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
using DialogOptions = AIStudio.Dialogs.DialogOptions;
|
||||
|
||||
namespace AIStudio.Components;
|
||||
|
||||
/// <summary>
|
||||
/// The heading of a category on the assistants page, which collapses and expands the category, and hides it.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The whole heading is the button which collapses the category, so that users find it where they look.
|
||||
/// The eye next to it hides the category, after the user confirmed it. The category block keeps the state,
|
||||
/// since it also decides what the category shows.
|
||||
/// </remarks>
|
||||
public partial class AssistantCategoryHeader : MSGComponentBase
|
||||
{
|
||||
[Inject]
|
||||
private IDialogService DialogService { get; init; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// The category whose name is the heading.
|
||||
/// </summary>
|
||||
[Parameter, EditorRequired]
|
||||
public AssistantCategoryKey Category { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the user collapsed the category.
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public bool IsCollapsed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Called when the user clicks the heading to collapse or expand the category.
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public EventCallback OnToggleCollapsed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Called when the user hides the category and confirmed it.
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public EventCallback OnHide { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The CSS classes of the heading.
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public string Class { get; set; } = string.Empty;
|
||||
|
||||
private string ToggleTooltip => this.IsCollapsed ? T("Expand this category") : T("Collapse this category");
|
||||
|
||||
/// <summary>
|
||||
/// Asks the user whether to hide the category, and hides it on a yes.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Many users click the eye just to see what it does. A category gone without a word would startle them,
|
||||
/// so the dialog says what happens, where to show the category again, and that collapsing it might be all
|
||||
/// they want. What happens to the assistants elsewhere depends on the option of the user, so the dialog
|
||||
/// describes the one in effect.
|
||||
/// </remarks>
|
||||
private async Task ConfirmHideAsync()
|
||||
{
|
||||
var effect = this.SettingsManager.ConfigurationData.AssistantsPage.HiddenCategoryAssistants is AssistantOfferBehavior.KEEP_OFFERING
|
||||
? TA("""The assistants page will no longer show this category. AI Studio keeps offering its assistants elsewhere, e.g., in the "Send to ..." menu.""")
|
||||
: TA("""The assistants page will no longer show this category, and AI Studio will treat its assistants as if they did not exist, e.g., they will not appear in the "Send to ..." menu.""");
|
||||
|
||||
var wayBack = TA("You can show the category again at any time in the assistant settings, which the gear next to the heading of the page opens.");
|
||||
var alternative = TA("If you only want a better overview, click the heading of the category instead: that collapses it.");
|
||||
|
||||
var dialogParameters = new DialogParameters<ConfirmDialog>
|
||||
{
|
||||
{ x => x.MarkdownBody, $"{effect}\n\n{wayBack}\n\n{alternative}" },
|
||||
};
|
||||
|
||||
var dialogReference = await this.DialogService.ShowAsync<ConfirmDialog>(string.Format(T("Hide the category '{0}'?"), this.Category.Name), dialogParameters, DialogOptions.FULLSCREEN);
|
||||
var dialogResult = await dialogReference.Result;
|
||||
if (dialogResult is null || dialogResult.Canceled)
|
||||
return;
|
||||
|
||||
await this.OnHide.InvokeAsync();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using AIStudio.Tools.PluginSystem;
|
||||
|
||||
namespace AIStudio.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Knows which categories the assistants page shows right now.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Whether a category shows any assistant is known only after its blocks rendered: the built-in assistants
|
||||
/// come as markup and decide on their own whether they are visible. The category blocks therefore report
|
||||
/// here after every rendering, just as the assistant blocks report to their category. The page asks which
|
||||
/// categories its settings dialog offers, and whether it shows any category at all.
|
||||
/// </remarks>
|
||||
public sealed class AssistantCategoryRegistry
|
||||
{
|
||||
private readonly HashSet<AssistantCategoryBlock> blocks = [];
|
||||
|
||||
/// <summary>
|
||||
/// Raised when the page went from showing no category to showing one, or the other way round.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Only this change matters to the page itself, so it renders again only then, not whenever a block
|
||||
/// reports.
|
||||
/// </remarks>
|
||||
public event Action? ShowsAnyCategoryChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the page shows at least one category, or null until the first block reported.
|
||||
/// </summary>
|
||||
public bool? ShowsAnyCategory { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the categories which show at least one assistant right now.
|
||||
/// </summary>
|
||||
public IReadOnlyList<AssistantCategoryKey> ShownCategories => this.blocks
|
||||
.Where(block => block.IsShowingAssistants)
|
||||
.Select(block => block.Category)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
|
||||
/// <summary>
|
||||
/// Adds a category block of the page.
|
||||
/// </summary>
|
||||
/// <param name="block">The block which joins the page.</param>
|
||||
internal void Register(AssistantCategoryBlock block) => this.blocks.Add(block);
|
||||
|
||||
/// <summary>
|
||||
/// Removes a category block of the page, e.g., when the plugins of its category are gone.
|
||||
/// </summary>
|
||||
/// <param name="block">The block which leaves the page.</param>
|
||||
internal void Unregister(AssistantCategoryBlock block) => this.blocks.Remove(block);
|
||||
|
||||
/// <summary>
|
||||
/// Takes note that a block rendered and might show something else now.
|
||||
/// </summary>
|
||||
internal void ReportChange()
|
||||
{
|
||||
var showsAnyCategory = this.blocks.Any(block => block.IsShowingAssistants);
|
||||
if (this.ShowsAnyCategory == showsAnyCategory)
|
||||
return;
|
||||
|
||||
this.ShowsAnyCategory = showsAnyCategory;
|
||||
this.ShowsAnyCategoryChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
@using AIStudio.Dialogs.Settings
|
||||
@inherits MSGComponentBase
|
||||
|
||||
<AssistantBlock TSettings="NoSettingsPanel"
|
||||
Component="Components.DYNAMIC_ASSISTANT"
|
||||
Name="@this.Plugin.AssistantTitle"
|
||||
Description="@this.Plugin.Description"
|
||||
Icon="@AppIcons.ASSISTANT_PLUGIN"
|
||||
Disabled="@(!this.SecurityState.CanStartAssistant)"
|
||||
AssistantSessionInstanceId="@this.Plugin.Id.ToString()"
|
||||
Link="@this.LaunchLink"
|
||||
OnClick="@this.StartAsync">
|
||||
<AdditionalActions>
|
||||
<DirectChatLauncherSettingsAction Plugin="@this.Plugin" />
|
||||
@if (this.AvailablePlugin is not null)
|
||||
{
|
||||
<PluginDeleteAction Plugin="@this.AvailablePlugin" />
|
||||
}
|
||||
</AdditionalActions>
|
||||
<SecurityBadge>
|
||||
<AssistantPluginSecurityCard Plugin="@this.Plugin" Compact="@true" />
|
||||
</SecurityBadge>
|
||||
</AssistantBlock>
|
||||
@@ -0,0 +1,61 @@
|
||||
using AIStudio.Tools.PluginSystem;
|
||||
using AIStudio.Tools.PluginSystem.Assistants;
|
||||
using AIStudio.Tools.Services;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace AIStudio.Components;
|
||||
|
||||
/// <summary>
|
||||
/// The tile of an assistant plugin on the assistants page.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A plugin appears in each of its categories, so the page may show this tile more than once. A form
|
||||
/// assistant opens its page, a direct chat launcher opens its chat right away. The plugin texts are shown
|
||||
/// as the plugin states them: AI Studio does not translate them.
|
||||
/// </remarks>
|
||||
public partial class AssistantPluginBlock : MSGComponentBase
|
||||
{
|
||||
/// <summary>
|
||||
/// The assistant plugin this tile starts.
|
||||
/// </summary>
|
||||
[Parameter, EditorRequired]
|
||||
public PluginAssistants Plugin { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
private NavigationManager NavigationManager { get; init; } = null!;
|
||||
|
||||
[Inject]
|
||||
private DirectChatService DirectChatService { get; init; } = null!;
|
||||
|
||||
private PluginAssistantSecurityState SecurityState => PluginAssistantSecurityResolver.Resolve(this.SettingsManager, this.Plugin);
|
||||
|
||||
private string LaunchLink => this.Plugin.StartsChatDirectly ? string.Empty : $"{Routes.ASSISTANT_DYNAMIC}?assistantId={this.Plugin.Id}";
|
||||
|
||||
/// <summary>
|
||||
/// The plugin as the plugin factory lists it, which the delete action needs.
|
||||
/// </summary>
|
||||
private IAvailablePlugin? AvailablePlugin => PluginFactory.AvailablePlugins.OfType<IAvailablePlugin>().FirstOrDefault(plugin => plugin.Id == this.Plugin.Id);
|
||||
|
||||
private async Task StartAsync()
|
||||
{
|
||||
if (!this.SecurityState.CanStartAssistant)
|
||||
return;
|
||||
|
||||
if (!this.Plugin.StartsChatDirectly)
|
||||
{
|
||||
this.NavigationManager.NavigateTo(this.LaunchLink);
|
||||
return;
|
||||
}
|
||||
|
||||
var result = await this.DirectChatService.TryCreateAssistantChatAsync(this.Plugin);
|
||||
if (result.Request is null)
|
||||
{
|
||||
await this.MessageBus.SendError(new(AppIcons.ERROR, result.ErrorMessage));
|
||||
return;
|
||||
}
|
||||
|
||||
MessageBus.INSTANCE.DeferMessage(this, Event.SEND_TO_CHAT, result.Request);
|
||||
this.NavigationManager.NavigateTo(Routes.CHAT);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<MudStack Row="@true" Class="mb-3">
|
||||
<MudSelect T="@T" Value="@this.Value" ValueChanged="@this.SelectionChanged" AdornmentIcon="@this.Icon" Adornment="Adornment.Start" IconSize="@this.IconSize" Label="@this.Label" Variant="Variant.Outlined" Margin="Margin.Dense" Validation="@this.ValidateSelection" Disabled="@this.Disabled">
|
||||
@foreach (var value in Enum.GetValues<T>())
|
||||
@foreach (var value in this.OfferedValues)
|
||||
{
|
||||
<MudSelectItem Value="@value">
|
||||
@this.NameFunc(value)
|
||||
|
||||
@@ -59,7 +59,18 @@ public partial class EnumSelection<T> : EnumSelectionBase where T : struct, Enum
|
||||
|
||||
[Parameter]
|
||||
public Func<T, Task> SelectionUpdated { get; set; } = _ => Task.CompletedTask;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the values to offer, in the order to show them.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Without it, the selection offers every value of the enum in the order of its declaration.
|
||||
/// </remarks>
|
||||
[Parameter]
|
||||
public IReadOnlyList<T>? Values { get; set; }
|
||||
|
||||
private IReadOnlyList<T> OfferedValues => this.Values ?? Enum.GetValues<T>();
|
||||
|
||||
[Inject]
|
||||
private SettingsManager SettingsManager { get; set; } = null!;
|
||||
|
||||
|
||||
Reference in new issue
Block a user