fix(grid): keep filters when refreshing restored table tabs
This commit is contained in:
1 parent
cd8300c3f5
commit
aa637b2d90
5 files changed
+101
-4
No files matched your search
@@ -2,7 +2,7 @@
|
||||
import { computed, ref, defineAsyncComponent, watch, nextTick, onMounted, onUnmounted } from "vue";
|
||||
import { safeLocalStorageGet, safeLocalStorageSet } from "@/lib/backend/safeStorage";
|
||||
import { appendDebugLog, isDebugLoggingEnabled } from "@/lib/backend/debugLog";
|
||||
import { canReloadUnavailableDataTab } from "@/lib/table/tableDataRefresh";
|
||||
import { canReloadUnavailableDataTab, restoredDataTabReloadFilters } from "@/lib/table/tableDataRefresh";
|
||||
import { defaultViewForResult } from "@/lib/query/queryResultDefaultView";
|
||||
import { isQueryExecutionErrorResult } from "@/lib/query/queryResultError";
|
||||
import { batchSqlRecoveryState, type BatchSqlRecoveryAction } from "@/lib/query/batchSqlRecovery";
|
||||
@@ -916,6 +916,11 @@ function refreshQueryEditorCompletionCache(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
function reloadUnavailableDataTab() {
|
||||
const { whereInput, orderBy } = restoredDataTabReloadFilters(props.activeTab);
|
||||
emit("reload", undefined, undefined, whereInput, orderBy);
|
||||
}
|
||||
|
||||
function refreshData(): boolean {
|
||||
// Reuse ObjectBrowser's reload path so schema reloads and stale object-response guards stay intact.
|
||||
if (props.activeTab.mode === "objects") return objectBrowserRef.value?.refresh?.() ?? false;
|
||||
@@ -927,7 +932,7 @@ function refreshData(): boolean {
|
||||
if (props.activeTab.mode === "databases") return databaseBrowserRef.value?.refresh?.() ?? false;
|
||||
// Restored data tabs intentionally omit row data, so refresh must work before DataGrid mounts.
|
||||
if (canReloadUnavailableDataTab(props.activeTab)) {
|
||||
emit("reload");
|
||||
reloadUnavailableDataTab();
|
||||
return true;
|
||||
}
|
||||
if (activeElasticsearchJsonResponse.value) {
|
||||
@@ -2220,7 +2225,7 @@ defineExpose({
|
||||
<kbd v-for="key in modRKeys" :key="key" class="min-w-5 rounded border border-border/60 bg-muted/50 px-1.5 py-0.5 text-center font-mono text-[12px] leading-none text-muted-foreground shadow-xs">{{ key }}</kbd>
|
||||
<span>{{ t("grid.dataUnavailableHintSuffix") }}</span>
|
||||
</div>
|
||||
<Button variant="outline" size="sm" class="h-7 gap-1.5" @click="emit('reload')">
|
||||
<Button variant="outline" size="sm" class="h-7 gap-1.5" @click="reloadUnavailableDataTab()">
|
||||
<RefreshCcw class="h-3.5 w-3.5" />
|
||||
{{ t("grid.refresh") }}
|
||||
</Button>
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
const contentAreaSource = readFileSync(new URL("../ContentArea.vue", import.meta.url), "utf8");
|
||||
|
||||
describe("ContentArea restored data-tab refresh", () => {
|
||||
it("routes both no-data refresh entries through the filter-preserving helper (#7963)", () => {
|
||||
// 裸 emit("reload") 会让 onReloadData 把缺省的 whereInput/orderBy 当成
|
||||
// “用户已清空”,刷新后退回整张表的数据。
|
||||
expect(contentAreaSource).not.toContain(`@click="emit('reload')"`);
|
||||
expect(contentAreaSource).not.toMatch(/\bemit\("reload"\)\s*;/);
|
||||
expect(contentAreaSource).toContain(`@click="reloadUnavailableDataTab()"`);
|
||||
expect(contentAreaSource).toContain("reloadUnavailableDataTab();");
|
||||
});
|
||||
|
||||
it("passes the restored tab's own WHERE/ORDER BY into the reload event", () => {
|
||||
expect(contentAreaSource).toContain("const { whereInput, orderBy } = restoredDataTabReloadFilters(props.activeTab);");
|
||||
expect(contentAreaSource).toContain(`emit("reload", undefined, undefined, whereInput, orderBy);`);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user