Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion client/src/pages/ConfigPage.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useEffect } from "react";
import { useNavigate, useParams } from "react-router-dom";
import { DatabaseConfigForm } from "@/components/DatabaseConfigForm";
import api from "@/lib/api";
Expand All @@ -8,6 +9,19 @@ export function ConfigPage() {
const { dbType } = useParams<{ dbType: string }>();
const navigate = useNavigate();

// Clear draft data when navigating away from the config page
useEffect(() => {
return () => {
if (dbType) {
try {
sessionStorage.removeItem(`db_mover_draft_${dbType}`);
} catch {
// Ignore storage access errors (e.g. when storage is blocked)
}
}
};
}, [dbType]);

const handleStartCopy = async (config: {
sourceUri: string;
targetUri: string;
Expand All @@ -23,7 +37,7 @@ export function ConfigPage() {
const { jobId } = res.data;

// Store migration config for retry functionality
localStorage.setItem(
sessionStorage.setItem(
`migration_${jobId}`,
JSON.stringify({
type: "copy",
Expand Down
31 changes: 27 additions & 4 deletions client/src/pages/MigrationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function MigrationPage() {

try {
// Get stored migration config
const storedConfig = localStorage.getItem(`migration_${jobId}`);
const storedConfig = sessionStorage.getItem(`migration_${jobId}`);
if (!storedConfig) {
toast.error("Retry failed", {
description:
Expand All @@ -38,9 +38,12 @@ export function MigrationPage() {
// Start new migration with same config
const res = await api.post("/migrate/start", config);
const newJobId = res.data.jobId;

// Store config for new job
localStorage.setItem(`migration_${newJobId}`, JSON.stringify(config));
try {
// Store config for new job
sessionStorage.setItem(`migration_${newJobId}`, JSON.stringify(config));
} catch (error) {
// Ignore storage access errors (e.g. when storage is blocked)
}

// Navigate to new migration page
navigate(`/migration/${newJobId}`);
Expand Down Expand Up @@ -84,6 +87,26 @@ export function MigrationPage() {

return () => {
es.close();

// Clean up session storage when navigating away
if (jobId) {
try {
const storedConfig = sessionStorage.getItem(`migration_${jobId}`);
if (storedConfig) {
const parsedConfig = JSON.parse(storedConfig);
const storedDbType =
typeof parsedConfig?.dbType === "string"
? parsedConfig.dbType.trim()
: "";
if (storedDbType) {
sessionStorage.removeItem(`db_mover_draft_${storedDbType}`);
}
}
sessionStorage.removeItem(`migration_${jobId}`);
} catch (storageError) {
console.error("Error cleaning up migration storage", storageError);
}
}
};
}, [jobId]);

Expand Down