Simplify Pandoc button text binding logic

This commit is contained in:
Thorsten Sommer 2025-05-30 16:51:10 +02:00
parent bfcb012dec
commit 55e2911ad9
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
2 changed files with 18 additions and 20 deletions

View File

@ -28,19 +28,9 @@
<MudButton Variant="Variant.Filled" Color="Color.Info" StartIcon="@Icons.Material.Filled.Update" OnClick="() => this.CheckForUpdate()"> <MudButton Variant="Variant.Filled" Color="Color.Info" StartIcon="@Icons.Material.Filled.Update" OnClick="() => this.CheckForUpdate()">
@T("Check for updates") @T("Check for updates")
</MudButton> </MudButton>
@if (this.pandocInstallation != default && !this.pandocInstallation.IsAvailable)
{
<MudButton Variant="Variant.Filled" Color="Color.Default" StartIcon="@Icons.Material.Filled.Download" OnClick="async () => await this.ShowPandocDialog()"> <MudButton Variant="Variant.Filled" Color="Color.Default" StartIcon="@Icons.Material.Filled.Download" OnClick="async () => await this.ShowPandocDialog()">
@if (string.IsNullOrWhiteSpace(this.pandocInstallation.Version)) @this.PandocButtonText
{
@T("Install Pandoc")
}
else
{
@T("Update Pandoc")
}
</MudButton> </MudButton>
}
</MudStack> </MudStack>
</ExpansionPanel> </ExpansionPanel>

View File

@ -95,15 +95,23 @@ public partial class About : MSGComponentBase
this.StateHasChanged(); this.StateHasChanged();
} }
private string PandocButtonText
{
get
{
return this.pandocInstallation switch
{
{ IsAvailable: true, CheckWasSuccessful: true } => this.T("Check Pandoc Installation"),
{ IsAvailable: false, CheckWasSuccessful: true } => this.T("Update Pandoc"),
_ => this.T("Install Pandoc")
};
}
}
private async Task ShowPandocDialog() private async Task ShowPandocDialog()
{ {
var dialogParameters = new DialogParameters<PandocDialog> await this.DialogService.ShowAsync<PandocDialog>(T("Pandoc Installation"), DialogOptions.FULLSCREEN);
{
{ x => x.ShowInstallationPage, true },
{ x => x.ShowInitialResultInSnackbar, false },
};
await this.DialogService.ShowAsync<PandocDialog>(T("Pandoc Installation"), dialogParameters, DialogOptions.FULLSCREEN);
} }
private async Task CopyStartupLogPath() private async Task CopyStartupLogPath()