fix(transfer): confirm background task submission

Closes #8649
This commit is contained in:
t8y2 committed 2026-09-27 14:19:10 +00:00
1 parent 5d13c5ecfc
commit 4329ec51db
20 files changed
+181 -12

No files matched your search

@@ -4,7 +4,7 @@ import { uuid } from "@/lib/common/utils";
import { useI18n } from "vue-i18n";
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog";
import { Button } from "@/components/ui/button";
import { buildTransferObjectSelections } from "./transferSelections";
import { buildTransferObjectSelections, countTransferObjects } from "./transferSelections";
import { createTaskLoadTracker } from "./taskLoadTracker";
import { confirmTransferWithProductionSafety, createTransferSubmission, rebuildUnavailableReason, resolveTransferStrategy, transferStrategyOptions, type TransferStrategy } from "./transferStrategy";
import { Input } from "@/components/ui/input";
@@ -815,6 +815,7 @@ function runTransfer(request: api.TransferRequest, shouldRefreshTargetTree: bool
isSubmitting.value = true;
startDataTransferTask(request, `${request.sourceDatabase} → ${request.targetDatabase}`, {
formatOverlapError: (tables) => t("transfer.targetTableBusy", { tables: tables.join(", ") }),
onStarted: () => toast(t("transfer.backgroundStarted")),
onDone: async () => {
if (shouldRefreshTargetTree) {
await store.refreshObjectListTreeNode(request.targetConnectionId, request.targetDatabase, request.targetSchema, request.targetCatalog);
@@ -1052,7 +1053,7 @@ const confirmationSummary = computed(() => {
if (!request) return "";
const source = formatTransferEndpointLabel(getConnectionName(request.sourceConnectionId), request.sourceDatabase, request.sourceSchema, request.sourceCatalog);
const target = formatTransferEndpointLabel(getConnectionName(request.targetConnectionId), request.targetDatabase, request.targetSchema, request.targetCatalog);
const count = request.tables.length + request.objects.reduce((total, selection) => total + selection.names.length, 0);
const count = countTransferObjects(request);
return t("transfer.startConfirmMessage", { source, target, count });
});
@@ -1,10 +1,28 @@
import { describe, expect, it } from "vitest";
import { buildTransferObjectSelections, matchBulkObjectNames, parseBulkObjectNames } from "../transferSelections";
import { buildTransferObjectSelections, countTransferObjects, matchBulkObjectNames, parseBulkObjectNames } from "../transferSelections";
function setOf(names: string[]): Set<string> {
return new Set(names);
}
describe("countTransferObjects", () => {
it("counts selected tables and non-table objects from their separate request fields", () => {
expect(
countTransferObjects({
tables: ["orders", "users"],
objects: [
{ objectType: "VIEW", names: ["active_users"] },
{ objectType: "SEQUENCE", names: ["order_id_seq"] },
],
}),
).toBe(4);
});
it("keeps a table-only multi-selection nonzero", () => {
expect(countTransferObjects({ tables: ["orders", "users"], objects: [] })).toBe(2);
});
});
describe("buildTransferObjectSelections", () => {
it("serializes non-table selections in request order", () => {
const result = buildTransferObjectSelections(
@@ -1,10 +1,15 @@
import type { TransferObjectKind } from "@/lib/backend/api";
import type { TransferObjectKind, TransferRequest } from "@/lib/backend/api";
export interface TransferObjectSelectionPayload {
objectType: TransferObjectKind;
names: string[];
}
/** Counts table and non-table selections represented by a transfer request. */
export function countTransferObjects(request: Pick<TransferRequest, "tables" | "objects">): number {
return request.tables.length + request.objects.reduce((total, selection) => total + selection.names.length, 0);
}
/**
* Builds the `objects` payload of a transfer request from the tree
* selection state. TABLE is handled by `tables`, and object types that