import { Check, ChevronDown, Copy, GitBranch, GitFork, HardDrive, UploadCloud, } from "lucide-react"; import * as React from "react"; import type { ProjectRepoSyncStatus } from "@/shared/api/types"; import { Button } from "@/shared/ui/button"; import { Card } from "@/shared/ui/card"; import { DropdownMenu, DropdownMenuContent, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuTrigger, } from "@/shared/ui/dropdown-menu"; function RepositoryPathRow({ action, path, title, type, }: { action?: React.ReactNode; path: string; title?: string; type: "remote" | "local"; }) { const [copied, setCopied] = React.useState(false); const handleCopy = React.useCallback(() => { void navigator.clipboard.writeText(path).then(() => { setCopied(true); setTimeout(() => setCopied(false), 2_000); }); }, [path]); const Icon = type === "local" ? HardDrive : GitFork; return (
{path}
{action}
); } export function RepositorySourceCard({ branch, branchOptions, cloneUrls, localDisabled, localLabel, localPath, onBranchChange, onPush, onSourceChange, pushDisabled, pushPending, remoteLabel, source, status, }: { branch: string; branchOptions: string[]; cloneUrls: string[]; localDisabled: boolean; localLabel: string; localPath?: string | null; onBranchChange: (branch: string) => void; onPush: () => void; onSourceChange: (source: "remote" | "local") => void; pushDisabled: boolean; pushPending: boolean; remoteLabel: string; source: "remote" | "local"; status: ProjectRepoSyncStatus | null | undefined; }) { if (cloneUrls.length === 0 && !branch) return null; const selectableBranches = branchOptions.length > 0 ? branchOptions : [branch]; const showLocalPath = source === "local" && localPath; const localRefLabel = status?.localShortHead ? `${status.localBranch ?? "local"} @ ${status.localShortHead}` : null; const showPushButton = source === "local" && status?.canPush; const pushAction = showPushButton ? ( ) : null; return (
{branch ? ( {selectableBranches.map((option) => ( {option} ))} ) : ( {branch || "—"} )}
{showLocalPath ? ( ) : cloneUrls.length > 0 ? ( cloneUrls.map((url) => ( )) ) : (
{source === "local" ? "No local checkout found." : "No clone URL published yet."}
)}
); }