fix(files): report success cancellation and errors with safe next actions (U02)
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
@inject IFileSaveService FileSaveService
|
||||
|
||||
@if (Result != null)
|
||||
{
|
||||
<div class="alert @(Result.Status == FileOperationStatus.Error ? "alert-danger" : Result.Status == FileOperationStatus.Success ? "alert-success" : "alert-info")" role="status" aria-live="polite" aria-atomic="true">
|
||||
<p>@Result.Message</p>
|
||||
@if (Result.Path != null)
|
||||
{
|
||||
<p class="text-break">@Result.Path</p>
|
||||
<button class="btn btn-outline-secondary" disabled="@busy" @onclick="OpenFolder">Ordner öffnen</button>
|
||||
}
|
||||
@if (Result.Details != null)
|
||||
{
|
||||
<details><summary>Technische Details</summary><p class="text-break">@Result.Details</p></details>
|
||||
}
|
||||
@if (openResult != null)
|
||||
{
|
||||
<p role="alert">@openResult.Message</p>
|
||||
@if (openResult.Details != null) { <details><summary>Technische Details</summary>@openResult.Details</details> }
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@code {
|
||||
[Parameter] public FileOperationResult? Result { get; set; }
|
||||
private FileOperationResult? openResult;
|
||||
private FileOperationResult? previous;
|
||||
private bool busy;
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
if (previous != Result) { openResult = null; previous = Result; }
|
||||
}
|
||||
private async Task OpenFolder()
|
||||
{
|
||||
if (busy || Result?.Path == null) return;
|
||||
busy = true;
|
||||
try { openResult = await FileSaveService.OpenFolderAsync(Result.Path); }
|
||||
finally { busy = false; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user