fix(ui): schema-library delete-audit name + busy guard + edit-row guard + sanitized create-race test (#260)
This commit is contained in:
@@ -93,10 +93,13 @@
|
||||
<td>@(string.IsNullOrWhiteSpace(s.Scope) ? "—" : s.Scope)</td>
|
||||
<td><code>lib:@s.Name</code></td>
|
||||
<td class="text-end">
|
||||
@* Row actions are disabled while the editor is open so the
|
||||
row under edit (and its siblings) can't be deleted out from
|
||||
under the form, and while a delete is in flight (_busy). *@
|
||||
<button class="btn btn-outline-primary btn-sm me-1"
|
||||
@onclick="() => BeginEdit(s)">Edit</button>
|
||||
@onclick="() => BeginEdit(s)" disabled="@(_editing || _busy)">Edit</button>
|
||||
<button class="btn btn-outline-danger btn-sm"
|
||||
@onclick="() => DeleteSchema(s)">Delete</button>
|
||||
@onclick="() => DeleteSchema(s)" disabled="@(_editing || _busy)">Delete</button>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
@@ -208,21 +211,34 @@
|
||||
|
||||
private async Task DeleteSchema(SharedSchema schema)
|
||||
{
|
||||
// In-flight guard: an editor-open row action is already disabled in the markup,
|
||||
// but the _busy gate is the authoritative guard against a double-invoked delete
|
||||
// (and mirrors the Save path's guard).
|
||||
if (_busy) return;
|
||||
|
||||
var confirmed = await Dialog.ConfirmAsync(
|
||||
"Delete Schema",
|
||||
$"Delete library schema '{schema.Name}'? References to lib:{schema.Name} will no longer resolve.",
|
||||
danger: true);
|
||||
if (!confirmed) return;
|
||||
|
||||
var result = await SchemaLibraryService.DeleteAsync(schema.Id);
|
||||
if (result.Success)
|
||||
_busy = true;
|
||||
try
|
||||
{
|
||||
_toast.ShowSuccess($"Schema '{schema.Name}' deleted.");
|
||||
await LoadAsync();
|
||||
var result = await SchemaLibraryService.DeleteAsync(schema.Id);
|
||||
if (result.Success)
|
||||
{
|
||||
_toast.ShowSuccess($"Schema '{schema.Name}' deleted.");
|
||||
await LoadAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
_toast.ShowError(result.Error ?? "Delete failed.");
|
||||
}
|
||||
}
|
||||
else
|
||||
finally
|
||||
{
|
||||
_toast.ShowError(result.Error ?? "Delete failed.");
|
||||
_busy = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user