import { useQuery, useSuspenseQuery } from "@tanstack/react-query"; import { getRepositoryOptions, getSnapshotDetailsOptions, listBackupSchedulesOptions, } from "~/client/api-client/@tanstack/react-query.gen"; import type { GetSnapshotDetailsResponse } from "~/client/api-client/types.gen"; import { Button } from "~/client/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle } from "~/client/components/ui/card"; import { SnapshotFileBrowser } from "~/client/modules/backups/components/snapshot-file-browser"; import { useTimeFormat } from "~/client/lib/datetime"; import { BackupSummaryCard } from "~/client/components/backup-summary-card"; import { useState } from "react"; import { Database } from "lucide-react"; import { Link, useParams } from "@tanstack/react-router"; import { getVolumeMountPath } from "~/client/lib/volume-path"; const SnapshotError = () => { const { repositoryId } = useParams({ from: "/(dashboard)/repositories/$repositoryId/$snapshotId/" }); return (

Snapshot not found

This snapshot does not exist in this repository

It may have been deleted manually outside of Zerobyte.

({ tab: "snapshots" })} params={{ repositoryId }}>
); }; const SnapshotFileBrowserSkeleton = () => (
File Browser

Loading snapshot...

); type Props = { repositoryId: string; snapshotId: string; initialSnapshot?: GetSnapshotDetailsResponse; }; export function SnapshotDetailsPage({ repositoryId, snapshotId, initialSnapshot }: Props) { const [showAllPaths, setShowAllPaths] = useState(false); const { formatDateTime } = useTimeFormat(); const { data: repository } = useSuspenseQuery({ ...getRepositoryOptions({ path: { shortId: repositoryId } }), }); const { data: schedules } = useSuspenseQuery({ ...listBackupSchedulesOptions(), }); const { data, error } = useQuery({ ...getSnapshotDetailsOptions({ path: { shortId: repositoryId, snapshotId: snapshotId } }), initialData: initialSnapshot, }); const backupSchedule = schedules?.find((s) => data?.tags?.includes(s.shortId)); if (error) { return ( <>

{repository.name}

Snapshot: {snapshotId}

); } return (

{repository.name}

Snapshot: {snapshotId}

{data ? ( ) : ( )} {data && ( Snapshot Information
Snapshot ID:

{data.short_id}

Hostname:

{data.hostname}

Time:

{formatDateTime(data.time)}

{backupSchedule && ( <>
Backup Schedule:

{backupSchedule?.name}

Volume:

{backupSchedule?.volume.name}

)}
Paths:
{data.paths.slice(0, showAllPaths ? undefined : 20).map((path) => (

{path}

))} {data.paths.length > 20 && ( )}
)} {data && }
); }