diff --git a/apps/desktop/src/components/layout/ContentArea.vue b/apps/desktop/src/components/layout/ContentArea.vue index e5af3cdbf1..41d2dc4a26 100644 --- a/apps/desktop/src/components/layout/ContentArea.vue +++ b/apps/desktop/src/components/layout/ContentArea.vue @@ -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({ {{ t("tableToolbox.generateData") }} - + {{ t("tableToolbox.importData") }} diff --git a/apps/desktop/src/components/layout/__tests__/ContentArea.tableImportEntry.spec.ts b/apps/desktop/src/components/layout/__tests__/ContentArea.tableImportEntry.spec.ts new file mode 100644 index 0000000000..f476e24e0b --- /dev/null +++ b/apps/desktop/src/components/layout/__tests__/ContentArea.tableImportEntry.spec.ts @@ -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(" { + for (const surface of TABLE_IMPORT_ENTRY_SURFACES) { + expect(read(surface), surface).toContain("supportsTableImport"); + } + }); +});