mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-25 13:45:03 +08:00
333c9f277b
Introduce list/restore/delete commands for skill backups created during uninstall. Restore copies files back to SSOT, saves the DB record, and syncs to the current app with rollback on failure. Delete removes the backup directory after a confirmation dialog. ConfirmDialog gains a configurable zIndex prop to support nested dialog stacking.
76 lines
2.0 KiB
TypeScript
76 lines
2.0 KiB
TypeScript
import {
|
|
Dialog,
|
|
DialogContent,
|
|
DialogDescription,
|
|
DialogFooter,
|
|
DialogHeader,
|
|
DialogTitle,
|
|
} from "@/components/ui/dialog";
|
|
import { Button } from "@/components/ui/button";
|
|
import { AlertTriangle, Info } from "lucide-react";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
interface ConfirmDialogProps {
|
|
isOpen: boolean;
|
|
title: string;
|
|
message: string;
|
|
confirmText?: string;
|
|
cancelText?: string;
|
|
variant?: "destructive" | "info";
|
|
zIndex?: "base" | "nested" | "alert" | "top";
|
|
onConfirm: () => void;
|
|
onCancel: () => void;
|
|
}
|
|
|
|
export function ConfirmDialog({
|
|
isOpen,
|
|
title,
|
|
message,
|
|
confirmText,
|
|
cancelText,
|
|
variant = "destructive",
|
|
zIndex = "alert",
|
|
onConfirm,
|
|
onCancel,
|
|
}: ConfirmDialogProps) {
|
|
const { t } = useTranslation();
|
|
|
|
const IconComponent = variant === "info" ? Info : AlertTriangle;
|
|
const iconClass =
|
|
variant === "info" ? "h-5 w-5 text-blue-500" : "h-5 w-5 text-destructive";
|
|
|
|
return (
|
|
<Dialog
|
|
open={isOpen}
|
|
onOpenChange={(open) => {
|
|
if (!open) {
|
|
onCancel();
|
|
}
|
|
}}
|
|
>
|
|
<DialogContent className="max-w-sm" zIndex={zIndex}>
|
|
<DialogHeader className="space-y-3 border-b-0 bg-transparent pb-0">
|
|
<DialogTitle className="flex items-center gap-2 text-lg font-semibold">
|
|
<IconComponent className={iconClass} />
|
|
{title}
|
|
</DialogTitle>
|
|
<DialogDescription className="whitespace-pre-line text-sm leading-relaxed">
|
|
{message}
|
|
</DialogDescription>
|
|
</DialogHeader>
|
|
<DialogFooter className="flex gap-2 border-t-0 bg-transparent pt-2 sm:justify-end">
|
|
<Button variant="outline" onClick={onCancel}>
|
|
{cancelText || t("common.cancel")}
|
|
</Button>
|
|
<Button
|
|
variant={variant === "info" ? "default" : "destructive"}
|
|
onClick={onConfirm}
|
|
>
|
|
{confirmText || t("common.confirm")}
|
|
</Button>
|
|
</DialogFooter>
|
|
</DialogContent>
|
|
</Dialog>
|
|
);
|
|
}
|