feat(export): respect connection query timeout in table export
This commit is contained in:
8 files changed
+148
-7
No files matched your search
@@ -3,12 +3,13 @@ import { computed, onBeforeUnmount, onMounted, ref } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Loader2, CheckCircle2, XCircle, AlertCircle, FolderOpen, Minimize2, X } from "@lucide/vue";
|
||||
import { Loader2, CheckCircle2, XCircle, AlertCircle, FolderOpen, Minimize2, Wrench, X } from "@lucide/vue";
|
||||
import { useToast } from "@/composables/useToast";
|
||||
import { isTauriRuntime } from "@/lib/backend/tauriRuntime";
|
||||
import * as api from "@/lib/backend/api";
|
||||
import { translateBackendError } from "@/i18n/backend-errors";
|
||||
import { formatDataTransferDuration } from "@/composables/useExportTracker";
|
||||
import { isQueryTimeoutErrorMessage } from "@/lib/sql/queryError";
|
||||
|
||||
const { t } = useI18n();
|
||||
const { toast } = useToast();
|
||||
@@ -38,11 +39,13 @@ const props = defineProps<{
|
||||
finishedAt?: number;
|
||||
disableCancel?: boolean;
|
||||
canMinimize?: boolean;
|
||||
connectionId?: string;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
cancel: [];
|
||||
minimize: [];
|
||||
changeQueryTimeout: [];
|
||||
"update:open": [value: boolean];
|
||||
}>();
|
||||
|
||||
@@ -59,6 +62,7 @@ const displayName = computed(() => {
|
||||
});
|
||||
const isActive = computed(() => props.status === "Running" || props.status === "Writing");
|
||||
const isFinished = computed(() => props.status === "Done" || props.status === "Error" || props.status === "Cancelled");
|
||||
const canChangeQueryTimeout = computed(() => props.status === "Error" && !!props.connectionId && !!props.errorMessage && isQueryTimeoutErrorMessage(props.errorMessage));
|
||||
const canRevealFile = computed(() => props.status === "Done" && !!props.filePath && isTauriRuntime());
|
||||
const progressPercent = computed(() => {
|
||||
if (!props.totalRows || props.totalRows <= 0) return 0;
|
||||
@@ -163,6 +167,10 @@ async function revealExportFile() {
|
||||
</Button>
|
||||
</template>
|
||||
<template v-else-if="isFinished">
|
||||
<Button v-if="canChangeQueryTimeout" variant="outline" size="sm" @click="emit('changeQueryTimeout')">
|
||||
<Wrench class="mr-1 h-3.5 w-3.5" />
|
||||
{{ t("editor.changeQueryTimeout") }}
|
||||
</Button>
|
||||
<Button v-if="canRevealFile" size="sm" :disabled="isRevealing" @click="revealExportFile">
|
||||
<Loader2 v-if="isRevealing" class="mr-1 h-3.5 w-3.5 animate-spin" />
|
||||
<FolderOpen v-else class="mr-1 h-3.5 w-3.5" />
|
||||
|
||||
@@ -80,3 +80,29 @@ describe("ExportProgressDialog display name", () => {
|
||||
expect(document.body.textContent).toContain("audit_log (.csv)");
|
||||
});
|
||||
});
|
||||
|
||||
describe("ExportProgressDialog query timeout action", () => {
|
||||
it("offers connection settings for a query timeout", async () => {
|
||||
i18n.global.locale.value = "en";
|
||||
const onChangeQueryTimeout = vi.fn();
|
||||
await mountDialog({
|
||||
...baseProps,
|
||||
status: "Error",
|
||||
errorMessage: "Agent RPC error (-1): dm.jdbc.driver.DMException: 请求执行超时",
|
||||
connectionId: "dm-1",
|
||||
onChangeQueryTimeout,
|
||||
});
|
||||
|
||||
const button = [...document.body.querySelectorAll("button")].find((element) => element.textContent?.includes("Change query timeout"));
|
||||
expect(button).toBeTruthy();
|
||||
button?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
||||
expect(onChangeQueryTimeout).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it("does not offer timeout settings for unrelated export errors", async () => {
|
||||
i18n.global.locale.value = "en";
|
||||
await mountDialog({ ...baseProps, status: "Error", errorMessage: "Permission denied", connectionId: "dm-1" });
|
||||
|
||||
expect(document.body.textContent).not.toContain("Change query timeout");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user