import { Calendar, Clock, Database, FolderTree, HardDrive } from "lucide-react"; import { useNavigate } from "react-router"; import type { ListSnapshotsResponse } from "~/api-client/types.gen"; import { ByteSize } from "~/components/bytes-size"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "~/components/ui/table"; import { Tooltip, TooltipContent, TooltipTrigger } from "~/components/ui/tooltip"; import { formatSnapshotDuration } from "~/modules/repositories/tabs/snapshots"; type Snapshot = ListSnapshotsResponse[number]; type Props = { snapshots: Snapshot[]; repositoryName: string; }; export const SnapshotsTable = ({ snapshots, repositoryName }: Props) => { const navigate = useNavigate(); const handleRowClick = (snapshotId: string) => { navigate(`/repositories/${repositoryName}/${snapshotId}`); }; return (
Snapshot ID Date & Time Size Duration Volume {snapshots.map((snapshot) => ( handleRowClick(snapshot.short_id)} >
{snapshot.short_id}
{new Date(snapshot.time).toLocaleString()}
{formatSnapshotDuration(snapshot.duration / 1000)}
{snapshot.paths[0].split("/").filter(Boolean).at(-2) || "/"} +{snapshot.paths.length - 1}
{snapshot.paths.slice(1).map((path) => (
{path}
))}
))}
); };