Refactor ForcePullDialog into a separate component

This commit is contained in:
Alex Gleason committed 2025-12-24 16:57:56 -06:00
1 parent 2dc22cc40b
commit 5c8d9b3aaa
2 files changed
+70 -53

No files matched your search

@@ -0,0 +1,63 @@
import { AlertTriangle } from 'lucide-react';
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from '@/components/ui/alert-dialog';
interface ForcePullDialogProps {
open: boolean;
onOpenChange: (open: boolean) => void;
onConfirm: () => void;
}
export function ForcePullDialog({ open, onOpenChange, onConfirm }: ForcePullDialogProps) {
const handleConfirm = () => {
onOpenChange(false);
onConfirm();
};
return (
<AlertDialog open={open} onOpenChange={onOpenChange}>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle className="flex items-center gap-2">
<AlertTriangle className="h-5 w-5 text-destructive" />
Force Pull - Discard Local Changes?
</AlertDialogTitle>
<AlertDialogDescription className="space-y-3">
<p>
This will <strong className="text-destructive">permanently discard all local changes</strong> and reset your repository to match the remote.
</p>
<p className="text-sm">
This action cannot be undone. Any uncommitted work will be lost.
</p>
<div className="rounded-md bg-destructive/10 p-3 text-sm border border-destructive/20">
<p className="font-medium text-destructive mb-1">What will happen:</p>
<ul className="list-disc list-inside space-y-1 text-muted-foreground">
<li>All local changes will be discarded</li>
<li>Repository will reset to remote state</li>
<li>Latest changes will be pulled from remote</li>
</ul>
</div>
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction
onClick={handleConfirm}
className="bg-destructive hover:bg-destructive/90"
>
<AlertTriangle className="h-4 w-4" />
Force Pull
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}
+7 -53
View File
@@ -1,5 +1,5 @@
import { useState, useCallback } from 'react';
import { Zap, Copy, Check, RefreshCw, EllipsisVertical, CloudOff, ExternalLink, ChevronDown, ArrowDown, ArrowUp, AlertTriangle } from 'lucide-react';
import { Zap, Copy, Check, RefreshCw, EllipsisVertical, CloudOff, ExternalLink, ChevronDown, ArrowDown, ArrowUp } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
@@ -9,18 +9,9 @@ import {
DropdownMenuItem,
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu';
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from '@/components/ui/alert-dialog';
import { ExternalFavicon } from '@/components/ExternalFavicon';
import { SyncStepError } from './SyncStepError';
import { ForcePullDialog } from './ForcePullDialog';
import { useGitStatus } from '@/hooks/useGitStatus';
import { useGitSettings } from '@/hooks/useGitSettings';
import { useGit } from '@/hooks/useGit';
@@ -259,8 +250,6 @@ export function SyncStep({ projectId }: StepProps) {
}
};
if (!originRemote) {
return null;
}
@@ -377,46 +366,11 @@ export function SyncStep({ projectId }: StepProps) {
</div>
</div>
{/* Force Pull Confirmation Dialog */}
<AlertDialog open={showForcePullDialog} onOpenChange={setShowForcePullDialog}>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle className="flex items-center gap-2">
<AlertTriangle className="h-5 w-5 text-destructive" />
Force Pull - Discard Local Changes?
</AlertDialogTitle>
<AlertDialogDescription className="space-y-3">
<p>
This will <strong className="text-destructive">permanently discard all local changes</strong> and reset your repository to match the remote.
</p>
<p className="text-sm">
This action cannot be undone. Any uncommitted work will be lost.
</p>
<div className="rounded-md bg-destructive/10 p-3 text-sm border border-destructive/20">
<p className="font-medium text-destructive mb-1">What will happen:</p>
<ul className="list-disc list-inside space-y-1 text-muted-foreground">
<li>All local changes will be discarded</li>
<li>Repository will reset to remote state</li>
<li>Latest changes will be pulled from remote</li>
</ul>
</div>
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction
onClick={() => {
setShowForcePullDialog(false);
handleForcePull();
}}
className="bg-destructive hover:bg-destructive/90"
>
<AlertTriangle className="h-4 w-4" />
Force Pull
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
<ForcePullDialog
open={showForcePullDialog}
onOpenChange={setShowForcePullDialog}
onConfirm={handleForcePull}
/>
</div>
);
}