* refactor: move to tanstack start * refactor: auth flow & volumes * refactor: repo & snapshot details * refactor: backups, create repo, volumes * refactor: create volume & restore snapshot * refactor: notifications * refactor: settings * refactor: breadcrumbs * fix: ts issues * refactor: prod deployment * fix: import css production * refactor: nitro build * refactor: winston -> consola * fix: memory leak is sse events cleanup * fix: cli usage * chore: remove rr routes file * refactor: pr feedbacks * refactor: patch api client to have a global client per call * refactor: pr feedbacks * fix(dockerfile): add explicit port * fix(e2e): healthcheck under /api
55 lines
1.8 KiB
TypeScript
55 lines
1.8 KiB
TypeScript
import { createFileRoute } from "@tanstack/react-router";
|
|
import { getBackupSchedule } from "~/client/api-client";
|
|
import { getRepositoryOptions, getSnapshotDetailsOptions } from "~/client/api-client/@tanstack/react-query.gen";
|
|
import { RestoreSnapshotPage } from "~/client/modules/repositories/routes/restore-snapshot";
|
|
|
|
export const Route = createFileRoute("/(dashboard)/backups/$backupId/$snapshotId/restore")({
|
|
component: RouteComponent,
|
|
loader: async ({ params, context }) => {
|
|
const schedule = await getBackupSchedule({ path: { scheduleId: params.backupId } });
|
|
|
|
if (!schedule.data) {
|
|
throw new Response("Not Found", { status: 404 });
|
|
}
|
|
|
|
const [snapshot, repository] = await Promise.all([
|
|
context.queryClient.ensureQueryData({
|
|
...getSnapshotDetailsOptions({ path: { id: schedule.data?.repositoryId, snapshotId: params.snapshotId } }),
|
|
}),
|
|
context.queryClient.ensureQueryData({ ...getRepositoryOptions({ path: { id: schedule.data?.repositoryId } }) }),
|
|
]);
|
|
|
|
return { snapshot, repository, schedule: schedule.data };
|
|
},
|
|
head: ({ params }) => ({
|
|
meta: [
|
|
{ title: `Zerobyte - Restore Snapshot ${params.snapshotId}` },
|
|
{
|
|
name: "description",
|
|
content: "Restore files from a backup snapshot.",
|
|
},
|
|
],
|
|
}),
|
|
staticData: {
|
|
breadcrumb: (match) => [
|
|
{ label: "Backup Jobs", href: "/backups" },
|
|
{ label: match.loaderData?.schedule?.name || "Job", href: `/backups/${match.params.backupId}` },
|
|
{ label: match.params.snapshotId },
|
|
{ label: "Restore" },
|
|
],
|
|
},
|
|
});
|
|
|
|
function RouteComponent() {
|
|
const { backupId, snapshotId } = Route.useParams();
|
|
const { snapshot, repository } = Route.useLoaderData();
|
|
|
|
return (
|
|
<RestoreSnapshotPage
|
|
returnPath={`/backups/${backupId}`}
|
|
snapshotId={snapshotId}
|
|
snapshot={snapshot}
|
|
repository={repository}
|
|
/>
|
|
);
|
|
}
|