mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-13 17:53:48 +00:00
Added detailed plugin information to the plugins page (#1013)
Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
This commit is contained in:
1 parent
b371b3d54f
commit
f912af321f
26 files changed
+884
-95
No files matched your search
@@ -0,0 +1,78 @@
|
||||
@inherits MSGComponentBase
|
||||
<MudDialog>
|
||||
<DialogContent>
|
||||
<MudJustifiedText Typo="Typo.body1" Class="mb-3">
|
||||
@T("Here are the details of this plugin. Most of them come from its authors, and AI Studio shows them as stated without being able to verify them.")
|
||||
</MudJustifiedText>
|
||||
|
||||
<MudSimpleTable Dense="@true" Hover="@true" Bordered="@true" Striped="@true" Style="overflow-x: auto;">
|
||||
<tbody>
|
||||
<InfoTableRow Icon="@Icons.Material.Filled.Description" Label="@T("Description")">
|
||||
<MudText Typo="Typo.body2">@this.Plugin.Description</MudText>
|
||||
</InfoTableRow>
|
||||
<InfoTableRow Icon="@Icons.Material.Filled.Extension" Label="@T("Type")">
|
||||
<MudText Typo="Typo.body2">@this.TypeText</MudText>
|
||||
</InfoTableRow>
|
||||
<InfoTableRow Icon="@Icons.Material.Filled.Tag" Label="@T("Version")">
|
||||
<MudText Typo="Typo.body2">@this.Plugin.Version</MudText>
|
||||
</InfoTableRow>
|
||||
<InfoTableRow Icon="@Icons.Material.Filled.EditCalendar" Label="@T("Last changed")">
|
||||
<MudText Typo="Typo.body2">@this.LastChangedText</MudText>
|
||||
</InfoTableRow>
|
||||
<InfoTableRow Icon="@Icons.Material.Filled.People" Label="@T("Authors")">
|
||||
<MudText Typo="Typo.body2">@this.AuthorsText</MudText>
|
||||
</InfoTableRow>
|
||||
@if (!string.IsNullOrWhiteSpace(this.Plugin.SupportContact))
|
||||
{
|
||||
<InfoTableRow Icon="@Icons.Material.Filled.SupportAgent" Label="@T("Support contact")">
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1">
|
||||
<MudText Typo="Typo.body2" Style="overflow-wrap: anywhere;">@this.SupportContactText</MudText>
|
||||
<PluginLinkButton Url="@this.Plugin.SupportContact" Size="Size.Small"/>
|
||||
</MudStack>
|
||||
</InfoTableRow>
|
||||
}
|
||||
@if (!string.IsNullOrWhiteSpace(this.Plugin.SourceURL))
|
||||
{
|
||||
<InfoTableRow Icon="@this.SourceIcon" Label="@this.SourceLabel">
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1">
|
||||
<MudText Typo="Typo.body2" Style="overflow-wrap: anywhere;">@this.SourceText</MudText>
|
||||
<PluginLinkButton Url="@this.Plugin.SourceURL" Size="Size.Small"/>
|
||||
</MudStack>
|
||||
</InfoTableRow>
|
||||
}
|
||||
<InfoTableRow Icon="@Icons.Material.Filled.Category" Label="@T("Categories")">
|
||||
<MudText Typo="Typo.body2">@this.CategoriesText</MudText>
|
||||
</InfoTableRow>
|
||||
<InfoTableRow Icon="@Icons.Material.Filled.Groups" Label="@T("Target groups")">
|
||||
<MudText Typo="Typo.body2">@this.TargetGroupsText</MudText>
|
||||
</InfoTableRow>
|
||||
<InfoTableRow Icon="@Icons.Material.Filled.Fingerprint" Label="@T("Plugin ID")">
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1">
|
||||
<MudText Typo="Typo.body2" Style="overflow-wrap: anywhere;">@this.Plugin.Id</MudText>
|
||||
<MudCopyClipboardButton StringContent="@this.Plugin.Id.ToString()" TooltipMessage="@T("Copies the plugin ID to the clipboard")"/>
|
||||
</MudStack>
|
||||
</InfoTableRow>
|
||||
@if (this.Plugin.IsManagedByConfigServer)
|
||||
{
|
||||
<InfoTableRow Icon="@Icons.Material.Filled.Business" Label="@T("Origin")">
|
||||
<MudText Typo="Typo.body2">@T("Managed by your organization")</MudText>
|
||||
</InfoTableRow>
|
||||
}
|
||||
</tbody>
|
||||
</MudSimpleTable>
|
||||
|
||||
@if (!this.Plugin.IsMaintained || !string.IsNullOrWhiteSpace(this.Plugin.DeprecationMessage))
|
||||
{
|
||||
<MudAlert Severity="Severity.Warning" Variant="Variant.Outlined" Class="mt-3">
|
||||
@(string.IsNullOrWhiteSpace(this.Plugin.DeprecationMessage)
|
||||
? T("The authors marked this plugin as no longer maintained.")
|
||||
: string.Format(T("The authors marked this plugin as deprecated: {0}"), this.Plugin.DeprecationMessage))
|
||||
</MudAlert>
|
||||
}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton OnClick="@this.Close" Variant="Variant.Filled">
|
||||
@T("Close")
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
@@ -0,0 +1,70 @@
|
||||
using AIStudio.Components;
|
||||
using AIStudio.Tools.PluginSystem;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace AIStudio.Dialogs;
|
||||
|
||||
/// <summary>
|
||||
/// Shows the details of a plugin on the plugins page: what its authors state about it, and whether an
|
||||
/// organization manages it.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The plugins page lists only the name, the version, and the description of a plugin. Everything else
|
||||
/// a plugin states, such as its authors or where to get support, would otherwise only be found in its
|
||||
/// code.
|
||||
/// </remarks>
|
||||
public partial class PluginInfoDialog : MSGComponentBase
|
||||
{
|
||||
[CascadingParameter]
|
||||
private IMudDialogInstance MudDialog { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// The plugin to show. The metadata alone would not do, because only an available plugin knows
|
||||
/// whether an organization manages it.
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public IAvailablePlugin Plugin { get; set; } = null!;
|
||||
|
||||
private string TypeText => this.Plugin.Type.GetName();
|
||||
|
||||
private string AuthorsText => this.Plugin.Authors.Length > 0 ? string.Join(", ", this.Plugin.Authors) : this.T("No authors specified");
|
||||
|
||||
private string CategoriesText => this.Plugin.Categories.Length > 0 ? string.Join(", ", this.Plugin.Categories.Select(category => category.GetName())) : this.T("No categories specified");
|
||||
|
||||
private string TargetGroupsText => this.Plugin.TargetGroups.Length > 0 ? string.Join(", ", this.Plugin.TargetGroups.Select(targetGroup => targetGroup.Name())) : this.T("No target groups specified");
|
||||
|
||||
/// <summary>
|
||||
/// The plugin states the time in UTC; the user reads it in their own time zone.
|
||||
/// </summary>
|
||||
private string LastChangedText => this.Plugin.LastChanged?.ToLocalTime().ToString("g", I18N.I.Culture) ?? this.T("Not specified");
|
||||
|
||||
private string SupportContactText => this.GetLinkText(this.Plugin.SupportContact);
|
||||
|
||||
private string SourceText => this.GetLinkText(this.Plugin.SourceURL);
|
||||
|
||||
/// <summary>
|
||||
/// The field SOURCE_URL holds a website, such as a repository or a wiki, or a mail address. The
|
||||
/// label and the icon of its row name which of both it is, since "source" would fit neither a wiki
|
||||
/// nor a mail address.
|
||||
/// </summary>
|
||||
private bool IsSourceAMail => PluginLinks.TryParse(this.Plugin.SourceURL, out var link) && PluginLinks.IsMail(link);
|
||||
|
||||
private string SourceLabel => this.IsSourceAMail ? this.T("Email contact") : this.T("Related link");
|
||||
|
||||
private string SourceIcon => this.IsSourceAMail ? Icons.Material.Filled.ContactMail : Icons.Material.Filled.Link;
|
||||
|
||||
/// <summary>
|
||||
/// Shows a link the way the user recognizes it: a mail address without its scheme, and a placeholder
|
||||
/// of the Assistant Builder as not stated. A text which is no link stays as it is.
|
||||
/// </summary>
|
||||
private string GetLinkText(string text)
|
||||
{
|
||||
if (PluginLinks.IsPlaceholder(text))
|
||||
return this.T("Not specified");
|
||||
|
||||
return PluginLinks.TryParse(text, out var link) ? PluginLinks.GetDisplayText(link) : text;
|
||||
}
|
||||
|
||||
private void Close() => this.MudDialog.Close();
|
||||
}
|
||||
Reference in new issue
Block a user