mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 08:37:22 +00:00
Refactor ForcePullDialog into a separate component
This commit is contained in:
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>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useState, useCallback } from 'react';
|
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 { Button } from '@/components/ui/button';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { Label } from '@/components/ui/label';
|
import { Label } from '@/components/ui/label';
|
||||||
@@ -9,18 +9,9 @@ import {
|
|||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from '@/components/ui/dropdown-menu';
|
} 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 { ExternalFavicon } from '@/components/ExternalFavicon';
|
||||||
import { SyncStepError } from './SyncStepError';
|
import { SyncStepError } from './SyncStepError';
|
||||||
|
import { ForcePullDialog } from './ForcePullDialog';
|
||||||
import { useGitStatus } from '@/hooks/useGitStatus';
|
import { useGitStatus } from '@/hooks/useGitStatus';
|
||||||
import { useGitSettings } from '@/hooks/useGitSettings';
|
import { useGitSettings } from '@/hooks/useGitSettings';
|
||||||
import { useGit } from '@/hooks/useGit';
|
import { useGit } from '@/hooks/useGit';
|
||||||
@@ -259,8 +250,6 @@ export function SyncStep({ projectId }: StepProps) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!originRemote) {
|
if (!originRemote) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -377,46 +366,11 @@ export function SyncStep({ projectId }: StepProps) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Force Pull Confirmation Dialog */}
|
<ForcePullDialog
|
||||||
<AlertDialog open={showForcePullDialog} onOpenChange={setShowForcePullDialog}>
|
open={showForcePullDialog}
|
||||||
<AlertDialogContent>
|
onOpenChange={setShowForcePullDialog}
|
||||||
<AlertDialogHeader>
|
onConfirm={handleForcePull}
|
||||||
<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>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user