File size: 1,763 Bytes
f59fbe2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from "@/components/ui/alert-dialog";
interface StreamingConfirmDialogProps {
open: boolean;
onOpenChange: (open: boolean) => void;
title: string;
description?: string;
confirmLabel?: string;
cancelLabel?: string;
onConfirm: () => void;
confirmDisabled?: boolean;
cancelDisabled?: boolean;
confirmLoading?: boolean;
}
export function StreamingConfirmDialog({
open,
onOpenChange,
title,
description = "The current conversation is still generating a response. This action will truncate the output. Are you sure you want to continue?",
confirmLabel = "Continue",
cancelLabel = "Cancel",
onConfirm,
confirmDisabled = false,
cancelDisabled = false,
confirmLoading = false,
}: StreamingConfirmDialogProps) {
return (
<AlertDialog open={open} onOpenChange={onOpenChange}>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>{title}</AlertDialogTitle>
<AlertDialogDescription>{description}</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel onClick={() => onOpenChange(false)} disabled={cancelDisabled}>
{cancelLabel}
</AlertDialogCancel>
<AlertDialogAction
onClick={onConfirm}
disabled={confirmDisabled}
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
>
{confirmLoading ? `${confirmLabel}…` : confirmLabel}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}
|