import { RotateCcw, Trash2 } from "lucide-react"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "~/client/components/ui/card"; import { Button, buttonVariants } from "~/client/components/ui/button"; import type { Snapshot } from "~/client/lib/types"; import { useTimeFormat } from "~/client/lib/datetime"; import { cn } from "~/client/lib/utils"; import { Link } from "@tanstack/react-router"; import { SnapshotTreeBrowser } from "~/client/components/file-browsers/snapshot-tree-browser"; import { findCommonAncestor } from "@zerobyte/core/utils"; interface Props { snapshot: Snapshot; repositoryId: string; backupId?: string; displayBasePath?: string; onDeleteSnapshot?: (snapshotId: string) => void; isDeletingSnapshot?: boolean; } const treeProps = { pageSize: 500, className: "flex flex-1 min-h-0 flex-col", treeContainerClassName: "overflow-auto flex-1 min-h-0 border border-border rounded-md bg-card m-4", treeClassName: "px-2 py-2", emptyMessage: "No files in this snapshot", stateClassName: "flex-1 min-h-0", } as const; export const SnapshotFileBrowser = (props: Props) => { const { snapshot, repositoryId, backupId, displayBasePath, onDeleteSnapshot, isDeletingSnapshot } = props; const { formatDateTime } = useTimeFormat(); const hasNonPosixSnapshotPaths = snapshot.paths.some((path) => !path.startsWith("/")); const queryBasePath = hasNonPosixSnapshotPaths ? "/" : findCommonAncestor(snapshot.paths); return (