import React from 'react'; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; import { Checkbox } from '@/components/ui/checkbox'; import { toast } from '@/components/ui'; import { Icon } from "@/components/icon/Icon"; import { useI18n } from '@/lib/i18n'; interface StashDialogProps { open: boolean; onOpenChange: (open: boolean) => void; operation: 'merge' | 'rebase'; targetBranch: string; onConfirm: (restoreAfter: boolean) => Promise; } export const StashDialog: React.FC = ({ open, onOpenChange, operation, targetBranch, onConfirm, }) => { const { t } = useI18n(); const [restoreAfter, setRestoreAfter] = React.useState(true); const [isProcessing, setIsProcessing] = React.useState(false); const operationLabel = operation === 'merge' ? t('gitView.operation.merge') : t('gitView.operation.rebase'); const handleConfirm = async () => { setIsProcessing(true); try { await onConfirm(restoreAfter); onOpenChange(false); } catch (err) { // Show error to user - parent may also handle it but user should see feedback const message = err instanceof Error ? err.message : `Failed to ${operation}`; toast.error(message); } finally { setIsProcessing(false); } }; const handleCancel = () => { if (!isProcessing) { onOpenChange(false); } }; return (
{t('gitView.stash.title')}
{t('gitView.stash.description', { operation })}

{t('gitView.stash.thisWill')}

  1. {t('gitView.stash.stepStash')}
  2. {operation === 'merge' ? t('gitView.operation.merge') : t('gitView.operation.rebase')}{' '} {operation === 'merge' ? t('gitView.stash.mergeWith') : t('gitView.stash.rebaseOnto')}{' '} {targetBranch}
  3. {restoreAfter &&
  4. {t('gitView.stash.stepRestore')}
  5. }
!isProcessing && setRestoreAfter(!restoreAfter)} > {t('gitView.stash.restoreAfterOperation', { operation })}
); };