Refactored about page to streamline environment usage and added plugin reload handling

This commit is contained in:
Thorsten Sommer 2025-08-09 21:52:11 +02:00
parent eca0d33da3
commit 6a62a69a07
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
2 changed files with 29 additions and 17 deletions

View File

@ -1,4 +1,5 @@
@attribute [Route(Routes.ABOUT)]
@using AIStudio.Tools.Services
@inherits MSGComponentBase
<div class="inner-scrolling-context">
@ -24,7 +25,7 @@
<MudListItem T="string" Icon="@Icons.Material.Outlined.Memory" Text="@TauriVersion"/>
<MudListItem T="string" Icon="@Icons.Material.Outlined.Translate" Text="@this.OSLanguage"/>
<MudListItem T="string" Icon="@Icons.Material.Outlined.Business">
@switch (this.currentEnvironment.IsActive)
@switch (EnterpriseEnvironmentService.CURRENT_ENVIRONMENT.IsActive)
{
case false when this.configPlug is null:
<MudText Typo="Typo.body1">
@ -55,16 +56,16 @@
<MudText Typo="Typo.body1" Class="mt-2 mb-2">
<div style="display: flex; align-items: center; gap: 8px;">
<MudIcon Icon="@Icons.Material.Filled.ArrowRightAlt"/>
<span>@T("Enterprise configuration ID:") @this.currentEnvironment.ConfigurationId</span>
<MudCopyClipboardButton TooltipMessage="@T("Copies the config ID to the clipboard")" StringContent=@this.currentEnvironment.ConfigurationId.ToString()/>
<span>@T("Enterprise configuration ID:") @EnterpriseEnvironmentService.CURRENT_ENVIRONMENT.ConfigurationId</span>
<MudCopyClipboardButton TooltipMessage="@T("Copies the config ID to the clipboard")" StringContent=@EnterpriseEnvironmentService.CURRENT_ENVIRONMENT.ConfigurationId.ToString()/>
</div>
</MudText>
<MudText Typo="Typo.body1" Class="mt-2 mb-2">
<div style="display: flex; align-items: center; gap: 8px;">
<MudIcon Icon="@Icons.Material.Filled.ArrowRightAlt"/>
<span>@T("Configuration server:") @this.currentEnvironment.ConfigurationServerUrl</span>
<MudCopyClipboardButton TooltipMessage="@T("Copies the server URL to the clipboard")" StringContent=@this.currentEnvironment.ConfigurationServerUrl/>
<span>@T("Configuration server:") @EnterpriseEnvironmentService.CURRENT_ENVIRONMENT.ConfigurationServerUrl</span>
<MudCopyClipboardButton TooltipMessage="@T("Copies the server URL to the clipboard")" StringContent=@EnterpriseEnvironmentService.CURRENT_ENVIRONMENT.ConfigurationServerUrl/>
</div>
</MudText>
</MudCollapse>
@ -78,16 +79,16 @@
<MudText Typo="Typo.body1" Class="mt-2 mb-2 ml-4">
<div style="display: flex; align-items: center; gap: 8px;">
<MudIcon Icon="@Icons.Material.Filled.ArrowRightAlt"/>
<span>@T("Enterprise configuration ID:") @this.currentEnvironment.ConfigurationId</span>
<MudCopyClipboardButton TooltipMessage="@T("Copies the config ID to the clipboard")" StringContent=@this.currentEnvironment.ConfigurationId.ToString()/>
<span>@T("Enterprise configuration ID:") @EnterpriseEnvironmentService.CURRENT_ENVIRONMENT.ConfigurationId</span>
<MudCopyClipboardButton TooltipMessage="@T("Copies the config ID to the clipboard")" StringContent=@EnterpriseEnvironmentService.CURRENT_ENVIRONMENT.ConfigurationId.ToString()/>
</div>
</MudText>
<MudText Typo="Typo.body1" Class="mt-2 mb-2 ml-4">
<div style="display: flex; align-items: center; gap: 8px;">
<MudIcon Icon="@Icons.Material.Filled.ArrowRightAlt"/>
<span>@T("Configuration server:") @this.currentEnvironment.ConfigurationServerUrl</span>
<MudCopyClipboardButton TooltipMessage="@T("Copies the server URL to the clipboard")" StringContent=@this.currentEnvironment.ConfigurationServerUrl/>
<span>@T("Configuration server:") @EnterpriseEnvironmentService.CURRENT_ENVIRONMENT.ConfigurationServerUrl</span>
<MudCopyClipboardButton TooltipMessage="@T("Copies the server URL to the clipboard")" StringContent=@EnterpriseEnvironmentService.CURRENT_ENVIRONMENT.ConfigurationServerUrl/>
</div>
</MudText>

View File

@ -58,12 +58,10 @@ public partial class About : MSGComponentBase
private GetLogPathsResponse logPaths;
private bool showEnterpriseConfigDetails = false;
private bool showEnterpriseConfigDetails;
private IPluginMetadata? configPlug = PluginFactory.AvailablePlugins.FirstOrDefault(x => x.Type is PluginType.CONFIGURATION);
private EnterpriseEnvironment currentEnvironment = EnterpriseEnvironmentService.CURRENT_ENVIRONMENT;
/// <summary>
/// Determines whether the enterprise configuration has details that can be shown/hidden.
/// Returns true if there are details available, false otherwise.
@ -72,7 +70,7 @@ public partial class About : MSGComponentBase
{
get
{
return this.currentEnvironment.IsActive switch
return EnterpriseEnvironmentService.CURRENT_ENVIRONMENT.IsActive switch
{
// Case 1: No enterprise config and no plugin - no details available
false when this.configPlug is null => false,
@ -105,6 +103,23 @@ public partial class About : MSGComponentBase
#endregion
#region Overrides of MSGComponentBase
protected override async Task ProcessIncomingMessage<T>(ComponentBase? sendingComponent, Event triggeredEvent, T? data) where T : default
{
switch (triggeredEvent)
{
case Event.PLUGINS_RELOADED:
this.configPlug = PluginFactory.AvailablePlugins.FirstOrDefault(x => x.Type is PluginType.CONFIGURATION);
await this.InvokeAsync(this.StateHasChanged);
break;
}
await base.ProcessIncomingMessage(sendingComponent, triggeredEvent, data);
}
#endregion
private async Task DeterminePandocVersion()
{
this.pandocInstallation = await Pandoc.CheckAvailabilityAsync(this.RustService, false);
@ -153,10 +168,6 @@ public partial class About : MSGComponentBase
private void ToggleEnterpriseConfigDetails()
{
// can configPlug and currentEnvironment change?
this.configPlug = PluginFactory.AvailablePlugins.FirstOrDefault(x => x.Type is PluginType.CONFIGURATION);
this.currentEnvironment = EnterpriseEnvironmentService.CURRENT_ENVIRONMENT;
this.showEnterpriseConfigDetails = !this.showEnterpriseConfigDetails;
}