diff --git a/frontend/src/routes/dashboard/capsules/+page.svelte b/frontend/src/routes/dashboard/capsules/+page.svelte index e8785ff..b2e2957 100644 --- a/frontend/src/routes/dashboard/capsules/+page.svelte +++ b/frontend/src/routes/dashboard/capsules/+page.svelte @@ -53,6 +53,12 @@ let creating = $state(false); let createError = $state(null); + // Snapshot dialog state + let snapshotTarget = $state<{ capsule: Capsule; pauseFirst: boolean } | null>(null); + let snapshotName = $state(''); + let snapshotting = $state(false); + let snapshotError = $state(null); + // Destroy confirmation state let destroyTarget = $state(null); let destroying = $state(false); @@ -172,30 +178,32 @@ actionLoading = null; } - async function handleSnapshot(id: string) { + function handleSnapshot(capsule: Capsule) { openMenuId = null; - actionLoading = id; - const result = await createSnapshot(id); - if (result.ok) { - // Snapshot may have paused the capsule — refresh to get updated status - await fetchCapsules(); - } else { - toast.error(result.error); - } - actionLoading = null; + snapshotName = ''; + snapshotError = null; + snapshotTarget = { capsule, pauseFirst: false }; } - async function handlePauseAndSnapshot(id: string) { + function handlePauseAndSnapshot(capsule: Capsule) { openMenuId = null; - actionLoading = id; - // Snapshot endpoint pauses automatically if running - const result = await createSnapshot(id); + snapshotName = ''; + snapshotError = null; + snapshotTarget = { capsule, pauseFirst: true }; + } + + async function handleSnapshotConfirm() { + if (!snapshotTarget) return; + snapshotting = true; + snapshotError = null; + const result = await createSnapshot(snapshotTarget.capsule.id, snapshotName.trim() || undefined); if (result.ok) { + snapshotTarget = null; await fetchCapsules(); } else { - toast.error(result.error); + snapshotError = result.error; } - actionLoading = null; + snapshotting = false; } async function handleDestroy() { @@ -640,7 +648,7 @@ Pause + + + + + +{/if} + {#if showCreateDialog}