Files
sencho/frontend/src/components/EditorLayout/UnsavedChangesDialog.tsx
T
Anso b3382d07a1 refactor(frontend): extract dialog cluster from EditorLayout (#898)
Extract the two remaining inline ConfirmModal blocks at the bottom of
EditorLayout into their own modules under components/EditorLayout/,
matching the pattern established by CreateStackDialog (B4-2):

- DeleteStackDialog: takes open/onOpenChange/stackName/onConfirm; owns
  the prune-volumes checkbox state internally and resets it on close.
  EditorLayout's deleteStack handler now accepts pruneVolumes as a
  parameter instead of reading parent state.
- UnsavedChangesDialog: takes open/onCancel/onConfirm. The discard
  body is hoisted to a named handler in EditorLayout
  (discardAndLoadPending) so the dialog stays a thin presentational
  wrapper.

Also removes a dead label-bulk-action surface that had no live entry
point: bulkActionLabel and bulkAction were declared without setters,
and setBulkActionOpen(true) was never called from anywhere. The
multi-select bulk-stack-actions live elsewhere via useBulkStackActions
and SidebarBulkBar; this removed code was unrelated and unreachable.
Drops the BulkActionResult interface, four useState lines, the
bulkAffected useMemo, the runLabelBulkAction handler, and the inline
ConfirmModal.

EditorLayout.tsx: 2,852 -> 2,747 LOC (-105). useState count: 66 -> 61.
2026-05-03 14:56:55 -04:00

26 lines
838 B
TypeScript

import { ConfirmModal } from '../ui/modal';
export interface UnsavedChangesDialogProps {
open: boolean;
onCancel: () => void;
onConfirm: () => void;
}
export function UnsavedChangesDialog({ open, onCancel, onConfirm }: UnsavedChangesDialogProps) {
return (
<ConfirmModal
open={open}
onOpenChange={(next) => { if (!next) onCancel(); }}
kicker="EDITOR · UNSAVED CHANGES"
title="Discard unsaved changes?"
description="You have unsaved changes. Switching stacks will discard them."
confirmLabel="Discard changes"
onConfirm={onConfirm}
>
<p className="text-sm text-muted-foreground">
You have unsaved changes. Switching stacks will discard them.
</p>
</ConfirmModal>
);
}