import { RotateCcw, Trash2 } from "lucide-react"; import { useQuery } from "@tanstack/react-query"; 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 { formatDateTime } 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 { getBackupScheduleOptions } from "~/client/api-client/@tanstack/react-query.gen"; import { getVolumeMountPath } from "~/client/lib/volume-path"; interface Props { snapshot: Snapshot; repositoryId: string; backupId?: string; basePath?: 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; interface ScheduleAwareTreeBrowserProps { scheduleShortId: string; repositoryId: string; snapshotId: string; } const ScheduleAwareTreeBrowser = ({ scheduleShortId, repositoryId, snapshotId }: ScheduleAwareTreeBrowserProps) => { const { data: schedule, isPending } = useQuery({ ...getBackupScheduleOptions({ path: { shortId: scheduleShortId } }), retry: false, }); if (isPending) { return ; } return ( ); }; const TreeBrowserFallback = () => (

Loading volume info...

); export const SnapshotFileBrowser = (props: Props) => { const { snapshot, repositoryId, backupId, basePath, onDeleteSnapshot, isDeletingSnapshot } = props; const scheduleShortId = !basePath ? backupId || snapshot.tags?.[0] : undefined; return (
File Browser {`Viewing snapshot from ${formatDateTime(snapshot?.time)}`}
Restore {onDeleteSnapshot && ( )}
{basePath ? ( ) : scheduleShortId ? ( ) : ( )}
); };