Files
manage/frontend/src/components/ConfirmDialog.tsx
T
Developer 109e74db41 feat(frontend): slice 2 — migrate 11 shared components to shadcn/Tailwind
Web UI rework. Shared-components slice (drift prevention):
- Migrate SectionCard, SelectionRailCard, TabbedCard, MetricCard,
  DiskSpaceCard, HoverEditButton, DialogFooter, ConfirmDialog,
  LibraryOverview, NowPlaying, SessionActivityPanel off @mui
- HoverEditButton: MUI IconButton + EditOutlined -> Button + lucide Pencil
- Status mapping uses the success Badge variant (chart-2) for healthy
- Exported APIs preserved so consuming pages still compile (no page edits)
- 11 behavioral Vitest component tests added

Gate: build + lint + test green.
2026-06-17 12:33:47 +00:00

56 lines
1.1 KiB
TypeScript

import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
import { DialogFooter } from "./DialogFooter";
/**
* Reusable confirmation dialog built on the shadcn Dialog family and the
* shared `DialogFooter`. Same exported props as the MUI version; Esc / overlay
* click routes to `onCancel` via `onOpenChange`.
*/
export function ConfirmDialog({
open,
title,
message,
confirmLabel = "Delete",
onCancel,
onConfirm,
busy,
}: {
open: boolean;
title: string;
message: string;
confirmLabel?: string;
onCancel: () => void;
onConfirm: () => void;
busy?: boolean;
}) {
return (
<Dialog
open={open}
onOpenChange={(next) => {
if (!next) onCancel();
}}
>
<DialogContent showCloseButton={false}>
<DialogHeader>
<DialogTitle>{title}</DialogTitle>
<DialogDescription>{message}</DialogDescription>
</DialogHeader>
<DialogFooter
onCancel={onCancel}
onConfirm={onConfirm}
confirmLabel={confirmLabel}
confirmColor="error"
confirmBusyLabel={confirmLabel}
confirmDisabled={busy}
/>
</DialogContent>
</Dialog>
);
}