Allow to disable the component

This commit is contained in:
Thorsten Sommer 2026-02-01 14:13:30 +01:00
parent f668388192
commit 3b2770dd5c
Signed by untrusted user who does not match committer: tsommer
GPG Key ID: 371BBA77A02C0108
2 changed files with 9 additions and 3 deletions

View File

@ -1,5 +1,5 @@
@inherits MSGComponentBase @inherits MSGComponentBase
<MudButton StartIcon="@Icons.Material.Filled.Description" OnClick="async () => await this.SelectFile()" Variant="Variant.Filled" Class="mb-3"> <MudButton StartIcon="@Icons.Material.Filled.Description" OnClick="@(async () => await this.SelectFile())" Variant="Variant.Filled" Class="mb-3" Disabled="@this.Disabled">
@if (string.IsNullOrWhiteSpace(this.Text)) @if (string.IsNullOrWhiteSpace(this.Text))
{ {
@T("Use file content as input") @T("Use file content as input")
@ -8,4 +8,4 @@
{ {
@this.Text @this.Text
} }
</MudButton> </MudButton>

View File

@ -15,6 +15,9 @@ public partial class ReadFileContent : MSGComponentBase
[Parameter] [Parameter]
public EventCallback<string> FileContentChanged { get; set; } public EventCallback<string> FileContentChanged { get; set; }
[Parameter]
public bool Disabled { get; set; }
[Inject] [Inject]
private RustService RustService { get; init; } = null!; private RustService RustService { get; init; } = null!;
@ -30,6 +33,9 @@ public partial class ReadFileContent : MSGComponentBase
private async Task SelectFile() private async Task SelectFile()
{ {
if (this.Disabled)
return;
// Ensure that Pandoc is installed and ready: // Ensure that Pandoc is installed and ready:
var pandocState = await this.PandocAvailabilityService.EnsureAvailabilityAsync( var pandocState = await this.PandocAvailabilityService.EnsureAvailabilityAsync(
showSuccessMessage: false, showSuccessMessage: false,
@ -73,4 +79,4 @@ public partial class ReadFileContent : MSGComponentBase
await MessageBus.INSTANCE.SendError(new(Icons.Material.Filled.Error, T("Failed to load file content"))); await MessageBus.INSTANCE.SendError(new(Icons.Material.Filled.Error, T("Failed to load file content")));
} }
} }
} }