@@ -80,7 +79,7 @@ export const SnapshotFileBrowser = (props: Props) => {
diff --git a/app/client/modules/repositories/routes/restore-snapshot.tsx b/app/client/modules/repositories/routes/restore-snapshot.tsx
index 4f2ec36f5..84f99e3ed 100644
--- a/app/client/modules/repositories/routes/restore-snapshot.tsx
+++ b/app/client/modules/repositories/routes/restore-snapshot.tsx
@@ -1,26 +1,26 @@
import { RestoreForm } from "~/client/components/restore-form";
import type { Repository } from "~/client/lib/types";
+type SnapshotRestorePlan = { queryBasePath: string; requiresCustomTarget: boolean };
+
type Props = {
repository: Repository;
snapshotId: string;
returnPath: string;
- queryBasePath?: string;
+ snapshotSourcePathPlan: SnapshotRestorePlan;
displayBasePath?: string;
- hasNonPosixSnapshotPaths?: boolean;
};
export function RestoreSnapshotPage(props: Props) {
- const { returnPath, snapshotId, repository, queryBasePath, displayBasePath, hasNonPosixSnapshotPaths } = props;
+ const { returnPath, snapshotId, repository, snapshotSourcePathPlan, displayBasePath } = props;
return (
);
}
diff --git a/app/routes/(dashboard)/backups/$backupId/$snapshotId.restore.tsx b/app/routes/(dashboard)/backups/$backupId/$snapshotId.restore.tsx
index 26d1f0c55..35b283f62 100644
--- a/app/routes/(dashboard)/backups/$backupId/$snapshotId.restore.tsx
+++ b/app/routes/(dashboard)/backups/$backupId/$snapshotId.restore.tsx
@@ -1,9 +1,12 @@
import { createFileRoute } from "@tanstack/react-router";
import { getBackupSchedule } from "~/client/api-client";
-import { getRepositoryOptions, getSnapshotDetailsOptions } from "~/client/api-client/@tanstack/react-query.gen";
+import {
+ getRepositoryOptions,
+ getSnapshotDetailsOptions,
+ getSnapshotRestorePlanOptions,
+} from "~/client/api-client/@tanstack/react-query.gen";
import { RestoreSnapshotPage } from "~/client/modules/repositories/routes/restore-snapshot";
import { getVolumeMountPath } from "~/client/lib/volume-path";
-import { findCommonAncestor } from "@zerobyte/core/utils";
export const Route = createFileRoute("/(dashboard)/backups/$backupId/$snapshotId/restore")({
component: RouteComponent,
@@ -15,7 +18,7 @@ export const Route = createFileRoute("/(dashboard)/backups/$backupId/$snapshotId
throw new Response("Not Found", { status: 404 });
}
- const [snapshot, repository] = await Promise.all([
+ const [snapshot, repository, restorePlan] = await Promise.all([
context.queryClient.ensureQueryData({
...getSnapshotDetailsOptions({
path: { shortId: schedule.data.repository.shortId, snapshotId: params.snapshotId },
@@ -24,17 +27,21 @@ export const Route = createFileRoute("/(dashboard)/backups/$backupId/$snapshotId
context.queryClient.ensureQueryData({
...getRepositoryOptions({ path: { shortId: schedule.data.repository.shortId } }),
}),
+ context.queryClient.ensureQueryData({
+ ...getSnapshotRestorePlanOptions({
+ path: { shortId: schedule.data.repository.shortId, snapshotId: params.snapshotId },
+ }),
+ }),
]);
- const hasNonPosixSnapshotPaths = snapshot.paths.some((path) => !path.startsWith("/"));
+ const displayBasePath = getVolumeMountPath(schedule.data.volume);
return {
snapshot,
repository,
schedule: schedule.data,
- queryBasePath: hasNonPosixSnapshotPaths ? "/" : findCommonAncestor(snapshot.paths),
- displayBasePath: getVolumeMountPath(schedule.data.volume),
- hasNonPosixSnapshotPaths,
+ displayBasePath,
+ snapshotSourcePathPlan: restorePlan,
};
},
head: ({ params }) => ({
@@ -58,16 +65,15 @@ export const Route = createFileRoute("/(dashboard)/backups/$backupId/$snapshotId
function RouteComponent() {
const { backupId, snapshotId } = Route.useParams();
- const { repository, queryBasePath, displayBasePath, hasNonPosixSnapshotPaths } = Route.useLoaderData();
+ const { repository, displayBasePath, snapshotSourcePathPlan } = Route.useLoaderData();
return (
);
}
diff --git a/app/routes/(dashboard)/repositories/$repositoryId/$snapshotId/restore.tsx b/app/routes/(dashboard)/repositories/$repositoryId/$snapshotId/restore.tsx
index aed977aad..48d16de57 100644
--- a/app/routes/(dashboard)/repositories/$repositoryId/$snapshotId/restore.tsx
+++ b/app/routes/(dashboard)/repositories/$repositoryId/$snapshotId/restore.tsx
@@ -1,19 +1,29 @@
import { createFileRoute } from "@tanstack/react-router";
import { getBackupSchedule } from "~/client/api-client";
-import { getRepositoryOptions, getSnapshotDetailsOptions } from "~/client/api-client/@tanstack/react-query.gen";
+import {
+ getRepositoryOptions,
+ getSnapshotDetailsOptions,
+ getSnapshotRestorePlanOptions,
+} from "~/client/api-client/@tanstack/react-query.gen";
import { RestoreSnapshotPage } from "~/client/modules/repositories/routes/restore-snapshot";
import { getVolumeMountPath } from "~/client/lib/volume-path";
-import { findCommonAncestor } from "@zerobyte/core/utils";
export const Route = createFileRoute("/(dashboard)/repositories/$repositoryId/$snapshotId/restore")({
component: RouteComponent,
errorComponent: (e) =>
{e.error.message}
,
loader: async ({ params, context }) => {
- const [snapshot, repository] = await Promise.all([
+ const [snapshot, repository, restorePlan] = await Promise.all([
context.queryClient.ensureQueryData({
...getSnapshotDetailsOptions({ path: { shortId: params.repositoryId, snapshotId: params.snapshotId } }),
}),
- context.queryClient.ensureQueryData({ ...getRepositoryOptions({ path: { shortId: params.repositoryId } }) }),
+ context.queryClient.ensureQueryData({
+ ...getRepositoryOptions({ path: { shortId: params.repositoryId } }),
+ }),
+ context.queryClient.ensureQueryData({
+ ...getSnapshotRestorePlanOptions({
+ path: { shortId: params.repositoryId, snapshotId: params.snapshotId },
+ }),
+ }),
]);
let displayBasePath: string | undefined;
@@ -25,21 +35,24 @@ export const Route = createFileRoute("/(dashboard)/repositories/$repositoryId/$s
}
}
- const hasNonPosixSnapshotPaths = snapshot.paths.some((path) => !path.startsWith("/"));
-
return {
snapshot,
repository,
- queryBasePath: hasNonPosixSnapshotPaths ? "/" : findCommonAncestor(snapshot.paths),
displayBasePath,
- hasNonPosixSnapshotPaths,
+ snapshotSourcePathPlan: restorePlan,
};
},
staticData: {
breadcrumb: (match) => [
{ label: "Repositories", href: "/repositories" },
- { label: match.loaderData?.repository?.name || "Repository", href: `/repositories/${match.params.repositoryId}` },
- { label: match.params.snapshotId, href: `/repositories/${match.params.repositoryId}/${match.params.snapshotId}` },
+ {
+ label: match.loaderData?.repository?.name || "Repository",
+ href: `/repositories/${match.params.repositoryId}`,
+ },
+ {
+ label: match.params.snapshotId,
+ href: `/repositories/${match.params.repositoryId}/${match.params.snapshotId}`,
+ },
{ label: "Restore" },
],
},
@@ -56,16 +69,15 @@ export const Route = createFileRoute("/(dashboard)/repositories/$repositoryId/$s
function RouteComponent() {
const { repositoryId, snapshotId } = Route.useParams();
- const { repository, queryBasePath, displayBasePath, hasNonPosixSnapshotPaths } = Route.useLoaderData();
+ const { repository, displayBasePath, snapshotSourcePathPlan } = Route.useLoaderData();
return (
);
}