import { useQuery, useSuspenseQuery } from "@tanstack/react-query";
import {
getRepositoryOptions,
getSnapshotDetailsOptions,
listBackupSchedulesOptions,
} from "~/client/api-client/@tanstack/react-query.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 { formatDateTime } 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";
export const SnapshotError = () => {
const { repoId } = useParams({ from: "/(dashboard)/repositories/$repoId/$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: repoId }}
>
);
};
const FilebrowserFallback = ({ repositoryId, snapshotId }: { repositoryId: string; snapshotId: string }) => {
return (
);
};
export function SnapshotDetailsPage({ repositoryId, snapshotId }: { repositoryId: string; snapshotId: string }) {
const [showAllPaths, setShowAllPaths] = useState(false);
const { data: repository } = useSuspenseQuery({
...getRepositoryOptions({ path: { id: repositoryId } }),
});
const { data: schedules } = useSuspenseQuery({
...listBackupSchedulesOptions(),
});
const { data, error } = useQuery({
...getSnapshotDetailsOptions({ path: { id: repositoryId, snapshotId: snapshotId } }),
});
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 &&
}
);
}