Dashboard: confirm before Close session / Kill worker
Add a shared ConfirmDialog component and route Sessions, Workers, and SessionDetails Close/Kill buttons through it. The dialog shows the target session id and a color-matched confirm button (yellow Close, red Kill); Cancel dismisses without invoking the admin service. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -25,6 +25,18 @@ else
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (CanManage)
|
||||
{
|
||||
<ConfirmDialog IsOpen="@(PendingSessionId is not null)"
|
||||
Title="Kill worker?"
|
||||
Message="@($"Forcefully kill the worker for session {PendingSessionId}? This skips graceful shutdown.")"
|
||||
ConfirmLabel="Kill"
|
||||
ConfirmButtonClass="btn-danger"
|
||||
IsBusy="IsBusy"
|
||||
OnConfirm="ConfirmKillAsync"
|
||||
OnCancel="CancelPending" />
|
||||
}
|
||||
|
||||
<section class="dashboard-section">
|
||||
@if (Snapshot.Workers.Count == 0)
|
||||
{
|
||||
@@ -61,7 +73,7 @@ else
|
||||
<td>
|
||||
<button type="button" class="btn btn-sm btn-outline-danger"
|
||||
disabled="@IsBusy"
|
||||
@onclick="() => KillWorkerAsync(worker.SessionId)">
|
||||
@onclick="() => RequestKill(worker.SessionId)">
|
||||
Kill
|
||||
</button>
|
||||
</td>
|
||||
@@ -93,13 +105,34 @@ else
|
||||
CanManage = SessionAdminService.CanManage(authenticationState.User);
|
||||
}
|
||||
|
||||
private async Task KillWorkerAsync(string sessionId)
|
||||
private string? PendingSessionId { get; set; }
|
||||
|
||||
private void RequestKill(string sessionId)
|
||||
{
|
||||
if (IsBusy)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
PendingSessionId = sessionId;
|
||||
}
|
||||
|
||||
private void CancelPending()
|
||||
{
|
||||
if (!IsBusy)
|
||||
{
|
||||
PendingSessionId = null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ConfirmKillAsync()
|
||||
{
|
||||
if (IsBusy || PendingSessionId is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string sessionId = PendingSessionId;
|
||||
IsBusy = true;
|
||||
try
|
||||
{
|
||||
@@ -115,6 +148,7 @@ else
|
||||
finally
|
||||
{
|
||||
IsBusy = false;
|
||||
PendingSessionId = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user