mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-20 00:17:44 +00:00
fix(import): hide the data-tab import entry for unsupported engines
This commit is contained in:
@@ -157,6 +157,7 @@ import { dataTabExecutionDatabase } from "@/lib/table/dataTabExecutionDatabase";
|
||||
import { formatShortcut } from "@/lib/editor/shortcutRegistry";
|
||||
import type { CodeMirrorSqlDialectName } from "@/lib/editor/codemirrorSqlDialect";
|
||||
import { codeMirrorSqlDialect, codeMirrorSqlDialectForConnection, effectiveDatabaseTypeForConnection } from "@/lib/database/jdbcDialect";
|
||||
import { supportsTableImport } from "@/lib/database/databaseFeatureSupport";
|
||||
import { chartableColumnIndexes } from "@/lib/dataGrid/chartData";
|
||||
import { elasticsearchJsonResponseForResult } from "@/lib/elasticsearch/elasticsearchJsonResponse";
|
||||
import { elasticsearchProfileBodyForResult, parseElasticsearchProfile } from "@/lib/elasticsearch/elasticsearchProfile";
|
||||
@@ -337,6 +338,8 @@ const activeResultConnectionId = computed(() => activeResultExecutionTarget.valu
|
||||
const activeResultDatabase = computed(() => activeResultExecutionTarget.value?.database ?? props.activeTab.database);
|
||||
const activeResultSchema = computed(() => activeResultExecutionTarget.value?.schema ?? props.activeTab.schema);
|
||||
const activeEffectiveDatabaseType = computed(() => effectiveDatabaseTypeForConnection(activeResultConnection.value));
|
||||
// 表数据工具箱的「导入数据」与侧边栏、对象浏览器共用同一条能力判断:未适配导入的引擎(如 HANA)不出现入口。
|
||||
const canOpenTableImport = computed(() => supportsTableImport(activeEffectiveDatabaseType.value));
|
||||
const activeVectorConnection = computed(() => connectionStore.getConfig(props.activeTab.connectionId) ?? props.activeConnection);
|
||||
const activeDataTabExecutionDatabase = computed(() => dataTabExecutionDatabase(props.activeConnection, props.activeTab.database, activeDataTabTableMeta.value?.catalog));
|
||||
const activeProductionContext = computed(() => productionContextForDatabase(props.activeConnection, props.activeTab.database));
|
||||
@@ -2079,7 +2082,7 @@ defineExpose({
|
||||
<Database class="h-4 w-4" />
|
||||
{{ t("tableToolbox.generateData") }}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem class="gap-2" @click="handleTableImport">
|
||||
<DropdownMenuItem v-if="canOpenTableImport" class="gap-2" @click="handleTableImport">
|
||||
<Download class="h-4 w-4" />
|
||||
{{ t("tableToolbox.importData") }}
|
||||
</DropdownMenuItem>
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
function read(relativePath: string) {
|
||||
return readFileSync(new URL(relativePath, import.meta.url), "utf8");
|
||||
}
|
||||
|
||||
// 能打开「导入表数据」向导的三个入口。侧边栏的守卫在菜单宿主(SidebarTreeRuntimeHost.vue)里,
|
||||
// 写入函数 composables/useSidebarTreeToolRuntime.ts 本身不带守卫,所以这里列的是入口界面而不是写入点。
|
||||
const TABLE_IMPORT_ENTRY_SURFACES = ["../ContentArea.vue", "../../objects/ObjectBrowser.vue", "../../sidebar/SidebarTreeRuntimeHost.vue"];
|
||||
|
||||
describe("ContentArea table import entry", () => {
|
||||
it("gates the data-tab toolbox import item on the shared capability check", () => {
|
||||
const source = read("../ContentArea.vue");
|
||||
// HANA 的能力清单是 tableImport:false。入口不跟能力走时,向导仍能打开并停在「选项」步:
|
||||
// 目标表字段元数据取不回来,下一步恒为禁用(QA #hana-import 的复现路径)。
|
||||
expect(source).toContain("const canOpenTableImport = computed(");
|
||||
expect(source).toContain("supportsTableImport(activeEffectiveDatabaseType.value)");
|
||||
|
||||
const item = source.indexOf('t("tableToolbox.importData")');
|
||||
expect(item).toBeGreaterThan(-1);
|
||||
const openTag = source.lastIndexOf("<DropdownMenuItem", item);
|
||||
expect(openTag).toBeGreaterThan(-1);
|
||||
expect(source.slice(openTag, item)).toContain('v-if="canOpenTableImport"');
|
||||
});
|
||||
|
||||
it("keeps every entry surface consulting the same capability", () => {
|
||||
for (const surface of TABLE_IMPORT_ENTRY_SURFACES) {
|
||||
expect(read(surface), surface).toContain("supportsTableImport");
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user