mirror of
https://github.com/Noooste/garage-ui.git
synced 2026-08-19 09:16:16 +00:00
bfed48421b
Signed-off-by: Noooste <83548733+Noooste@users.noreply.github.com>
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import { Trash2 } from 'lucide-react';
|
|
import { Button } from '@/components/ui/button';
|
|
import {
|
|
Dialog,
|
|
DialogContent,
|
|
DialogDescription,
|
|
DialogFooter,
|
|
DialogHeader,
|
|
DialogTitle,
|
|
} from '@/components/ui/dialog';
|
|
import { IconTile } from '@/components/ui/icon-tile';
|
|
import type { S3Object } from '@/types';
|
|
|
|
interface DeleteObjectDialogProps {
|
|
open: boolean;
|
|
onOpenChange: (open: boolean) => void;
|
|
object: S3Object | null;
|
|
onDeleteObject: (key: string) => Promise<boolean>;
|
|
}
|
|
|
|
export function DeleteObjectDialog({ open, onOpenChange, object, onDeleteObject }: DeleteObjectDialogProps) {
|
|
const handleDelete = async () => {
|
|
if (!object) return;
|
|
|
|
const success = await onDeleteObject(object.key);
|
|
if (success) {
|
|
onOpenChange(false);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<Dialog open={open} onOpenChange={onOpenChange} size="destructive">
|
|
<DialogContent>
|
|
<DialogHeader>
|
|
<IconTile icon={<Trash2 />} tone="destructive" size="md" />
|
|
<div className="flex-1">
|
|
<DialogTitle>Delete Object</DialogTitle>
|
|
<DialogDescription>
|
|
Are you sure you want to delete "{object?.key}"? This action cannot be undone.
|
|
</DialogDescription>
|
|
</div>
|
|
</DialogHeader>
|
|
<DialogFooter>
|
|
<Button variant="secondary" onClick={() => onOpenChange(false)}>
|
|
Cancel
|
|
</Button>
|
|
<Button variant="destructive" onClick={handleDelete}>
|
|
Delete
|
|
</Button>
|
|
</DialogFooter>
|
|
</DialogContent>
|
|
</Dialog>
|
|
);
|
|
}
|