Changed the plugin list to be a table

This commit is contained in:
Thorsten Sommer 2025-03-27 07:40:48 +01:00
parent c99b231f4a
commit 3f57207512
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
2 changed files with 82 additions and 18 deletions

View File

@ -8,27 +8,58 @@
<PreviewExperimental ApplyInnerScrollingFix="true"/>
<InnerScrolling>
<MudList T="string">
@foreach (var plugin in PluginFactory.AvailablePlugins)
<MudTable Items="@PluginFactory.AvailablePlugins" Hover="@true" GroupBy="@this.groupConfig" Class="border-dashed border rounded-lg">
<ColGroup>
<col/>
<col style="width: 12em;"/>
</ColGroup>
<HeaderContent>
<MudTh>Plugin</MudTh>
<MudTh>Actions</MudTh>
</HeaderContent>
<GroupHeaderTemplate>
<MudTh Class="mud-table-cell-custom-group" colspan="2">
@switch (context.Key)
{
<MudListItem>
<AvatarContent>
<MudAvatar Size="Size.Large" Class="align-content-stretch me-4">
case GROUP_ENABLED:
<MudText Typo="Typo.h6" Class="mb-2">
Enabled Plugins
</MudText>
break;
case GROUP_DISABLED:
<MudText Typo="Typo.h6" Class="mb-2">
Disabled Plugins
</MudText>
break;
case GROUP_INTERNAL:
<MudText Typo="Typo.h6" Class="mb-2">
Internal Plugins
</MudText>
break;
}
</MudTh>
</GroupHeaderTemplate>
<RowTemplate>
<MudStack Row="true">
<MudAvatar Size="Size.Medium" Class="align-content-stretch me-4">
<div class="plugin-icon-container">
@((MarkupString)plugin.IconSVG)
@((MarkupString)context.IconSVG)
</div>
</MudAvatar>
</AvatarContent>
<ChildContent>
<MudStack Class="mb-2 mt-2">
<MudText Typo="Typo.h6">
@plugin.Name
@context.Name
</MudText>
<MudJustifiedText Typo="Typo.body1">
@plugin.Description
@context.Description
</MudJustifiedText>
</ChildContent>
</MudListItem>
}
</MudList>
</MudStack>
</MudStack>
</RowTemplate>
</MudTable>
</InnerScrolling>
</div>

View File

@ -1,7 +1,40 @@
using AIStudio.Settings;
using AIStudio.Tools.PluginSystem;
using Microsoft.AspNetCore.Components;
namespace AIStudio.Pages;
public partial class Plugins : ComponentBase
{
private const string GROUP_ENABLED = "Enabled";
private const string GROUP_DISABLED = "Disabled";
private const string GROUP_INTERNAL = "Internal";
[Inject]
private SettingsManager SettingsManager { get; init; } = null!;
private TableGroupDefinition<IPluginMetadata> groupConfig = null!;
#region Overrides of ComponentBase
protected override async Task OnInitializedAsync()
{
this.groupConfig = new TableGroupDefinition<IPluginMetadata>
{
Selector = pluginMeta =>
{
if (pluginMeta.IsInternal)
return GROUP_INTERNAL;
return SettingsManager.ConfigurationData.EnabledPlugins.Contains(pluginMeta.Id)
? GROUP_ENABLED
: GROUP_DISABLED;
}
};
await base.OnInitializedAsync();
}
#endregion
}