Ensure DRY on the info page

This commit is contained in:
Thorsten Sommer 2026-02-19 20:30:24 +01:00
parent a92f3635f2
commit adfc70a0ea
Signed by untrusted user who does not match committer: tsommer
GPG Key ID: 371BBA77A02C0108
7 changed files with 188 additions and 116 deletions

View File

@ -0,0 +1,10 @@
<div style="display: flex; align-items: center; gap: 8px; @this.Style">
<MudIcon Icon="@this.Icon"/>
<span>
@this.Text
</span>
@if (!string.IsNullOrWhiteSpace(this.CopyValue))
{
<MudCopyClipboardButton TooltipMessage="@this.CopyTooltip" StringContent="@this.CopyValue"/>
}
</div>

View File

@ -0,0 +1,21 @@
using Microsoft.AspNetCore.Components;
namespace AIStudio.Components;
public partial class ConfigInfoRow : ComponentBase
{
[Parameter]
public string Icon { get; set; } = Icons.Material.Filled.ArrowRightAlt;
[Parameter]
public string Text { get; set; } = string.Empty;
[Parameter]
public string CopyValue { get; set; } = string.Empty;
[Parameter]
public string CopyTooltip { get; set; } = string.Empty;
[Parameter]
public string Style { get; set; } = string.Empty;
}

View File

@ -0,0 +1,25 @@
<MudPaper Outlined="true" Class="@this.Class">
<div style="display: flex; align-items: center; gap: 8px; margin-bottom: 8px;">
<MudIcon Icon="@this.HeaderIcon" Size="Size.Small"/>
<MudText Typo="Typo.subtitle2">
@this.HeaderText
</MudText>
</div>
@foreach (var item in this.Items)
{
<ConfigInfoRow Icon="@item.Icon"
Text="@item.Text"
CopyValue="@item.CopyValue"
CopyTooltip="@item.CopyTooltip"
Style="@(item.Style)"/>
}
@if (this.ShowWarning)
{
<div style="display: flex; align-items: center; gap: 8px; margin-top: 4px;">
<MudIcon Icon="@Icons.Material.Filled.Warning" Size="Size.Small" Color="Color.Warning"/>
<MudText Typo="Typo.subtitle2">@this.WarningText</MudText>
</div>
}
</MudPaper>

View File

@ -0,0 +1,32 @@
using Microsoft.AspNetCore.Components;
namespace AIStudio.Components;
public partial class ConfigPluginInfoCard : ComponentBase
{
[Parameter]
public string HeaderIcon { get; set; } = Icons.Material.Filled.Extension;
[Parameter]
public string HeaderText { get; set; } = string.Empty;
[Parameter]
public IEnumerable<ConfigInfoRowItem> Items { get; set; } = [];
[Parameter]
public bool ShowWarning { get; set; }
[Parameter]
public string WarningText { get; set; } = string.Empty;
[Parameter]
public string Class { get; set; } = "pa-3 mt-2 mb-2";
}
public sealed record ConfigInfoRowItem(
string Icon,
string Text,
string CopyValue = "",
string CopyTooltip = "",
string Style = ""
);

View File

@ -0,0 +1,15 @@
<MudText Typo="Typo.body1" Class="@this.Class">
<div style="display: flex; align-items: center; gap: 8px;">
<MudIcon Icon="@Icons.Material.Filled.ArrowRightAlt"/>
@if (this.IsConfigured)
{
<MudIcon Icon="@Icons.Material.Filled.CheckCircle" Color="Color.Success" Size="Size.Small"/>
<span>@this.ConfiguredText</span>
}
else
{
<MudIcon Icon="@Icons.Material.Filled.Cancel" Color="Color.Error" Size="Size.Small"/>
<span>@this.NotConfiguredText</span>
}
</div>
</MudText>

View File

@ -0,0 +1,18 @@
using Microsoft.AspNetCore.Components;
namespace AIStudio.Components;
public partial class EncryptionSecretInfo : ComponentBase
{
[Parameter]
public bool IsConfigured { get; set; }
[Parameter]
public string ConfiguredText { get; set; } = string.Empty;
[Parameter]
public string NotConfiguredText { get; set; } = string.Empty;
[Parameter]
public string Class { get; set; } = "mt-2 mb-2";
}

