feat(export): add setting to auto-open folder after export
This commit is contained in:
1 parent
8df09c779f
commit
b10c5433da
28 files changed
+336
-15
No files matched your search
@@ -901,6 +901,7 @@ const editSidebarIndent = ref(settingsStore.editorSettings.sidebarIndent);
|
|||||||
const editSidebarFontSize = ref(settingsStore.editorSettings.sidebarFontSize);
|
const editSidebarFontSize = ref(settingsStore.editorSettings.sidebarFontSize);
|
||||||
const editExportBatchSize = ref(settingsStore.editorSettings.exportBatchSize);
|
const editExportBatchSize = ref(settingsStore.editorSettings.exportBatchSize);
|
||||||
const editPreferredExportPath = ref(settingsStore.editorSettings.preferredExportPath);
|
const editPreferredExportPath = ref(settingsStore.editorSettings.preferredExportPath);
|
||||||
|
const editAutoOpenExportFolder = ref(settingsStore.editorSettings.autoOpenExportFolder);
|
||||||
const editCsvQuoteMode = ref<CsvQuoteMode>(settingsStore.editorSettings.csvQuoteMode);
|
const editCsvQuoteMode = ref<CsvQuoteMode>(settingsStore.editorSettings.csvQuoteMode);
|
||||||
const editCsvNullMode = ref<CsvNullMode>(settingsStore.editorSettings.csvNullMode);
|
const editCsvNullMode = ref<CsvNullMode>(settingsStore.editorSettings.csvNullMode);
|
||||||
const editGlobalDateTimeDisplayFormat = ref(settingsStore.editorSettings.globalDateTimeDisplayFormat);
|
const editGlobalDateTimeDisplayFormat = ref(settingsStore.editorSettings.globalDateTimeDisplayFormat);
|
||||||
@@ -1179,6 +1180,7 @@ function currentEditorSettingsDraft(): EditorSettingsDraft {
|
|||||||
redisDatabaseDisplayLimit: editRedisDatabaseDisplayLimit.value,
|
redisDatabaseDisplayLimit: editRedisDatabaseDisplayLimit.value,
|
||||||
exportBatchSize: editExportBatchSize.value,
|
exportBatchSize: editExportBatchSize.value,
|
||||||
preferredExportPath: editPreferredExportPath.value,
|
preferredExportPath: editPreferredExportPath.value,
|
||||||
|
autoOpenExportFolder: editAutoOpenExportFolder.value,
|
||||||
csvQuoteMode: editCsvQuoteMode.value,
|
csvQuoteMode: editCsvQuoteMode.value,
|
||||||
csvNullMode: editCsvNullMode.value,
|
csvNullMode: editCsvNullMode.value,
|
||||||
globalDateTimeDisplayFormat: editGlobalDateTimeDisplayFormat.value,
|
globalDateTimeDisplayFormat: editGlobalDateTimeDisplayFormat.value,
|
||||||
@@ -1856,6 +1858,7 @@ function syncEditorSettingsDraftFromStore() {
|
|||||||
editSidebarFontSize.value = settingsStore.editorSettings.sidebarFontSize;
|
editSidebarFontSize.value = settingsStore.editorSettings.sidebarFontSize;
|
||||||
editExportBatchSize.value = settingsStore.editorSettings.exportBatchSize;
|
editExportBatchSize.value = settingsStore.editorSettings.exportBatchSize;
|
||||||
editPreferredExportPath.value = settingsStore.editorSettings.preferredExportPath;
|
editPreferredExportPath.value = settingsStore.editorSettings.preferredExportPath;
|
||||||
|
editAutoOpenExportFolder.value = settingsStore.editorSettings.autoOpenExportFolder;
|
||||||
editCsvQuoteMode.value = settingsStore.editorSettings.csvQuoteMode;
|
editCsvQuoteMode.value = settingsStore.editorSettings.csvQuoteMode;
|
||||||
editCsvNullMode.value = settingsStore.editorSettings.csvNullMode;
|
editCsvNullMode.value = settingsStore.editorSettings.csvNullMode;
|
||||||
editGlobalDateTimeDisplayFormat.value = settingsStore.editorSettings.globalDateTimeDisplayFormat;
|
editGlobalDateTimeDisplayFormat.value = settingsStore.editorSettings.globalDateTimeDisplayFormat;
|
||||||
@@ -2007,6 +2010,7 @@ const editorSettingsDraftRefs: EditorSettingsDraftRefMap = {
|
|||||||
redisDatabaseDisplayLimit: editRedisDatabaseDisplayLimit,
|
redisDatabaseDisplayLimit: editRedisDatabaseDisplayLimit,
|
||||||
exportBatchSize: editExportBatchSize,
|
exportBatchSize: editExportBatchSize,
|
||||||
preferredExportPath: editPreferredExportPath,
|
preferredExportPath: editPreferredExportPath,
|
||||||
|
autoOpenExportFolder: editAutoOpenExportFolder,
|
||||||
csvQuoteMode: editCsvQuoteMode,
|
csvQuoteMode: editCsvQuoteMode,
|
||||||
csvNullMode: editCsvNullMode,
|
csvNullMode: editCsvNullMode,
|
||||||
exportRowLimitEnabled: editExportRowLimitEnabled,
|
exportRowLimitEnabled: editExportRowLimitEnabled,
|
||||||
@@ -2560,6 +2564,7 @@ function resetDefaultsForTab(tab: SettingsCategory) {
|
|||||||
editRedisDatabaseDisplayLimit.value = DEFAULT_EDITOR_SETTINGS.redisDatabaseDisplayLimit;
|
editRedisDatabaseDisplayLimit.value = DEFAULT_EDITOR_SETTINGS.redisDatabaseDisplayLimit;
|
||||||
editExportBatchSize.value = DEFAULT_EDITOR_SETTINGS.exportBatchSize;
|
editExportBatchSize.value = DEFAULT_EDITOR_SETTINGS.exportBatchSize;
|
||||||
editPreferredExportPath.value = DEFAULT_EDITOR_SETTINGS.preferredExportPath;
|
editPreferredExportPath.value = DEFAULT_EDITOR_SETTINGS.preferredExportPath;
|
||||||
|
editAutoOpenExportFolder.value = DEFAULT_EDITOR_SETTINGS.autoOpenExportFolder;
|
||||||
editCsvQuoteMode.value = DEFAULT_EDITOR_SETTINGS.csvQuoteMode;
|
editCsvQuoteMode.value = DEFAULT_EDITOR_SETTINGS.csvQuoteMode;
|
||||||
editCsvNullMode.value = DEFAULT_EDITOR_SETTINGS.csvNullMode;
|
editCsvNullMode.value = DEFAULT_EDITOR_SETTINGS.csvNullMode;
|
||||||
editGlobalDateTimeDisplayFormat.value = DEFAULT_EDITOR_SETTINGS.globalDateTimeDisplayFormat;
|
editGlobalDateTimeDisplayFormat.value = DEFAULT_EDITOR_SETTINGS.globalDateTimeDisplayFormat;
|
||||||
@@ -2715,6 +2720,7 @@ function resetAllDefaults() {
|
|||||||
editRedisDatabaseDisplayLimit.value = DEFAULT_EDITOR_SETTINGS.redisDatabaseDisplayLimit;
|
editRedisDatabaseDisplayLimit.value = DEFAULT_EDITOR_SETTINGS.redisDatabaseDisplayLimit;
|
||||||
editExportBatchSize.value = DEFAULT_EDITOR_SETTINGS.exportBatchSize;
|
editExportBatchSize.value = DEFAULT_EDITOR_SETTINGS.exportBatchSize;
|
||||||
editPreferredExportPath.value = DEFAULT_EDITOR_SETTINGS.preferredExportPath;
|
editPreferredExportPath.value = DEFAULT_EDITOR_SETTINGS.preferredExportPath;
|
||||||
|
editAutoOpenExportFolder.value = DEFAULT_EDITOR_SETTINGS.autoOpenExportFolder;
|
||||||
editCsvQuoteMode.value = DEFAULT_EDITOR_SETTINGS.csvQuoteMode;
|
editCsvQuoteMode.value = DEFAULT_EDITOR_SETTINGS.csvQuoteMode;
|
||||||
editCsvNullMode.value = DEFAULT_EDITOR_SETTINGS.csvNullMode;
|
editCsvNullMode.value = DEFAULT_EDITOR_SETTINGS.csvNullMode;
|
||||||
editGlobalDateTimeDisplayFormat.value = DEFAULT_EDITOR_SETTINGS.globalDateTimeDisplayFormat;
|
editGlobalDateTimeDisplayFormat.value = DEFAULT_EDITOR_SETTINGS.globalDateTimeDisplayFormat;
|
||||||
@@ -9069,6 +9075,15 @@ onUnmounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
<p class="text-xs text-muted-foreground">{{ t("settings.preferredExportPathDescription") }}</p>
|
<p class="text-xs text-muted-foreground">{{ t("settings.preferredExportPathDescription") }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="!isWeb" data-settings-search-id="data-export-auto-open-folder" :class="['flex items-start justify-between gap-3', settingsSearchTargetClass('data-export-auto-open-folder')]">
|
||||||
|
<div class="space-y-0.5">
|
||||||
|
<Label for="export-auto-open-folder">{{ t("settings.autoOpenExportFolder") }}</Label>
|
||||||
|
<p class="text-xs text-muted-foreground">
|
||||||
|
{{ t("settings.autoOpenExportFolderDescription") }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<Switch id="export-auto-open-folder" v-model="editAutoOpenExportFolder" class="mt-0.5" />
|
||||||
|
</div>
|
||||||
<div class="space-y-2">
|
<div class="space-y-2">
|
||||||
<Label>{{ t("settings.exportBatchSize") }}</Label>
|
<Label>{{ t("settings.exportBatchSize") }}</Label>
|
||||||
<div class="flex items-center gap-3">
|
<div class="flex items-center gap-3">
|
||||||
|
|||||||
@@ -18,10 +18,12 @@ import { isTauriRuntime } from "@/lib/backend/tauriRuntime";
|
|||||||
import { promptExportSavePath } from "@/lib/export/exportPath";
|
import { promptExportSavePath } from "@/lib/export/exportPath";
|
||||||
import { useToast } from "@/composables/useToast";
|
import { useToast } from "@/composables/useToast";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { Download, Square, CheckSquare, Search, X, Loader2, Wrench } from "@lucide/vue";
|
import { Download, Square, CheckSquare, Search, X, Loader2, Wrench, FolderOpen } from "@lucide/vue";
|
||||||
import { formatDataTransferDuration, useExportTracker } from "@/composables/useExportTracker";
|
import { formatDataTransferDuration, useExportTracker } from "@/composables/useExportTracker";
|
||||||
import { isQueryTimeoutErrorMessage } from "@/lib/sql/queryError";
|
import { isQueryTimeoutErrorMessage } from "@/lib/sql/queryError";
|
||||||
import type { SqlInsertDialect, SqlInsertMode } from "@/lib/export/sqlInsertMode";
|
import type { SqlInsertDialect, SqlInsertMode } from "@/lib/export/sqlInsertMode";
|
||||||
|
import { revealExportedPath } from "@/lib/export/exportPath";
|
||||||
|
import { translateBackendError } from "@/i18n/backend-errors";
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
@@ -91,6 +93,22 @@ const exportWarning = ref<string | null>(null);
|
|||||||
const exportCancelled = ref(false);
|
const exportCancelled = ref(false);
|
||||||
const exportStartedAt = ref<number | null>(null);
|
const exportStartedAt = ref<number | null>(null);
|
||||||
const exportFinishedAt = ref<number | null>(null);
|
const exportFinishedAt = ref<number | null>(null);
|
||||||
|
const exportFilePath = ref("");
|
||||||
|
const isRevealing = ref(false);
|
||||||
|
const canRevealFile = computed(() => exportDone.value && !!exportFilePath.value && isTauriRuntime());
|
||||||
|
|
||||||
|
async function revealExportFile() {
|
||||||
|
if (!exportFilePath.value || isRevealing.value) return;
|
||||||
|
isRevealing.value = true;
|
||||||
|
try {
|
||||||
|
await revealExportedPath(exportFilePath.value);
|
||||||
|
} catch (error) {
|
||||||
|
toast(t("exportProgress.openFolderFailed", { message: translateBackendError(t, error) }), 5000);
|
||||||
|
} finally {
|
||||||
|
isRevealing.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const currentTime = ref(Date.now());
|
const currentTime = ref(Date.now());
|
||||||
const pendingPrefillTable = ref("");
|
const pendingPrefillTable = ref("");
|
||||||
const pendingPrefillTables = ref<string[]>([]);
|
const pendingPrefillTables = ref<string[]>([]);
|
||||||
@@ -357,6 +375,7 @@ async function startExport() {
|
|||||||
// Web mode: use a temp path; the server will handle the file
|
// Web mode: use a temp path; the server will handle the file
|
||||||
filePath = `__web_export_${exportId.value}.sql`;
|
filePath = `__web_export_${exportId.value}.sql`;
|
||||||
}
|
}
|
||||||
|
exportFilePath.value = filePath;
|
||||||
|
|
||||||
// Switch to the progress view only after the save dialog closes, and seed a
|
// Switch to the progress view only after the save dialog closes, and seed a
|
||||||
// preparing state so the dialog is never a blank panel while metadata loads.
|
// preparing state so the dialog is never a blank panel while metadata loads.
|
||||||
@@ -489,6 +508,7 @@ async function startAllDatabasesExport() {
|
|||||||
const connectionType = store.getConfig(connectionId.value)?.db_type;
|
const connectionType = store.getConfig(connectionId.value)?.db_type;
|
||||||
const batchId = generateDatabaseExportId();
|
const batchId = generateDatabaseExportId();
|
||||||
exportId.value = batchId;
|
exportId.value = batchId;
|
||||||
|
exportFilePath.value = directoryPath;
|
||||||
exportProgress.value = {
|
exportProgress.value = {
|
||||||
exportId: batchId,
|
exportId: batchId,
|
||||||
currentObject: "",
|
currentObject: "",
|
||||||
@@ -682,6 +702,7 @@ function resetState() {
|
|||||||
exportCancelled.value = false;
|
exportCancelled.value = false;
|
||||||
exportStartedAt.value = null;
|
exportStartedAt.value = null;
|
||||||
exportFinishedAt.value = null;
|
exportFinishedAt.value = null;
|
||||||
|
exportFilePath.value = "";
|
||||||
exportId.value = "";
|
exportId.value = "";
|
||||||
batchDatabaseIndex.value = 0;
|
batchDatabaseIndex.value = 0;
|
||||||
batchDatabaseTotal.value = 0;
|
batchDatabaseTotal.value = 0;
|
||||||
@@ -1075,7 +1096,12 @@ watch(
|
|||||||
</Button>
|
</Button>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<Button size="sm" @click="open = false">
|
<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" />
|
||||||
|
{{ t("exportProgress.openFolder") }}
|
||||||
|
</Button>
|
||||||
|
<Button size="sm" variant="outline" @click="open = false">
|
||||||
{{ t("common.close") }}
|
{{ t("common.close") }}
|
||||||
</Button>
|
</Button>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onBeforeUnmount, onMounted, ref } from "vue";
|
import { computed, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog";
|
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Loader2, CheckCircle2, XCircle, AlertCircle, FolderOpen, Minimize2, Wrench, X } from "@lucide/vue";
|
import { Loader2, CheckCircle2, XCircle, AlertCircle, FolderOpen, Minimize2, Wrench, X } from "@lucide/vue";
|
||||||
import { useToast } from "@/composables/useToast";
|
import { useToast } from "@/composables/useToast";
|
||||||
import { isTauriRuntime } from "@/lib/backend/tauriRuntime";
|
import { isTauriRuntime } from "@/lib/backend/tauriRuntime";
|
||||||
import * as api from "@/lib/backend/api";
|
import { autoRevealExportedPathIfConfigured, revealExportedPath } from "@/lib/export/exportPath";
|
||||||
import { translateBackendError } from "@/i18n/backend-errors";
|
import { translateBackendError } from "@/i18n/backend-errors";
|
||||||
import { formatDataTransferDuration } from "@/composables/useExportTracker";
|
import { formatDataTransferDuration } from "@/composables/useExportTracker";
|
||||||
import { isQueryTimeoutErrorMessage } from "@/lib/sql/queryError";
|
import { isQueryTimeoutErrorMessage } from "@/lib/sql/queryError";
|
||||||
@@ -86,13 +86,22 @@ async function revealExportFile() {
|
|||||||
if (!props.filePath || isRevealing.value) return;
|
if (!props.filePath || isRevealing.value) return;
|
||||||
isRevealing.value = true;
|
isRevealing.value = true;
|
||||||
try {
|
try {
|
||||||
await api.revealPathInFileManager(props.filePath);
|
await revealExportedPath(props.filePath);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast(t("exportProgress.openFolderFailed", { message: translateBackendError(t, error) }), 5000);
|
toast(t("exportProgress.openFolderFailed", { message: translateBackendError(t, error) }), 5000);
|
||||||
} finally {
|
} finally {
|
||||||
isRevealing.value = false;
|
isRevealing.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.status,
|
||||||
|
(status, oldStatus) => {
|
||||||
|
if (status === "Done" && oldStatus !== "Done" && props.filePath) {
|
||||||
|
void autoRevealExportedPathIfConfigured(props.filePath);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ import { useToast } from "@/composables/useToast";
|
|||||||
import { buildExecutableObjectSourceStatements, buildRoutineRenameObjectSourceStatements, executeObjectSourceSave, formatObjectSourceSaveError, supportsSourceBackedRoutineRename } from "@/lib/table/objectSourceEditor";
|
import { buildExecutableObjectSourceStatements, buildRoutineRenameObjectSourceStatements, executeObjectSourceSave, formatObjectSourceSaveError, supportsSourceBackedRoutineRename } from "@/lib/table/objectSourceEditor";
|
||||||
import { buildRenameObjectSql, supportsObjectRename } from "@/lib/table/objectRenameSql";
|
import { buildRenameObjectSql, supportsObjectRename } from "@/lib/table/objectRenameSql";
|
||||||
import { isTauriRuntime } from "@/lib/backend/tauriRuntime";
|
import { isTauriRuntime } from "@/lib/backend/tauriRuntime";
|
||||||
import { promptExportSavePath } from "@/lib/export/exportPath";
|
import { autoRevealExportedPathIfConfigured, promptExportSavePath } from "@/lib/export/exportPath";
|
||||||
import { generateDatabaseExportId } from "@/lib/export/databaseExport";
|
import { generateDatabaseExportId } from "@/lib/export/databaseExport";
|
||||||
import { buildXlsxHeaderOverrides, hasXlsxHeaderComments, type XlsxExportOptions, type XlsxHeaderMode } from "@/lib/export/xlsxHeader";
|
import { buildXlsxHeaderOverrides, hasXlsxHeaderComments, type XlsxExportOptions, type XlsxHeaderMode } from "@/lib/export/xlsxHeader";
|
||||||
import { showSqlInsertModeDialog, type SqlInsertDialect, type SqlInsertMode } from "@/lib/export/sqlInsertMode";
|
import { showSqlInsertModeDialog, type SqlInsertDialect, type SqlInsertMode } from "@/lib/export/sqlInsertMode";
|
||||||
@@ -2424,6 +2424,7 @@ async function exportDataLegacy(row: ObjectBrowserRow, format: "json") {
|
|||||||
}
|
}
|
||||||
await api.exportQueryResultJson(outputPath, result.columns, result.rows);
|
await api.exportQueryResultJson(outputPath, result.columns, result.rows);
|
||||||
toast(t("grid.exported"));
|
toast(t("grid.exported"));
|
||||||
|
void autoRevealExportedPathIfConfigured(outputPath);
|
||||||
}
|
}
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
toast(t("grid.exportFailed", { message: e?.message || String(e) }), 5000);
|
toast(t("grid.exportFailed", { message: e?.message || String(e) }), 5000);
|
||||||
@@ -2523,6 +2524,7 @@ async function exportTableData(row: ObjectBrowserRow, format: "csv" | "xlsx" | "
|
|||||||
await api.exportQueryResultXlsx(filePath, row.name, result.columns, result.column_types ?? result.columns.map(() => ""), headerOverrides, result.rows, undefined, autoFilter, settingsStore.editorSettings.globalDateTimeExportFormat || undefined);
|
await api.exportQueryResultXlsx(filePath, row.name, result.columns, result.column_types ?? result.columns.map(() => ""), headerOverrides, result.rows, undefined, autoFilter, settingsStore.editorSettings.globalDateTimeExportFormat || undefined);
|
||||||
}
|
}
|
||||||
toast(t("grid.exported"));
|
toast(t("grid.exported"));
|
||||||
|
void autoRevealExportedPathIfConfigured(filePath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let columns: string[] | undefined;
|
let columns: string[] | undefined;
|
||||||
|
|||||||
@@ -9,6 +9,11 @@ vi.mock("@/lib/backend/api", () => ({
|
|||||||
cancelTableExport: vi.fn(),
|
cancelTableExport: vi.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
const mockAutoRevealExportedPathIfConfigured = vi.fn();
|
||||||
|
vi.mock("@/lib/export/exportPath", () => ({
|
||||||
|
autoRevealExportedPathIfConfigured: (...args: unknown[]) => mockAutoRevealExportedPathIfConfigured(...args),
|
||||||
|
}));
|
||||||
|
|
||||||
import * as api from "@/lib/backend/api";
|
import * as api from "@/lib/backend/api";
|
||||||
import {
|
import {
|
||||||
formatDataTransferDuration,
|
formatDataTransferDuration,
|
||||||
@@ -487,3 +492,44 @@ describe("formatDataTransferDuration", () => {
|
|||||||
expect(formatDataTransferDuration(3_661_000)).toBe("1h 1m 1s");
|
expect(formatDataTransferDuration(3_661_000)).toBe("1h 1m 1s");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("auto-revealing export directory on completion", () => {
|
||||||
|
it("triggers auto-reveal when manual export task succeeds with a file path", () => {
|
||||||
|
const tracker = useExportTracker();
|
||||||
|
const task = tracker.addDatabaseExportTask("db-export-1", "mydb", "/tmp/backup.sql", "manual");
|
||||||
|
tracker.updateDatabaseExportTask(task.exportId, {
|
||||||
|
exportId: task.exportId,
|
||||||
|
status: "Done",
|
||||||
|
rowsExported: 100,
|
||||||
|
totalRows: 100,
|
||||||
|
} as any);
|
||||||
|
|
||||||
|
expect(mockAutoRevealExportedPathIfConfigured).toHaveBeenCalledTimes(1);
|
||||||
|
expect(mockAutoRevealExportedPathIfConfigured).toHaveBeenCalledWith("/tmp/backup.sql");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("does not trigger auto-reveal for scheduled exports", () => {
|
||||||
|
const tracker = useExportTracker();
|
||||||
|
const task = tracker.addDatabaseExportTask("db-export-sched", "mydb", "/tmp/backup.sql", "scheduled");
|
||||||
|
tracker.updateDatabaseExportTask(task.exportId, {
|
||||||
|
exportId: task.exportId,
|
||||||
|
status: "Done",
|
||||||
|
rowsExported: 100,
|
||||||
|
totalRows: 100,
|
||||||
|
} as any);
|
||||||
|
|
||||||
|
expect(mockAutoRevealExportedPathIfConfigured).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("does not trigger auto-reveal when export ends with error or cancellation", () => {
|
||||||
|
const tracker = useExportTracker();
|
||||||
|
const task = tracker.addDatabaseExportTask("db-export-err", "mydb", "/tmp/backup.sql", "manual");
|
||||||
|
tracker.updateDatabaseExportTask(task.exportId, {
|
||||||
|
exportId: task.exportId,
|
||||||
|
status: "Error",
|
||||||
|
errorMessage: "disk full",
|
||||||
|
} as any);
|
||||||
|
|
||||||
|
expect(mockAutoRevealExportedPathIfConfigured).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -2,7 +2,7 @@ import { computed, type ComputedRef, type Ref, createApp } from "vue";
|
|||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { useDataGridExtractor } from "@/composables/useDataGridExtractor";
|
import { useDataGridExtractor } from "@/composables/useDataGridExtractor";
|
||||||
import { isTauriRuntime } from "@/lib/backend/tauriRuntime";
|
import { isTauriRuntime } from "@/lib/backend/tauriRuntime";
|
||||||
import { promptExportSavePath } from "@/lib/export/exportPath";
|
import { autoRevealExportedPathIfConfigured, promptExportSavePath } from "@/lib/export/exportPath";
|
||||||
import { saveTextFile, sanitizeExportBaseName, compactLocalTimestamp } from "@/lib/export/saveTextFile";
|
import { saveTextFile, sanitizeExportBaseName, compactLocalTimestamp } from "@/lib/export/saveTextFile";
|
||||||
import { dropsSchemaQualifier } from "@/lib/table/tableSelectSql";
|
import { dropsSchemaQualifier } from "@/lib/table/tableSelectSql";
|
||||||
import * as api from "@/lib/backend/api";
|
import * as api from "@/lib/backend/api";
|
||||||
@@ -928,6 +928,7 @@ export function useDataGridExport(options: UseDataGridExportOptions) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
toast(t("grid.exported"));
|
toast(t("grid.exported"));
|
||||||
|
void autoRevealExportedPathIfConfigured(outputPath);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
if (exportProgressState) {
|
if (exportProgressState) {
|
||||||
exportProgressState.value = {
|
exportProgressState.value = {
|
||||||
@@ -957,6 +958,7 @@ export function useDataGridExport(options: UseDataGridExportOptions) {
|
|||||||
const result = await resultToExport(undefined, undefined, false);
|
const result = await resultToExport(undefined, undefined, false);
|
||||||
await api.exportQueryResultCsv(outputPath, result.columns, result.rows, useSettingsStore().editorSettings.csvQuoteMode, csvNullLiteralForMode(useSettingsStore().editorSettings.csvNullMode));
|
await api.exportQueryResultCsv(outputPath, result.columns, result.rows, useSettingsStore().editorSettings.csvQuoteMode, csvNullLiteralForMode(useSettingsStore().editorSettings.csvNullMode));
|
||||||
toast(t("grid.exported"));
|
toast(t("grid.exported"));
|
||||||
|
void autoRevealExportedPathIfConfigured(outputPath);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
toast(t("grid.exportFailed", { message: translateBackendError(t, e) }), 5000);
|
toast(t("grid.exportFailed", { message: translateBackendError(t, e) }), 5000);
|
||||||
}
|
}
|
||||||
@@ -982,6 +984,7 @@ export function useDataGridExport(options: UseDataGridExportOptions) {
|
|||||||
const result = await resultToExport(rowIds, undefined, true, true, "name", true);
|
const result = await resultToExport(rowIds, undefined, true, true, "name", true);
|
||||||
await api.exportQueryResultJson(outputPath, result.columns, result.rows);
|
await api.exportQueryResultJson(outputPath, result.columns, result.rows);
|
||||||
toast(t("grid.exported"));
|
toast(t("grid.exported"));
|
||||||
|
void autoRevealExportedPathIfConfigured(outputPath);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
toast(t("grid.exportFailed", { message: translateBackendError(t, e) }), 5000);
|
toast(t("grid.exportFailed", { message: translateBackendError(t, e) }), 5000);
|
||||||
}
|
}
|
||||||
@@ -1004,6 +1007,7 @@ export function useDataGridExport(options: UseDataGridExportOptions) {
|
|||||||
const result = await resultToExport(undefined, undefined, false, true, "name", true);
|
const result = await resultToExport(undefined, undefined, false, true, "name", true);
|
||||||
await api.exportQueryResultJson(outputPath, result.columns, result.rows);
|
await api.exportQueryResultJson(outputPath, result.columns, result.rows);
|
||||||
toast(t("grid.exported"));
|
toast(t("grid.exported"));
|
||||||
|
void autoRevealExportedPathIfConfigured(outputPath);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
toast(t("grid.exportFailed", { message: translateBackendError(t, e) }), 5000);
|
toast(t("grid.exportFailed", { message: translateBackendError(t, e) }), 5000);
|
||||||
}
|
}
|
||||||
@@ -1028,6 +1032,7 @@ export function useDataGridExport(options: UseDataGridExportOptions) {
|
|||||||
const result = await resultToExport(rowIds);
|
const result = await resultToExport(rowIds);
|
||||||
await api.exportQueryResultMarkdown(outputPath, result.columns, result.rows);
|
await api.exportQueryResultMarkdown(outputPath, result.columns, result.rows);
|
||||||
toast(t("grid.exported"));
|
toast(t("grid.exported"));
|
||||||
|
void autoRevealExportedPathIfConfigured(outputPath);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
toast(t("grid.exportFailed", { message: translateBackendError(t, e) }), 5000);
|
toast(t("grid.exportFailed", { message: translateBackendError(t, e) }), 5000);
|
||||||
}
|
}
|
||||||
@@ -1050,6 +1055,7 @@ export function useDataGridExport(options: UseDataGridExportOptions) {
|
|||||||
const result = await resultToExport(undefined, undefined, false);
|
const result = await resultToExport(undefined, undefined, false);
|
||||||
await api.exportQueryResultMarkdown(outputPath, result.columns, result.rows);
|
await api.exportQueryResultMarkdown(outputPath, result.columns, result.rows);
|
||||||
toast(t("grid.exported"));
|
toast(t("grid.exported"));
|
||||||
|
void autoRevealExportedPathIfConfigured(outputPath);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
toast(t("grid.exportFailed", { message: translateBackendError(t, e) }), 5000);
|
toast(t("grid.exportFailed", { message: translateBackendError(t, e) }), 5000);
|
||||||
}
|
}
|
||||||
@@ -1063,7 +1069,7 @@ export function useDataGridExport(options: UseDataGridExportOptions) {
|
|||||||
if (await exportFullTableDataViaBackend("txt", rowIds)) return;
|
if (await exportFullTableDataViaBackend("txt", rowIds)) return;
|
||||||
const result = await resultToExport(rowIds);
|
const result = await resultToExport(rowIds);
|
||||||
const content = formatTsv(result.columns, result.rows);
|
const content = formatTsv(result.columns, result.rows);
|
||||||
await saveTextFile(content, exportFileName(tableMeta.value?.tableName || "export", "txt", { preferFallback: true }), "Text", "txt");
|
await saveTextFile(content, exportFileName(tableMeta.value?.tableName || "export", "txt", { preferFallback: true }), "Text", "txt", { autoOpenFolder: true });
|
||||||
toast(t("grid.exported"));
|
toast(t("grid.exported"));
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
toast(t("grid.exportFailed", { message: translateBackendError(t, e) }), 5000);
|
toast(t("grid.exportFailed", { message: translateBackendError(t, e) }), 5000);
|
||||||
@@ -1091,6 +1097,7 @@ export function useDataGridExport(options: UseDataGridExportOptions) {
|
|||||||
await api.exportQueryResultHtml(outputPath, currentExportTitle(), result.columns, result.rows);
|
await api.exportQueryResultHtml(outputPath, currentExportTitle(), result.columns, result.rows);
|
||||||
toast(t("grid.exported"));
|
toast(t("grid.exported"));
|
||||||
if (openAfterExport && isTauriRuntime()) await api.openQueryResultTempFile(outputPath);
|
if (openAfterExport && isTauriRuntime()) await api.openQueryResultTempFile(outputPath);
|
||||||
|
else void autoRevealExportedPathIfConfigured(outputPath);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
toast(t("grid.exportFailed", { message: translateBackendError(t, e) }), 5000);
|
toast(t("grid.exportFailed", { message: translateBackendError(t, e) }), 5000);
|
||||||
}
|
}
|
||||||
@@ -1113,6 +1120,7 @@ export function useDataGridExport(options: UseDataGridExportOptions) {
|
|||||||
const result = await resultToExport(undefined, undefined, false);
|
const result = await resultToExport(undefined, undefined, false);
|
||||||
await api.exportQueryResultHtml(outputPath, currentExportTitle(), result.columns, result.rows);
|
await api.exportQueryResultHtml(outputPath, currentExportTitle(), result.columns, result.rows);
|
||||||
toast(t("grid.exported"));
|
toast(t("grid.exported"));
|
||||||
|
void autoRevealExportedPathIfConfigured(outputPath);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
toast(t("grid.exportFailed", { message: translateBackendError(t, e) }), 5000);
|
toast(t("grid.exportFailed", { message: translateBackendError(t, e) }), 5000);
|
||||||
}
|
}
|
||||||
@@ -1124,7 +1132,7 @@ export function useDataGridExport(options: UseDataGridExportOptions) {
|
|||||||
try {
|
try {
|
||||||
const result = await resultToExport(undefined, undefined, false);
|
const result = await resultToExport(undefined, undefined, false);
|
||||||
const content = formatTsv(result.columns, result.rows);
|
const content = formatTsv(result.columns, result.rows);
|
||||||
await saveTextFile(content, exportFileName("export-page", "txt", { page: true }), "Text", "txt");
|
await saveTextFile(content, exportFileName("export-page", "txt", { page: true }), "Text", "txt", { autoOpenFolder: true });
|
||||||
toast(t("grid.exported"));
|
toast(t("grid.exported"));
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
toast(t("grid.exportFailed", { message: translateBackendError(t, e) }), 5000);
|
toast(t("grid.exportFailed", { message: translateBackendError(t, e) }), 5000);
|
||||||
@@ -1256,6 +1264,7 @@ export function useDataGridExport(options: UseDataGridExportOptions) {
|
|||||||
const result = await resultToExport(undefined, undefined, false, true, exportOptions.headerMode);
|
const result = await resultToExport(undefined, undefined, false, true, exportOptions.headerMode);
|
||||||
await writeXlsxResult(outputPath, result, includeSqlSheet, exportOptions.autoFilter, currentPageExportSql());
|
await writeXlsxResult(outputPath, result, includeSqlSheet, exportOptions.autoFilter, currentPageExportSql());
|
||||||
toast(t("grid.exported"));
|
toast(t("grid.exported"));
|
||||||
|
void autoRevealExportedPathIfConfigured(outputPath);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
toast(t("grid.exportFailed", { message: translateBackendError(t, e) }), 5000);
|
toast(t("grid.exportFailed", { message: translateBackendError(t, e) }), 5000);
|
||||||
}
|
}
|
||||||
@@ -1304,6 +1313,7 @@ export function useDataGridExport(options: UseDataGridExportOptions) {
|
|||||||
const sqlWorksheet = includeSqlSheet ? buildXlsxSqlWorksheet(sheets.map((sheet) => ({ resultName: sheet.sheetName, sql: sheet.sql || sheet.result.sourceStatement || "" }))) : undefined;
|
const sqlWorksheet = includeSqlSheet ? buildXlsxSqlWorksheet(sheets.map((sheet) => ({ resultName: sheet.sheetName, sql: sheet.sql || sheet.result.sourceStatement || "" }))) : undefined;
|
||||||
await api.exportQueryResultsXlsx(outputPath, sqlWorksheet ? [...worksheets, { ...sqlWorksheet, autoFilter: false }] : worksheets, exportOptions.autoFilter, exportPattern || undefined);
|
await api.exportQueryResultsXlsx(outputPath, sqlWorksheet ? [...worksheets, { ...sqlWorksheet, autoFilter: false }] : worksheets, exportOptions.autoFilter, exportPattern || undefined);
|
||||||
toast(t("grid.exported"));
|
toast(t("grid.exported"));
|
||||||
|
void autoRevealExportedPathIfConfigured(outputPath);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
toast(t("grid.exportFailed", { message: translateBackendError(t, e) }), 5000);
|
toast(t("grid.exportFailed", { message: translateBackendError(t, e) }), 5000);
|
||||||
}
|
}
|
||||||
@@ -1701,7 +1711,7 @@ export function useDataGridExport(options: UseDataGridExportOptions) {
|
|||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
logExportStage("save-start", { contentChars: content.length }, true);
|
logExportStage("save-start", { contentChars: content.length }, true);
|
||||||
await saveTextFile(content, exportFileName(tableMeta.value?.tableName || "export", "sql", { preferFallback: true }), "SQL", "sql", { exportId, operation: "sql-insert-all" });
|
await saveTextFile(content, exportFileName(tableMeta.value?.tableName || "export", "sql", { preferFallback: true }), "SQL", "sql", { exportId, operation: "sql-insert-all", autoOpenFolder: true });
|
||||||
logExportStage("done", { contentChars: content.length });
|
logExportStage("done", { contentChars: content.length });
|
||||||
toast(t("grid.exported"));
|
toast(t("grid.exported"));
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
@@ -1737,7 +1747,7 @@ export function useDataGridExport(options: UseDataGridExportOptions) {
|
|||||||
insertMode,
|
insertMode,
|
||||||
excludeColumns: sqlExportExcludedColumns(),
|
excludeColumns: sqlExportExcludedColumns(),
|
||||||
});
|
});
|
||||||
await saveTextFile(content, exportFileName("export-page", "sql", { page: true }), "SQL", "sql");
|
await saveTextFile(content, exportFileName("export-page", "sql", { page: true }), "SQL", "sql", { autoOpenFolder: true });
|
||||||
toast(t("grid.exported"));
|
toast(t("grid.exported"));
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
toast(t("grid.exportFailed", { message: translateBackendError(t, e) }), 5000);
|
toast(t("grid.exportFailed", { message: translateBackendError(t, e) }), 5000);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import * as api from "@/lib/backend/api";
|
|||||||
import { isTerminalTransferProgress } from "@/lib/backend/transferProgress";
|
import { isTerminalTransferProgress } from "@/lib/backend/transferProgress";
|
||||||
import { uuid } from "@/lib/common/utils";
|
import { uuid } from "@/lib/common/utils";
|
||||||
import { formatQueryDuration } from "@/lib/format/duration";
|
import { formatQueryDuration } from "@/lib/format/duration";
|
||||||
|
import { autoRevealExportedPathIfConfigured } from "@/lib/export/exportPath";
|
||||||
|
|
||||||
export type BackgroundTaskKind = "table-export" | "database-export" | "data-dictionary" | "sql-file" | "data-transfer" | "data-generation" | "multi-db-execution" | "schema-diff" | "data-compare";
|
export type BackgroundTaskKind = "table-export" | "database-export" | "data-dictionary" | "sql-file" | "data-transfer" | "data-generation" | "multi-db-execution" | "schema-diff" | "data-compare";
|
||||||
export type BackgroundTaskStatus = "Running" | "Writing" | "Cancelling" | "Done" | "Error" | "Cancelled";
|
export type BackgroundTaskStatus = "Running" | "Writing" | "Cancelling" | "Done" | "Error" | "Cancelled";
|
||||||
@@ -361,6 +362,9 @@ function finishDataTransferTask(task: ExportTask) {
|
|||||||
|
|
||||||
function finishExportTask(task: ExportTask) {
|
function finishExportTask(task: ExportTask) {
|
||||||
task.finishedAt ??= Date.now();
|
task.finishedAt ??= Date.now();
|
||||||
|
if (task.status === "Done" && (task.kind === "table-export" || task.kind === "database-export" || task.kind === "data-dictionary") && task.databaseExportSource !== "scheduled" && task.filePath) {
|
||||||
|
void autoRevealExportedPathIfConfigured(task.filePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implementation lives in @/lib/format/duration (shared with the DataGrid
|
// Implementation lives in @/lib/format/duration (shared with the DataGrid
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { copyToClipboard } from "@/lib/common/clipboard";
|
|||||||
import { effectiveDatabaseTypeForConnection } from "@/lib/database/jdbcDialect";
|
import { effectiveDatabaseTypeForConnection } from "@/lib/database/jdbcDialect";
|
||||||
import { gaussdbMTypeDisplayName } from "@/lib/table/postgresDataTypeHelp";
|
import { gaussdbMTypeDisplayName } from "@/lib/table/postgresDataTypeHelp";
|
||||||
import { joinExportedDdls } from "@/lib/export/ddlExport";
|
import { joinExportedDdls } from "@/lib/export/ddlExport";
|
||||||
import { promptExportSavePath } from "@/lib/export/exportPath";
|
import { autoRevealExportedPathIfConfigured, promptExportSavePath } from "@/lib/export/exportPath";
|
||||||
import { translateBackendError } from "@/i18n/backend-errors";
|
import { translateBackendError } from "@/i18n/backend-errors";
|
||||||
import { sidebarStructureExportTargets, sidebarTableDataExportTargets } from "@/lib/sidebar/sidebarExportRuntime";
|
import { sidebarStructureExportTargets, sidebarTableDataExportTargets } from "@/lib/sidebar/sidebarExportRuntime";
|
||||||
import { fetchTableDataForExport } from "@/lib/table/tableDataExport";
|
import { fetchTableDataForExport } from "@/lib/table/tableDataExport";
|
||||||
@@ -386,6 +386,7 @@ export function useSidebarTreeExportRuntime(options: SidebarTreeExportRuntimeOpt
|
|||||||
if (!outputPath) return false;
|
if (!outputPath) return false;
|
||||||
await api.exportQueryResultJson(outputPath, result.columns, result.rows);
|
await api.exportQueryResultJson(outputPath, result.columns, result.rows);
|
||||||
if (!suppressDoneToast) toast(t("grid.exported"));
|
if (!suppressDoneToast) toast(t("grid.exported"));
|
||||||
|
void autoRevealExportedPathIfConfigured(outputPath);
|
||||||
return true;
|
return true;
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
toast(t("grid.exportFailed", { message: translateBackendError(t, error) }), 5000);
|
toast(t("grid.exportFailed", { message: translateBackendError(t, error) }), 5000);
|
||||||
|
|||||||
@@ -7697,6 +7697,8 @@ export default withEnglishFallback({
|
|||||||
preferredExportPathPlaceholder: "Təyin edilməyib (son ixrac yolunu istifadə edin)",
|
preferredExportPathPlaceholder: "Təyin edilməyib (son ixrac yolunu istifadə edin)",
|
||||||
preferredExportPathChoose: "Üstünlük verilən ixrac qovluğunu seçin",
|
preferredExportPathChoose: "Üstünlük verilən ixrac qovluğunu seçin",
|
||||||
preferredExportPathClear: "Üstünlük verilən ixrac yolunu təmizləyin",
|
preferredExportPathClear: "Üstünlük verilən ixrac yolunu təmizləyin",
|
||||||
|
autoOpenExportFolder: "İxracdan sonra qovluğu avtomatik aç",
|
||||||
|
autoOpenExportFolderDescription: "Məlumat ixracı uğurla başa çatdıqda fayl menecerində ixrac edilən faylın qovluğunu avtomatik açır.",
|
||||||
exportSection: "İxrac",
|
exportSection: "İxrac",
|
||||||
csvQuoteMode: "CSV sahələrinin dırnaqları",
|
csvQuoteMode: "CSV sahələrinin dırnaqları",
|
||||||
csvQuoteModeDescription: "CSV sahələrində qoşa dırnaqların necə istifadə olunacağını seçin.",
|
csvQuoteModeDescription: "CSV sahələrində qoşa dırnaqların necə istifadə olunacağını seçin.",
|
||||||
|
|||||||
@@ -8638,6 +8638,8 @@ export default {
|
|||||||
preferredExportPathPlaceholder: "Not set (use last export path)",
|
preferredExportPathPlaceholder: "Not set (use last export path)",
|
||||||
preferredExportPathChoose: "Choose preferred export directory",
|
preferredExportPathChoose: "Choose preferred export directory",
|
||||||
preferredExportPathClear: "Clear preferred export path",
|
preferredExportPathClear: "Clear preferred export path",
|
||||||
|
autoOpenExportFolder: "Auto-open folder after export",
|
||||||
|
autoOpenExportFolderDescription: "Automatically reveal and open the containing folder in the file manager after data export succeeds.",
|
||||||
exportSection: "Export",
|
exportSection: "Export",
|
||||||
csvQuoteMode: "CSV field quotes",
|
csvQuoteMode: "CSV field quotes",
|
||||||
csvQuoteModeDescription: "Choose how CSV fields use double quotes.",
|
csvQuoteModeDescription: "Choose how CSV fields use double quotes.",
|
||||||
|
|||||||
@@ -7928,6 +7928,8 @@ export default withEnglishFallback({
|
|||||||
preferredExportPathPlaceholder: "No establecido (usar última ruta)",
|
preferredExportPathPlaceholder: "No establecido (usar última ruta)",
|
||||||
preferredExportPathChoose: "Elegir directorio de exportación preferido",
|
preferredExportPathChoose: "Elegir directorio de exportación preferido",
|
||||||
preferredExportPathClear: "Borrar ruta de exportación preferida",
|
preferredExportPathClear: "Borrar ruta de exportación preferida",
|
||||||
|
autoOpenExportFolder: "Abrir carpeta automáticamente después de exportar",
|
||||||
|
autoOpenExportFolderDescription: "Abre y muestra automáticamente la carpeta que contiene el archivo exportado en el administrador de archivos tras completarse la exportación.",
|
||||||
exportSection: "Exportar",
|
exportSection: "Exportar",
|
||||||
csvQuoteMode: "Comillas de campos CSV",
|
csvQuoteMode: "Comillas de campos CSV",
|
||||||
csvQuoteModeDescription: "Elige cómo usar comillas dobles en los campos CSV.",
|
csvQuoteModeDescription: "Elige cómo usar comillas dobles en los campos CSV.",
|
||||||
|
|||||||
@@ -8422,6 +8422,8 @@ export default withEnglishFallback({
|
|||||||
preferredExportPathPlaceholder: "Belum diatur (gunakan jalur ekspor terakhir)",
|
preferredExportPathPlaceholder: "Belum diatur (gunakan jalur ekspor terakhir)",
|
||||||
preferredExportPathChoose: "Pilih direktori ekspor pilihan",
|
preferredExportPathChoose: "Pilih direktori ekspor pilihan",
|
||||||
preferredExportPathClear: "Hapus jalur ekspor pilihan",
|
preferredExportPathClear: "Hapus jalur ekspor pilihan",
|
||||||
|
autoOpenExportFolder: "Buka folder otomatis setelah ekspor",
|
||||||
|
autoOpenExportFolderDescription: "Buka dan tampilkan folder yang berisi berkas hasil ekspor secara otomatis di pengelola berkas setelah ekspor data berhasil.",
|
||||||
exportSection: "Ekspor",
|
exportSection: "Ekspor",
|
||||||
csvQuoteMode: "Tanda kutip bidang CSV",
|
csvQuoteMode: "Tanda kutip bidang CSV",
|
||||||
csvQuoteModeDescription: "Pilih bagaimana bidang CSV menggunakan tanda kutip ganda.",
|
csvQuoteModeDescription: "Pilih bagaimana bidang CSV menggunakan tanda kutip ganda.",
|
||||||
|
|||||||
@@ -7690,6 +7690,8 @@ export default withEnglishFallback({
|
|||||||
preferredExportPathPlaceholder: "Non impostato (usa l'ultimo percorso)",
|
preferredExportPathPlaceholder: "Non impostato (usa l'ultimo percorso)",
|
||||||
preferredExportPathChoose: "Scegli la directory di esportazione preferita",
|
preferredExportPathChoose: "Scegli la directory di esportazione preferita",
|
||||||
preferredExportPathClear: "Cancella il percorso di esportazione preferito",
|
preferredExportPathClear: "Cancella il percorso di esportazione preferito",
|
||||||
|
autoOpenExportFolder: "Apri cartella automaticamente dopo l'esportazione",
|
||||||
|
autoOpenExportFolderDescription: "Apre e mostra automaticamente la cartella contenente il file esportato nel file manager dopo il completamento dell'esportazione.",
|
||||||
exportSection: "Esportazione",
|
exportSection: "Esportazione",
|
||||||
csvQuoteMode: "Virgolette campi CSV",
|
csvQuoteMode: "Virgolette campi CSV",
|
||||||
csvQuoteModeDescription: "Scegli come usare le virgolette doppie nei campi CSV.",
|
csvQuoteModeDescription: "Scegli come usare le virgolette doppie nei campi CSV.",
|
||||||
|
|||||||
@@ -7686,6 +7686,8 @@ export default withEnglishFallback({
|
|||||||
preferredExportPathPlaceholder: "未設定(前回のパスを使用)",
|
preferredExportPathPlaceholder: "未設定(前回のパスを使用)",
|
||||||
preferredExportPathChoose: "優先エクスポートディレクトリを選択",
|
preferredExportPathChoose: "優先エクスポートディレクトリを選択",
|
||||||
preferredExportPathClear: "優先エクスポートパスをクリア",
|
preferredExportPathClear: "優先エクスポートパスをクリア",
|
||||||
|
autoOpenExportFolder: "エクスポート後に保存先フォルダーを開く",
|
||||||
|
autoOpenExportFolderDescription: "データエクスポート完了後、ファイルマネージャーで保存先フォルダーを自動的に開きます。",
|
||||||
exportSection: "エクスポート",
|
exportSection: "エクスポート",
|
||||||
csvQuoteMode: "CSV フィールドの引用符",
|
csvQuoteMode: "CSV フィールドの引用符",
|
||||||
csvQuoteModeDescription: "CSV フィールドを二重引用符で囲む方法を選択します。",
|
csvQuoteModeDescription: "CSV フィールドを二重引用符で囲む方法を選択します。",
|
||||||
|
|||||||
@@ -7511,6 +7511,8 @@ export default withEnglishFallback({
|
|||||||
preferredExportPathPlaceholder: "설정되지 않음 (마지막 내보내기 경로 사용)",
|
preferredExportPathPlaceholder: "설정되지 않음 (마지막 내보내기 경로 사용)",
|
||||||
preferredExportPathChoose: "기본 내보내기 디렉터리 선택",
|
preferredExportPathChoose: "기본 내보내기 디렉터리 선택",
|
||||||
preferredExportPathClear: "기본 내보내기 경로 지우기",
|
preferredExportPathClear: "기본 내보내기 경로 지우기",
|
||||||
|
autoOpenExportFolder: "내보내기 후 폴더 자동 열기",
|
||||||
|
autoOpenExportFolderDescription: "데이터 내보내기가 완료된 후 파일 관리자에서 저장된 폴더를 자동으로 엽니다.",
|
||||||
exportSection: "내보내기",
|
exportSection: "내보내기",
|
||||||
performanceSection: "성능",
|
performanceSection: "성능",
|
||||||
shortcutExecuteSql: "SQL 실행",
|
shortcutExecuteSql: "SQL 실행",
|
||||||
|
|||||||
@@ -7691,6 +7691,8 @@ export default withEnglishFallback({
|
|||||||
preferredExportPathPlaceholder: "Não definido (usar último caminho)",
|
preferredExportPathPlaceholder: "Não definido (usar último caminho)",
|
||||||
preferredExportPathChoose: "Escolher diretório de exportação preferencial",
|
preferredExportPathChoose: "Escolher diretório de exportação preferencial",
|
||||||
preferredExportPathClear: "Limpar caminho de exportação preferencial",
|
preferredExportPathClear: "Limpar caminho de exportação preferencial",
|
||||||
|
autoOpenExportFolder: "Abrir pasta automaticamente após exportar",
|
||||||
|
autoOpenExportFolderDescription: "Abre e revela automaticamente a pasta que contém o arquivo exportado no gerenciador de arquivos após a conclusão da exportação.",
|
||||||
exportSection: "Exportar",
|
exportSection: "Exportar",
|
||||||
csvQuoteMode: "Aspas dos campos CSV",
|
csvQuoteMode: "Aspas dos campos CSV",
|
||||||
csvQuoteModeDescription: "Escolha como usar aspas duplas nos campos CSV.",
|
csvQuoteModeDescription: "Escolha como usar aspas duplas nos campos CSV.",
|
||||||
|
|||||||
@@ -8942,6 +8942,8 @@ export default withEnglishFallback({
|
|||||||
preferredExportPathPlaceholder: "Не задан (использовать последний путь)",
|
preferredExportPathPlaceholder: "Не задан (использовать последний путь)",
|
||||||
preferredExportPathChoose: "Выбрать предпочтительный каталог экспорта",
|
preferredExportPathChoose: "Выбрать предпочтительный каталог экспорта",
|
||||||
preferredExportPathClear: "Очистить предпочтительный путь экспорта",
|
preferredExportPathClear: "Очистить предпочтительный путь экспорта",
|
||||||
|
autoOpenExportFolder: "Автоматически открывать папку после экспорта",
|
||||||
|
autoOpenExportFolderDescription: "Автоматически открывать папку с экспортированным файлом в файловом менеджере после завершения экспорта данных.",
|
||||||
exportSection: "Экспорт",
|
exportSection: "Экспорт",
|
||||||
csvQuoteMode: "Кавычки в полях CSV",
|
csvQuoteMode: "Кавычки в полях CSV",
|
||||||
csvQuoteModeDescription: "Выберите, как поля CSV используют двойные кавычки.",
|
csvQuoteModeDescription: "Выберите, как поля CSV используют двойные кавычки.",
|
||||||
|
|||||||
@@ -7599,6 +7599,8 @@ export default withEnglishFallback({
|
|||||||
preferredExportPathPlaceholder: "Ayarlanmadı (son dışa aktarma yolunu kullan)",
|
preferredExportPathPlaceholder: "Ayarlanmadı (son dışa aktarma yolunu kullan)",
|
||||||
preferredExportPathChoose: "Tercih edilen dışa aktarma dizinini seçin",
|
preferredExportPathChoose: "Tercih edilen dışa aktarma dizinini seçin",
|
||||||
preferredExportPathClear: "Tercih edilen dışa aktarma yolunu temizle",
|
preferredExportPathClear: "Tercih edilen dışa aktarma yolunu temizle",
|
||||||
|
autoOpenExportFolder: "Dışa aktardıktan sonra klasörü otomatik aç",
|
||||||
|
autoOpenExportFolderDescription: "Veri dışa aktarımı başarılı olduğunda dosya yöneticisinde dışa aktarılan dosyanın klasörünü otomatik olarak açar.",
|
||||||
exportSection: "Dışa Aktar",
|
exportSection: "Dışa Aktar",
|
||||||
csvQuoteMode: "CSV alan tırnakları",
|
csvQuoteMode: "CSV alan tırnakları",
|
||||||
csvQuoteModeDescription: "CSV alanlarının çift tırnağı nasıl kullanacağını seçin.",
|
csvQuoteModeDescription: "CSV alanlarının çift tırnağı nasıl kullanacağını seçin.",
|
||||||
|
|||||||
@@ -8621,6 +8621,8 @@ export default withEnglishFallback({
|
|||||||
preferredExportPathPlaceholder: "未设置(自动使用上次导出路径)",
|
preferredExportPathPlaceholder: "未设置(自动使用上次导出路径)",
|
||||||
preferredExportPathChoose: "选择首选导出目录",
|
preferredExportPathChoose: "选择首选导出目录",
|
||||||
preferredExportPathClear: "清除首选导出路径",
|
preferredExportPathClear: "清除首选导出路径",
|
||||||
|
autoOpenExportFolder: "导出后自动打开所在文件夹",
|
||||||
|
autoOpenExportFolderDescription: "数据导出成功后,自动在系统文件管理器中打开并定位导出文件所在的文件夹。",
|
||||||
exportSection: "导出",
|
exportSection: "导出",
|
||||||
csvQuoteMode: "CSV 字段引号",
|
csvQuoteMode: "CSV 字段引号",
|
||||||
csvQuoteModeDescription: "选择 CSV 导出时字段使用双引号的方式。",
|
csvQuoteModeDescription: "选择 CSV 导出时字段使用双引号的方式。",
|
||||||
|
|||||||
@@ -7598,6 +7598,8 @@ export default withEnglishFallback({
|
|||||||
preferredExportPathPlaceholder: "未設定(自動使用上次匯出路徑)",
|
preferredExportPathPlaceholder: "未設定(自動使用上次匯出路徑)",
|
||||||
preferredExportPathChoose: "選擇首選匯出目錄",
|
preferredExportPathChoose: "選擇首選匯出目錄",
|
||||||
preferredExportPathClear: "清除首選匯出路徑",
|
preferredExportPathClear: "清除首選匯出路徑",
|
||||||
|
autoOpenExportFolder: "匯出後自動開啟所在資料夾",
|
||||||
|
autoOpenExportFolderDescription: "資料匯出成功後,自動在系統檔案管理器中開啟並定位匯出檔案所在的資料夾。",
|
||||||
shortcutUppercaseSelection: "選取內容轉為大寫",
|
shortcutUppercaseSelection: "選取內容轉為大寫",
|
||||||
shortcutLowercaseSelection: "選取內容轉為小寫",
|
shortcutLowercaseSelection: "選取內容轉為小寫",
|
||||||
shortcutToggleCaseSelection: "切換選取內容大小寫",
|
shortcutToggleCaseSelection: "切換選取內容大小寫",
|
||||||
|
|||||||
+111
-1
@@ -1,17 +1,48 @@
|
|||||||
// @vitest-environment happy-dom
|
// @vitest-environment happy-dom
|
||||||
|
|
||||||
|
import { createPinia, setActivePinia } from "pinia";
|
||||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
import { clearLastExportDirectory, getLastExportDirectory, getParentDirectory, isAbsolutePath, joinExportPath, LAST_EXPORT_DIRECTORY_STORAGE_KEY, promptExportSavePath, rememberLastExportPath, resolveExportDefaultPath, setLastExportDirectory } from "../exportPath";
|
import {
|
||||||
|
autoRevealExportedPathIfConfigured,
|
||||||
|
clearLastExportDirectory,
|
||||||
|
getLastExportDirectory,
|
||||||
|
getParentDirectory,
|
||||||
|
isAbsolutePath,
|
||||||
|
joinExportPath,
|
||||||
|
LAST_EXPORT_DIRECTORY_STORAGE_KEY,
|
||||||
|
promptExportSavePath,
|
||||||
|
rememberLastExportPath,
|
||||||
|
resolveExportDefaultPath,
|
||||||
|
revealExportedPath,
|
||||||
|
setLastExportDirectory,
|
||||||
|
} from "../exportPath";
|
||||||
|
import { useSettingsStore } from "@/stores/settingsStore";
|
||||||
|
|
||||||
const mockSave = vi.fn();
|
const mockSave = vi.fn();
|
||||||
vi.mock("@tauri-apps/plugin-dialog", () => ({
|
vi.mock("@tauri-apps/plugin-dialog", () => ({
|
||||||
save: (args: unknown) => mockSave(args),
|
save: (args: unknown) => mockSave(args),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
const mockRevealPathInFileManager = vi.fn();
|
||||||
|
vi.mock("@/lib/backend/api", async (importOriginal) => {
|
||||||
|
const actual = await importOriginal<Record<string, unknown>>();
|
||||||
|
return {
|
||||||
|
...actual,
|
||||||
|
revealPathInFileManager: (...args: unknown[]) => mockRevealPathInFileManager(...args),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const mockIsTauriRuntime = vi.fn(() => true);
|
||||||
|
vi.mock("@/lib/backend/tauriRuntime", () => ({
|
||||||
|
isTauriRuntime: () => mockIsTauriRuntime(),
|
||||||
|
}));
|
||||||
|
|
||||||
describe("exportPath", () => {
|
describe("exportPath", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
mockSave.mockReset();
|
mockSave.mockReset();
|
||||||
|
mockRevealPathInFileManager.mockReset();
|
||||||
|
mockIsTauriRuntime.mockReturnValue(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("isAbsolutePath", () => {
|
describe("isAbsolutePath", () => {
|
||||||
@@ -163,4 +194,83 @@ describe("exportPath", () => {
|
|||||||
expect(getLastExportDirectory()).toBe("/existing/dir");
|
expect(getLastExportDirectory()).toBe("/existing/dir");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("revealExportedPath", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
mockRevealPathInFileManager.mockReset();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("ignores empty or whitespace path", async () => {
|
||||||
|
await revealExportedPath("");
|
||||||
|
await revealExportedPath(" ");
|
||||||
|
expect(mockRevealPathInFileManager).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("calls revealPathInFileManager and deduplicates rapid repeated calls within 2000ms", async () => {
|
||||||
|
let currentTime = 10_000;
|
||||||
|
const nowSpy = vi.spyOn(Date, "now").mockImplementation(() => currentTime);
|
||||||
|
|
||||||
|
await revealExportedPath(" /path/to/exported1.csv ");
|
||||||
|
expect(mockRevealPathInFileManager).toHaveBeenCalledTimes(1);
|
||||||
|
expect(mockRevealPathInFileManager).toHaveBeenCalledWith("/path/to/exported1.csv");
|
||||||
|
|
||||||
|
// Same path within 2000ms should be skipped
|
||||||
|
currentTime += 1000;
|
||||||
|
await revealExportedPath("/path/to/exported1.csv");
|
||||||
|
expect(mockRevealPathInFileManager).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
|
// Different path should be revealed immediately
|
||||||
|
currentTime += 100;
|
||||||
|
await revealExportedPath("/path/to/exported2.csv");
|
||||||
|
expect(mockRevealPathInFileManager).toHaveBeenCalledTimes(2);
|
||||||
|
expect(mockRevealPathInFileManager).toHaveBeenLastCalledWith("/path/to/exported2.csv");
|
||||||
|
|
||||||
|
// Same path after 2000ms should be revealed
|
||||||
|
currentTime += 2001;
|
||||||
|
await revealExportedPath("/path/to/exported2.csv");
|
||||||
|
expect(mockRevealPathInFileManager).toHaveBeenCalledTimes(3);
|
||||||
|
|
||||||
|
nowSpy.mockRestore();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("autoRevealExportedPathIfConfigured", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
setActivePinia(createPinia());
|
||||||
|
mockRevealPathInFileManager.mockReset();
|
||||||
|
mockIsTauriRuntime.mockReturnValue(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("returns false for empty or null paths", async () => {
|
||||||
|
expect(await autoRevealExportedPathIfConfigured(null)).toBe(false);
|
||||||
|
expect(await autoRevealExportedPathIfConfigured("")).toBe(false);
|
||||||
|
expect(await autoRevealExportedPathIfConfigured(" ")).toBe(false);
|
||||||
|
expect(mockRevealPathInFileManager).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("returns false when not running in Tauri", async () => {
|
||||||
|
mockIsTauriRuntime.mockReturnValue(false);
|
||||||
|
const settings = useSettingsStore();
|
||||||
|
settings.editorSettings.autoOpenExportFolder = true;
|
||||||
|
|
||||||
|
expect(await autoRevealExportedPathIfConfigured("/path/to/file.csv")).toBe(false);
|
||||||
|
expect(mockRevealPathInFileManager).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("returns false when autoOpenExportFolder setting is disabled", async () => {
|
||||||
|
const settings = useSettingsStore();
|
||||||
|
settings.editorSettings.autoOpenExportFolder = false;
|
||||||
|
|
||||||
|
expect(await autoRevealExportedPathIfConfigured("/path/to/file.csv")).toBe(false);
|
||||||
|
expect(mockRevealPathInFileManager).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("returns true and reveals path when setting is enabled in Tauri", async () => {
|
||||||
|
const settings = useSettingsStore();
|
||||||
|
settings.editorSettings.autoOpenExportFolder = true;
|
||||||
|
|
||||||
|
expect(await autoRevealExportedPathIfConfigured("/path/to/file_auto.csv")).toBe(true);
|
||||||
|
expect(mockRevealPathInFileManager).toHaveBeenCalledWith("/path/to/file_auto.csv");
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
@@ -106,3 +106,36 @@ export async function promptExportSavePath(options: { defaultFileName: string; f
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let lastRevealedPath = "";
|
||||||
|
let lastRevealedTime = 0;
|
||||||
|
|
||||||
|
export async function revealExportedPath(path: string): Promise<void> {
|
||||||
|
const trimmed = path?.trim();
|
||||||
|
if (!trimmed) return;
|
||||||
|
const now = Date.now();
|
||||||
|
if (trimmed === lastRevealedPath && now - lastRevealedTime < 2000) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lastRevealedPath = trimmed;
|
||||||
|
lastRevealedTime = now;
|
||||||
|
const { revealPathInFileManager } = await import("@/lib/backend/api");
|
||||||
|
await revealPathInFileManager(trimmed);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function autoRevealExportedPathIfConfigured(path: string | null | undefined): Promise<boolean> {
|
||||||
|
const trimmed = path?.trim();
|
||||||
|
if (!trimmed) return false;
|
||||||
|
const { isTauriRuntime } = await import("@/lib/backend/tauriRuntime");
|
||||||
|
if (!isTauriRuntime()) return false;
|
||||||
|
try {
|
||||||
|
const { getActivePinia } = await import("pinia");
|
||||||
|
if (!getActivePinia()) return false;
|
||||||
|
const { useSettingsStore } = await import("@/stores/settingsStore");
|
||||||
|
if (!useSettingsStore().editorSettings.autoOpenExportFolder) return false;
|
||||||
|
await revealExportedPath(trimmed);
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import { isTauriRuntime } from "@/lib/backend/tauriRuntime";
|
import { isTauriRuntime } from "@/lib/backend/tauriRuntime";
|
||||||
import { appendDebugLog, getBrowserMemorySnapshot, isDebugLoggingEnabled } from "@/lib/backend/debugLog";
|
import { appendDebugLog, getBrowserMemorySnapshot, isDebugLoggingEnabled } from "@/lib/backend/debugLog";
|
||||||
import { promptExportSavePath } from "./exportPath";
|
import { autoRevealExportedPathIfConfigured, promptExportSavePath } from "./exportPath";
|
||||||
|
|
||||||
export async function saveTextFile(content: string, defaultFileName: string, filterName: string, filterExt: string, diagnostics: { exportId?: string; operation?: string } = {}): Promise<boolean> {
|
export async function saveTextFile(content: string, defaultFileName: string, filterName: string, filterExt: string, diagnostics: { exportId?: string; operation?: string; autoOpenFolder?: boolean } = {}): Promise<boolean> {
|
||||||
const logSaveStage = (stage: string, details: Record<string, unknown> = {}) => {
|
const logSaveStage = (stage: string, details: Record<string, unknown> = {}) => {
|
||||||
if (!isDebugLoggingEnabled()) return;
|
if (!isDebugLoggingEnabled()) return;
|
||||||
appendDebugLog("info", `[DBX][export:save:${stage}]`, {
|
appendDebugLog("info", `[DBX][export:save:${stage}]`, {
|
||||||
@@ -25,6 +25,9 @@ export async function saveTextFile(content: string, defaultFileName: string, fil
|
|||||||
logSaveStage("dialog-result", { selected: !!path });
|
logSaveStage("dialog-result", { selected: !!path });
|
||||||
if (path) await writeTextFile(path, content);
|
if (path) await writeTextFile(path, content);
|
||||||
if (path) logSaveStage("write-done");
|
if (path) logSaveStage("write-done");
|
||||||
|
if (path && diagnostics.autoOpenFolder) {
|
||||||
|
void autoRevealExportedPathIfConfigured(path);
|
||||||
|
}
|
||||||
return Boolean(path);
|
return Boolean(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -134,6 +134,7 @@ export const EDITOR_SETTINGS_DRAFT_KEYS = [
|
|||||||
"redisDatabaseDisplayLimit",
|
"redisDatabaseDisplayLimit",
|
||||||
"exportBatchSize",
|
"exportBatchSize",
|
||||||
"preferredExportPath",
|
"preferredExportPath",
|
||||||
|
"autoOpenExportFolder",
|
||||||
"csvQuoteMode",
|
"csvQuoteMode",
|
||||||
"csvNullMode",
|
"csvNullMode",
|
||||||
"exportRowLimitEnabled",
|
"exportRowLimitEnabled",
|
||||||
|
|||||||
@@ -261,6 +261,7 @@ export const SETTINGS_SEARCH_DEFINITIONS: readonly SettingsSearchDefinition[] =
|
|||||||
{ id: "data-datetime-import-format", category: "data", titleKey: "settings.globalDateTimeImportFormat", descriptionKey: "settings.globalDateTimeImportFormatDescription", targetId: "data" },
|
{ id: "data-datetime-import-format", category: "data", titleKey: "settings.globalDateTimeImportFormat", descriptionKey: "settings.globalDateTimeImportFormatDescription", targetId: "data" },
|
||||||
{ id: "data-export", category: "data", titleKey: "settings.exportSection", targetId: "data" },
|
{ id: "data-export", category: "data", titleKey: "settings.exportSection", targetId: "data" },
|
||||||
{ id: "data-export-preferred-path", category: "data", titleKey: "settings.preferredExportPath", descriptionKey: "settings.preferredExportPathDescription", targetId: "data" },
|
{ id: "data-export-preferred-path", category: "data", titleKey: "settings.preferredExportPath", descriptionKey: "settings.preferredExportPathDescription", targetId: "data" },
|
||||||
|
{ id: "data-export-auto-open-folder", category: "data", titleKey: "settings.autoOpenExportFolder", descriptionKey: "settings.autoOpenExportFolderDescription", targetId: "data", visible: desktopOnly },
|
||||||
{ id: "data-export-batch", category: "data", titleKey: "settings.exportBatchSize", descriptionKey: "settings.exportBatchSizeDescription", targetId: "data" },
|
{ id: "data-export-batch", category: "data", titleKey: "settings.exportBatchSize", descriptionKey: "settings.exportBatchSizeDescription", targetId: "data" },
|
||||||
{ id: "data-export-row-limit-enabled", category: "data", titleKey: "settings.exportRowLimitEnabled", descriptionKey: "settings.exportRowLimitEnabledDescription", targetId: "data" },
|
{ id: "data-export-row-limit-enabled", category: "data", titleKey: "settings.exportRowLimitEnabled", descriptionKey: "settings.exportRowLimitEnabledDescription", targetId: "data" },
|
||||||
{ id: "data-export-row-limit", category: "data", titleKey: "settings.exportRowLimit", descriptionKey: "settings.exportRowLimitDescription", targetId: "data" },
|
{ id: "data-export-row-limit", category: "data", titleKey: "settings.exportRowLimit", descriptionKey: "settings.exportRowLimitDescription", targetId: "data" },
|
||||||
|
|||||||
@@ -189,6 +189,7 @@ const SETTINGS_TRANSFER_CATEGORY_KEYS: Record<SettingsTransferCategoryId, readon
|
|||||||
"redisDatabaseDisplayLimit",
|
"redisDatabaseDisplayLimit",
|
||||||
"exportBatchSize",
|
"exportBatchSize",
|
||||||
"preferredExportPath",
|
"preferredExportPath",
|
||||||
|
"autoOpenExportFolder",
|
||||||
"csvQuoteMode",
|
"csvQuoteMode",
|
||||||
"csvNullMode",
|
"csvNullMode",
|
||||||
"exportRowLimitEnabled",
|
"exportRowLimitEnabled",
|
||||||
|
|||||||
@@ -1066,6 +1066,23 @@ describe("normalizeEditorSettings - preferredExportPath", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("normalizeEditorSettings - autoOpenExportFolder", () => {
|
||||||
|
it("defaults autoOpenExportFolder to false", () => {
|
||||||
|
expect(normalizeEditorSettings({}).autoOpenExportFolder).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("preserves boolean values", () => {
|
||||||
|
expect(normalizeEditorSettings({ autoOpenExportFolder: true }).autoOpenExportFolder).toBe(true);
|
||||||
|
expect(normalizeEditorSettings({ autoOpenExportFolder: false }).autoOpenExportFolder).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("falls back to default for non-boolean values", () => {
|
||||||
|
expect(normalizeEditorSettings({ autoOpenExportFolder: "true" } as any).autoOpenExportFolder).toBe(false);
|
||||||
|
expect(normalizeEditorSettings({ autoOpenExportFolder: null } as any).autoOpenExportFolder).toBe(false);
|
||||||
|
expect(normalizeEditorSettings({ autoOpenExportFolder: 1 } as any).autoOpenExportFolder).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// --- Helpers for Pinia store tests ---
|
// --- Helpers for Pinia store tests ---
|
||||||
|
|
||||||
function makeTestConfig(overrides: Partial<AiConfigItem> & { id: string }): AiConfigItem {
|
function makeTestConfig(overrides: Partial<AiConfigItem> & { id: string }): AiConfigItem {
|
||||||
@@ -1737,6 +1754,20 @@ describe("settingsStore persisted settings initialization", () => {
|
|||||||
expect(store.editorSettings.preferredExportPath).toBe("/custom/export/dir");
|
expect(store.editorSettings.preferredExportPath).toBe("/custom/export/dir");
|
||||||
expect(saveEditorSettings).toHaveBeenCalledWith(expect.objectContaining({ preferredExportPath: "/custom/export/dir" }));
|
expect(saveEditorSettings).toHaveBeenCalledWith(expect.objectContaining({ preferredExportPath: "/custom/export/dir" }));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("persists autoOpenExportFolder update", async () => {
|
||||||
|
const loadEditorSettings = vi.fn().mockResolvedValue({ autoOpenExportFolder: false });
|
||||||
|
const saveEditorSettings = vi.fn().mockResolvedValue(undefined);
|
||||||
|
vi.doMock("@/lib/backend/api", () => ({ loadEditorSettings, saveEditorSettings }));
|
||||||
|
|
||||||
|
const { useSettingsStore } = await import("@/stores/settingsStore");
|
||||||
|
const store = useSettingsStore();
|
||||||
|
await store.initEditorSettings();
|
||||||
|
|
||||||
|
await store.updateEditorSettingsAndPersist({ autoOpenExportFolder: true });
|
||||||
|
expect(store.editorSettings.autoOpenExportFolder).toBe(true);
|
||||||
|
expect(saveEditorSettings).toHaveBeenCalledWith(expect.objectContaining({ autoOpenExportFolder: true }));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("settingsStore editor settings persistence", () => {
|
describe("settingsStore editor settings persistence", () => {
|
||||||
|
|||||||
@@ -1063,6 +1063,7 @@ export interface EditorSettings {
|
|||||||
tableColumnTemplateFields: string[];
|
tableColumnTemplateFields: string[];
|
||||||
exportBatchSize: number;
|
exportBatchSize: number;
|
||||||
preferredExportPath: string;
|
preferredExportPath: string;
|
||||||
|
autoOpenExportFolder: boolean;
|
||||||
csvQuoteMode: CsvQuoteMode;
|
csvQuoteMode: CsvQuoteMode;
|
||||||
csvNullMode: CsvNullMode;
|
csvNullMode: CsvNullMode;
|
||||||
/** Global Redis key-search templates; overridden by non-empty connection templates. */
|
/** Global Redis key-search templates; overridden by non-empty connection templates. */
|
||||||
@@ -1368,6 +1369,7 @@ export const DEFAULT_EDITOR_SETTINGS: EditorSettings = {
|
|||||||
tableColumnTemplateFields: [...DEFAULT_TABLE_COLUMN_TEMPLATE_FIELDS],
|
tableColumnTemplateFields: [...DEFAULT_TABLE_COLUMN_TEMPLATE_FIELDS],
|
||||||
exportBatchSize: 2000,
|
exportBatchSize: 2000,
|
||||||
preferredExportPath: "",
|
preferredExportPath: "",
|
||||||
|
autoOpenExportFolder: false,
|
||||||
csvQuoteMode: DEFAULT_CSV_QUOTE_MODE,
|
csvQuoteMode: DEFAULT_CSV_QUOTE_MODE,
|
||||||
csvNullMode: DEFAULT_CSV_NULL_MODE,
|
csvNullMode: DEFAULT_CSV_NULL_MODE,
|
||||||
redisKeyTemplates: [],
|
redisKeyTemplates: [],
|
||||||
@@ -2025,6 +2027,7 @@ export function normalizeEditorSettings(settings: Partial<EditorSettings>, exist
|
|||||||
tableColumnTemplateFields: normalizeTableColumnTemplateFields(settings.tableColumnTemplateFields),
|
tableColumnTemplateFields: normalizeTableColumnTemplateFields(settings.tableColumnTemplateFields),
|
||||||
exportBatchSize: typeof settings.exportBatchSize === "number" && settings.exportBatchSize >= 100 && settings.exportBatchSize <= 100000 ? Math.round(settings.exportBatchSize) : DEFAULT_EDITOR_SETTINGS.exportBatchSize,
|
exportBatchSize: typeof settings.exportBatchSize === "number" && settings.exportBatchSize >= 100 && settings.exportBatchSize <= 100000 ? Math.round(settings.exportBatchSize) : DEFAULT_EDITOR_SETTINGS.exportBatchSize,
|
||||||
preferredExportPath: typeof settings.preferredExportPath === "string" ? settings.preferredExportPath.trim() : DEFAULT_EDITOR_SETTINGS.preferredExportPath,
|
preferredExportPath: typeof settings.preferredExportPath === "string" ? settings.preferredExportPath.trim() : DEFAULT_EDITOR_SETTINGS.preferredExportPath,
|
||||||
|
autoOpenExportFolder: typeof settings.autoOpenExportFolder === "boolean" ? settings.autoOpenExportFolder : DEFAULT_EDITOR_SETTINGS.autoOpenExportFolder,
|
||||||
csvQuoteMode: normalizeCsvQuoteMode(settings.csvQuoteMode),
|
csvQuoteMode: normalizeCsvQuoteMode(settings.csvQuoteMode),
|
||||||
csvNullMode: normalizeCsvNullMode(settings.csvNullMode),
|
csvNullMode: normalizeCsvNullMode(settings.csvNullMode),
|
||||||
redisKeyTemplates: normalizeRedisKeyTemplates(settings.redisKeyTemplates),
|
redisKeyTemplates: normalizeRedisKeyTemplates(settings.redisKeyTemplates),
|
||||||
@@ -2852,6 +2855,7 @@ export const useSettingsStore = defineStore("settings", () => {
|
|||||||
if (partial.tableColumnTemplateFields !== undefined) editorSettings.value.tableColumnTemplateFields = normalizeTableColumnTemplateFields(partial.tableColumnTemplateFields);
|
if (partial.tableColumnTemplateFields !== undefined) editorSettings.value.tableColumnTemplateFields = normalizeTableColumnTemplateFields(partial.tableColumnTemplateFields);
|
||||||
if (partial.exportBatchSize !== undefined) editorSettings.value.exportBatchSize = Math.min(100000, Math.max(100, Math.round(partial.exportBatchSize)));
|
if (partial.exportBatchSize !== undefined) editorSettings.value.exportBatchSize = Math.min(100000, Math.max(100, Math.round(partial.exportBatchSize)));
|
||||||
if (partial.preferredExportPath !== undefined) editorSettings.value.preferredExportPath = typeof partial.preferredExportPath === "string" ? partial.preferredExportPath.trim() : "";
|
if (partial.preferredExportPath !== undefined) editorSettings.value.preferredExportPath = typeof partial.preferredExportPath === "string" ? partial.preferredExportPath.trim() : "";
|
||||||
|
if (partial.autoOpenExportFolder !== undefined) editorSettings.value.autoOpenExportFolder = partial.autoOpenExportFolder === true;
|
||||||
if (partial.csvQuoteMode !== undefined) editorSettings.value.csvQuoteMode = normalizeCsvQuoteMode(partial.csvQuoteMode);
|
if (partial.csvQuoteMode !== undefined) editorSettings.value.csvQuoteMode = normalizeCsvQuoteMode(partial.csvQuoteMode);
|
||||||
if (partial.csvNullMode !== undefined) editorSettings.value.csvNullMode = normalizeCsvNullMode(partial.csvNullMode);
|
if (partial.csvNullMode !== undefined) editorSettings.value.csvNullMode = normalizeCsvNullMode(partial.csvNullMode);
|
||||||
if (partial.redisKeyTemplates !== undefined) editorSettings.value.redisKeyTemplates = normalizeRedisKeyTemplates(partial.redisKeyTemplates);
|
if (partial.redisKeyTemplates !== undefined) editorSettings.value.redisKeyTemplates = normalizeRedisKeyTemplates(partial.redisKeyTemplates);
|
||||||
|
|||||||
Reference in new issue
Block a user