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()">
@T("Check for updates")
</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()">
@if (string.IsNullOrWhiteSpace(this.pandocInstallation.Version))
{
@T("Install Pandoc")
}
else
{
@T("Update Pandoc")
}
</MudButton>
}
<MudButton Variant="Variant.Filled" Color="Color.Default" StartIcon="@Icons.Material.Filled.Download" OnClick="async () => await this.ShowPandocDialog()">
@this.PandocButtonText
</MudButton>
</MudStack>
</ExpansionPanel>

View File

@ -95,15 +95,23 @@ public partial class About : MSGComponentBase
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()
{
var dialogParameters = new DialogParameters<PandocDialog>
{
{ x => x.ShowInstallationPage, true },
{ x => x.ShowInitialResultInSnackbar, false },
};
await this.DialogService.ShowAsync<PandocDialog>(T("Pandoc Installation"), dialogParameters, DialogOptions.FULLSCREEN);
await this.DialogService.ShowAsync<PandocDialog>(T("Pandoc Installation"), DialogOptions.FULLSCREEN);
}
private async Task CopyStartupLogPath()