View File

@ -64,33 +64,19 @@
<MudCollapse Expanded="@this.showEnterpriseConfigDetails"> <MudCollapse Expanded="@this.showEnterpriseConfigDetails">
@foreach (var plug in this.configPlugins) @foreach (var plug in this.configPlugins)
{ {
<MudPaper Outlined="true" Class="pa-3 mt-2 mb-2"> <ConfigPluginInfoCard HeaderIcon="@Icons.Material.Filled.Extension"
<div style="display: flex; align-items: center; gap: 8px; margin-bottom: 8px;"> HeaderText="@plug.Name"
<MudIcon Icon="@Icons.Material.Filled.Extension" Size="Size.Small"/> Items="@(new[]
<MudText Typo="Typo.subtitle2">@plug.Name</MudText> {
</div> new ConfigInfoRowItem(Icons.Material.Filled.ArrowRightAlt,
<div style="display: flex; align-items: center; gap: 8px;"> $"{T("Configuration plugin ID:")} {plug.Id}",
<MudIcon Icon="@Icons.Material.Filled.ArrowRightAlt"/> plug.Id.ToString(),
<span>@T("Configuration plugin ID:") @plug.Id</span> T("Copies the configuration plugin ID to the clipboard"))
<MudCopyClipboardButton TooltipMessage="@T("Copies the configuration plugin ID to the clipboard")" StringContent=@plug.Id.ToString()/> })"/>
</div>
</MudPaper>
} }
<MudText Typo="Typo.body1" Class="mt-2 mb-2"> <EncryptionSecretInfo IsConfigured="@(PluginFactory.EnterpriseEncryption?.IsAvailable is true)"
<div style="display: flex; align-items: center; gap: 8px;"> ConfiguredText="@T("Encryption secret: is configured")"
<MudIcon Icon="@Icons.Material.Filled.ArrowRightAlt"/> NotConfiguredText="@T("Encryption secret: is not configured")"/>
@if (PluginFactory.EnterpriseEncryption?.IsAvailable is true)
{
<MudIcon Icon="@Icons.Material.Filled.CheckCircle" Color="Color.Success" Size="Size.Small"/>
<span>@T("Encryption secret: is configured")</span>
}
else
{
<MudIcon Icon="@Icons.Material.Filled.Cancel" Color="Color.Error" Size="Size.Small"/>
<span>@T("Encryption secret: is not configured")</span>
}
</div>
</MudText>
</MudCollapse> </MudCollapse>
break; break;
@ -101,38 +87,24 @@
<MudCollapse Expanded="@this.showEnterpriseConfigDetails"> <MudCollapse Expanded="@this.showEnterpriseConfigDetails">
@foreach (var env in EnterpriseEnvironmentService.CURRENT_ENVIRONMENTS.Where(e => e.IsActive)) @foreach (var env in EnterpriseEnvironmentService.CURRENT_ENVIRONMENTS.Where(e => e.IsActive))
{ {
<MudPaper Outlined="true" Class="pa-3 mt-2 mb-2"> <ConfigPluginInfoCard HeaderIcon="@Icons.Material.Filled.HourglassBottom"
<div style="display: flex; align-items: center; gap: 8px; margin-bottom: 8px;"> HeaderText="@T("Waiting for the configuration plugin...")"
<MudIcon Icon="@Icons.Material.Filled.HourglassBottom" Size="Size.Small"/> Items="@(new[]
<MudText Typo="Typo.subtitle2">@T("Waiting for the configuration plugin...")</MudText> {
</div> new ConfigInfoRowItem(Icons.Material.Filled.ArrowRightAlt,
<div style="display: flex; align-items: center; gap: 8px;"> $"{T("Enterprise configuration ID:")} {env.ConfigurationId}",
<MudIcon Icon="@Icons.Material.Filled.ArrowRightAlt"/> env.ConfigurationId.ToString(),
<span>@T("Enterprise configuration ID:") @env.ConfigurationId</span> T("Copies the config ID to the clipboard")),
<MudCopyClipboardButton TooltipMessage="@T("Copies the config ID to the clipboard")" StringContent=@env.ConfigurationId.ToString()/> new ConfigInfoRowItem(Icons.Material.Filled.ArrowRightAlt,
</div> $"{T("Configuration server:")} {env.ConfigurationServerUrl}",
<div style="display: flex; align-items: center; gap: 8px; margin-top: 4px;"> env.ConfigurationServerUrl,
<MudIcon Icon="@Icons.Material.Filled.ArrowRightAlt"/> T("Copies the server URL to the clipboard"),
<span>@T("Configuration server:") @env.ConfigurationServerUrl</span> "margin-top: 4px;")
<MudCopyClipboardButton TooltipMessage="@T("Copies the server URL to the clipboard")" StringContent=@env.ConfigurationServerUrl/> })"/>
</div>
</MudPaper>
} }
<MudText Typo="Typo.body1" Class="mt-2 mb-2"> <EncryptionSecretInfo IsConfigured="@(PluginFactory.EnterpriseEncryption?.IsAvailable is true)"
<div style="display: flex; align-items: center; gap: 8px;"> ConfiguredText="@T("Encryption secret: is configured")"
<MudIcon Icon="@Icons.Material.Filled.ArrowRightAlt"/> NotConfiguredText="@T("Encryption secret: is not configured")"/>
@if (PluginFactory.EnterpriseEncryption?.IsAvailable is true)
{
<MudIcon Icon="@Icons.Material.Filled.CheckCircle" Color="Color.Success" Size="Size.Small"/>
<span>@T("Encryption secret: is configured")</span>
}
else
{
<MudIcon Icon="@Icons.Material.Filled.Cancel" Color="Color.Error" Size="Size.Small"/>
<span>@T("Encryption secret: is not configured")</span>
}
</div>
</MudText>
</MudCollapse> </MudCollapse>
break; break;
@ -155,68 +127,47 @@
var matchingPlugin = this.FindManagedConfigurationPlugin(env.ConfigurationId); var matchingPlugin = this.FindManagedConfigurationPlugin(env.ConfigurationId);
if (matchingPlugin is null) if (matchingPlugin is null)
{ {
<MudPaper Outlined="true" Class="pa-3 mt-2 mb-2"> <ConfigPluginInfoCard HeaderIcon="@Icons.Material.Filled.HourglassBottom"
<div style="display: flex; align-items: center; gap: 8px; margin-bottom: 8px;"> HeaderText="@T("Waiting for the configuration plugin...")"
<MudIcon Icon="@Icons.Material.Filled.HourglassBottom" Size="Size.Small"/> Items="@(new[]
<MudText Typo="Typo.subtitle2">@T("Waiting for the configuration plugin...")</MudText> {
</div> new ConfigInfoRowItem(Icons.Material.Filled.ArrowRightAlt,
<div style="display: flex; align-items: center; gap: 8px;"> $"{T("Enterprise configuration ID:")} {env.ConfigurationId}",
<MudIcon Icon="@Icons.Material.Filled.ArrowRightAlt"/> env.ConfigurationId.ToString(),
<span>@T("Enterprise configuration ID:") @env.ConfigurationId</span> T("Copies the config ID to the clipboard")),
<MudCopyClipboardButton TooltipMessage="@T("Copies the config ID to the clipboard")" StringContent=@env.ConfigurationId.ToString()/> new ConfigInfoRowItem(Icons.Material.Filled.ArrowRightAlt,
</div> $"{T("Configuration server:")} {env.ConfigurationServerUrl}",
<div style="display: flex; align-items: center; gap: 8px; margin-top: 4px;"> env.ConfigurationServerUrl,
<MudIcon Icon="@Icons.Material.Filled.ArrowRightAlt"/> T("Copies the server URL to the clipboard"),
<span>@T("Configuration server:") @env.ConfigurationServerUrl</span> "margin-top: 4px;")
<MudCopyClipboardButton TooltipMessage="@T("Copies the server URL to the clipboard")" StringContent=@env.ConfigurationServerUrl/> })"/>
</div>
</MudPaper>
continue; continue;
} }
<MudPaper Outlined="true" Class="pa-3 mt-2 mb-2"> <ConfigPluginInfoCard HeaderIcon="@Icons.Material.Filled.Extension"
<div style="display: flex; align-items: center; gap: 8px; margin-bottom: 8px;"> HeaderText="@matchingPlugin.Name"
<MudIcon Icon="@Icons.Material.Filled.Extension" Size="Size.Small"/> Items="@(new[]
<MudText Typo="Typo.subtitle2">@matchingPlugin.Name</MudText> {
</div> new ConfigInfoRowItem(Icons.Material.Filled.ArrowRightAlt,
<div style="display: flex; align-items: center; gap: 8px;"> $"{T("Enterprise configuration ID:")} {env.ConfigurationId}",
<MudIcon Icon="@Icons.Material.Filled.ArrowRightAlt"/> env.ConfigurationId.ToString(),
<span>@T("Enterprise configuration ID:") @env.ConfigurationId</span> T("Copies the config ID to the clipboard")),
<MudCopyClipboardButton TooltipMessage="@T("Copies the config ID to the clipboard")" StringContent=@env.ConfigurationId.ToString()/> new ConfigInfoRowItem(Icons.Material.Filled.ArrowRightAlt,
</div> $"{T("Configuration server:")} {env.ConfigurationServerUrl}",
<div style="display: flex; align-items: center; gap: 8px; margin-top: 4px;"> env.ConfigurationServerUrl,
<MudIcon Icon="@Icons.Material.Filled.ArrowRightAlt"/> T("Copies the server URL to the clipboard"),
<span>@T("Configuration server:") @env.ConfigurationServerUrl</span> "margin-top: 4px;"),
<MudCopyClipboardButton TooltipMessage="@T("Copies the server URL to the clipboard")" StringContent=@env.ConfigurationServerUrl/> new ConfigInfoRowItem(Icons.Material.Filled.ArrowRightAlt,
</div> $"{T("Configuration plugin ID:")} {matchingPlugin.Id}",
<div style="display: flex; align-items: center; gap: 8px; margin-top: 4px;"> matchingPlugin.Id.ToString(),
<MudIcon Icon="@Icons.Material.Filled.ArrowRightAlt"/> T("Copies the configuration plugin ID to the clipboard"),
<span>@T("Configuration plugin ID:") @matchingPlugin.Id</span> "margin-top: 4px;")
<MudCopyClipboardButton TooltipMessage="@T("Copies the configuration plugin ID to the clipboard")" StringContent=@matchingPlugin.Id.ToString()/> })"
</div> ShowWarning="@this.IsManagedConfigurationIdMismatch(matchingPlugin, env.ConfigurationId)"
@if (this.IsManagedConfigurationIdMismatch(matchingPlugin, env.ConfigurationId)) WarningText="@T("ID mismatch: the plugin ID differs from the enterprise configuration ID.")"/>
{
<div style="display: flex; align-items: center; gap: 8px; margin-top: 4px;">
<MudIcon Icon="@Icons.Material.Filled.Warning" Size="Size.Small" Color="Color.Warning"/>
<MudText Typo="Typo.subtitle2">@T("ID mismatch: the plugin ID differs from the enterprise configuration ID.")</MudText>
</div>
}
</MudPaper>
} }
<MudText Typo="Typo.body1" Class="mt-2 mb-2"> <EncryptionSecretInfo IsConfigured="@(PluginFactory.EnterpriseEncryption?.IsAvailable is true)"
<div style="display: flex; align-items: center; gap: 8px;"> ConfiguredText="@T("Encryption secret: is configured")"
<MudIcon Icon="@Icons.Material.Filled.ArrowRightAlt"/> NotConfiguredText="@T("Encryption secret: is not configured")"/>
@if (PluginFactory.EnterpriseEncryption?.IsAvailable is true)
{
<MudIcon Icon="@Icons.Material.Filled.CheckCircle" Color="Color.Success" Size="Size.Small"/>
<span>@T("Encryption secret: is configured")</span>
}
else
{
<MudIcon Icon="@Icons.Material.Filled.Cancel" Color="Color.Error" Size="Size.Small"/>
<span>@T("Encryption secret: is not configured")</span>
}
</div>
</MudText>
</MudCollapse> </MudCollapse>
break; break;
} }