"use client"; import { useState, type RefObject } from "react"; import { IconGitCommit, IconLoader2, IconCheck } from "@tabler/icons-react"; import { Button } from "@kandev/ui/button"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter, DialogClose, } from "@kandev/ui/dialog"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "@kandev/ui/alert-dialog"; import { Label } from "@kandev/ui/label"; import { Input } from "@kandev/ui/input"; import { Textarea } from "@kandev/ui/textarea"; import { RadioGroup, RadioGroupItem } from "@kandev/ui/radio-group"; import { Trans, useTranslation } from "react-i18next"; import { ActionConfirmPopover } from "@/components/confirmation/action-confirm-popover"; // --- Discard Confirmation Dialog --- type DiscardDialogProps = { open: boolean; onOpenChange: (open: boolean) => void; fileToDiscard: string | null; filesToDiscard: string[] | null; anchorRef: RefObject; onConfirm: () => void; }; function DiscardFileDescription({ file }: { file: string | null }) { return ( This will permanently discard all changes to{" "} {file}. This action cannot be undone. ); } export function DiscardDialog({ open, onOpenChange, fileToDiscard, filesToDiscard, anchorRef, onConfirm, }: DiscardDialogProps) { const { t } = useTranslation(); const bulkCount = filesToDiscard?.length ?? 0; const isBulk = bulkCount > 1; const displayFile = fileToDiscard ?? (filesToDiscard?.length === 1 ? filesToDiscard[0] : null); const description = isBulk ? t("task:discardAllChangesToFiles", { count: bulkCount }) : null; const title = t("task:discardChanges"); const cancelLabel = t("common:cancel"); const confirmLabel = t("task:discard"); if (!isBulk) { return ( } cancelLabel={cancelLabel} confirmLabel={confirmLabel} confirmTestId="discard-local-changes-confirm" testId="discard-local-changes-confirm-popover" onOpenChange={onOpenChange} onCancel={() => onOpenChange(false)} onConfirm={onConfirm} /> ); } return ( {title} {description ?? } {cancelLabel} {confirmLabel} ); } // --- Amend Commit Message Dialog --- type AmendDialogProps = { open: boolean; onOpenChange: (open: boolean) => void; amendMessage: string; onAmendMessageChange: (value: string) => void; onAmend: () => void; isLoading: boolean; }; export function AmendDialog({ open, onOpenChange, amendMessage, onAmendMessageChange, onAmend, isLoading, }: AmendDialogProps) { const { t } = useTranslation(); return ( {t("task:amendCommitMessage")}

{t("task:editTheMessageForTheMost")}