From 8968974f423eb6a9299b727285a1ab12a7868706 Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Fri, 27 Nov 2026 03:50:44 +0800 Subject: [PATCH 1/2] feat(database): side panels, data extractor and Export Table to Clipboard in the grid's context menu (#6247) The grid's context menu gets Show Record View, Open in Value Editor and Show Aggregate View (checked while shown; the shown one hides it), the toolbar's data extractor as a submenu, and Export Table to Clipboard, which copies the whole result or table page through that extractor (whole values, as Export). Part of #6144 --- src/features/database/DataView.tsx | 58 ++++++++++++++++++++- src/features/database/Grid.test.tsx | 72 +++++++++++++++++++++++++++ src/features/database/ResultsView.tsx | 22 ++++---- src/features/database/TableEditor.tsx | 10 ++++ src/platform/locales/text/en.json | 7 ++- src/platform/locales/text/ru.json | 7 ++- src/platform/locales/text/tr.json | 7 ++- src/platform/locales/text/zh-TW.json | 7 ++- src/platform/locales/text/zh.json | 7 ++- 9 files changed, 179 insertions(+), 18 deletions(-) diff --git a/src/features/database/DataView.tsx b/src/features/database/DataView.tsx index d413e9f571..e67ba79764 100644 --- a/src/features/database/DataView.tsx +++ b/src/features/database/DataView.tsx @@ -70,6 +70,56 @@ export function ExtractorSelect({ value, onChange }: { value: ExportFormat; onCh export const copyFormatOf = (extractor: ExportFormat): CopyFormat => extractor === "csv" ? "csv" : extractor === "onerow" ? "onerow" : "tsv"; +/** The toolbar's extractor; `table` is the whole table to export (`null`: nothing, already reported). */ +export interface ExtractorMenu { + value: ExportFormat; + onChange: (f: ExportFormat) => void; + table: () => ExportData | null | Promise; +} + +const PANEL_ENTRIES: ReadonlyArray<{ panel: DataPanel; label: string }> = [ + { panel: "record", label: "Show Record View" }, + { panel: "value", label: "Open in Value Editor" }, + { panel: "aggregates", label: "Show Aggregate View" }, +]; + +/** + * The view's entries of the grid's context menu (DataGrip's): the side panels, checked while + * shown, then the toolbar's extractor and Export Table to Clipboard when the view has them. + */ +export function viewMenu( + panel: DataPanel | null, + onPanelChange: (panel: DataPanel | null) => void, + extractor?: ExtractorMenu, +): MenuItem[] { + const items: MenuItem[] = PANEL_ENTRIES.map(({ panel: p, label }) => ({ + label, + checked: panel === p, + run: () => onPanelChange(panel === p ? null : p), + })); + if (!extractor) return items; + return [ + ...items, + { kind: "separator" }, + { + label: "Data Extractor", + submenu: EXPORT_FORMATS.map((f) => ({ + label: f.label, + checked: f.id === extractor.value, + run: () => extractor.onChange(f.id), + })), + }, + { + label: "Export Table to Clipboard", + icon: "copy", + run: () => + void Promise.resolve(extractor.table()).then( + (data) => data && writeClipboardText(exportData(extractor.value, data)), + ), + }, + ]; +} + /** The Record / Value / Aggregates panel's toggle (IDEA's "Show Value Editor"). */ export function PanelToggle({ panel, onChange }: { panel: DataPanel | null; onChange: (p: DataPanel | null) => void }) { return ( @@ -117,6 +167,8 @@ export interface DataViewProps extends Pick< onPanelChange: (panel: DataPanel | null) => void; /** Plain ⌘C's copy format (the toolbar's extractor; TSV by default). */ copyFormat?: CopyFormat; + /** The toolbar's extractor, also offered in the grid's context menu with the whole table to copy. */ + extractor?: ExtractorMenu; /** The search bar is shown (the toolbar's search button, ⌘F in the grid). */ searchOpen?: boolean; onSearchOpenChange?: (open: boolean) => void; @@ -248,7 +300,11 @@ export function DataView(props: DataViewProps) { driver={props.driver} sort={sort} onSort={onSort} - rowMenu={props.rowMenu && ((rows) => props.rowMenu!(rows.map(at)))} + rowMenu={(rows) => { + const own = props.rowMenu?.(rows.map(at)) ?? []; + const view = viewMenu(panel, onPanelChange, props.extractor); + return own.length ? [...own, { kind: "separator" }, ...view] : view; + }} rowNumber={(r) => (props.firstRowNumber ?? 1) + at(r)} copyFormat={props.copyFormat} onSelectionChange={setRange} diff --git a/src/features/database/Grid.test.tsx b/src/features/database/Grid.test.tsx index 4d2aee9899..92765f14ef 100644 --- a/src/features/database/Grid.test.tsx +++ b/src/features/database/Grid.test.tsx @@ -1013,3 +1013,75 @@ describe("local filter (#6022)", () => { expect(cities()).toEqual(["Shanghai", "Beijing", "Shenzhen", "Hangzhou"]); }); }); + +describe("the data view's context menu (DataGrip)", () => { + const columns = [ + { name: "id", type: "int" }, + { name: "city", type: "text" }, + ]; + const data = [ + ["1", "Shanghai"], + ["2", "Beijing"], + ]; + const value = (r: number, c: number) => data[r]?.[c] ?? null; + + it("toggles the side panels, switches the extractor and exports the whole table to the clipboard", async () => { + const writeText = vi.fn(() => Promise.resolve()); + Object.defineProperty(navigator, "clipboard", { configurable: true, value: { writeText } }); + const onPanelChange = vi.fn(); + const onExtractor = vi.fn(); + const table = () => ({ columns, rows: data, table: "cities", driver: "postgres" as const }); + const { rerender } = render( + <> + + + , + ); + const open = () => { + fireEvent.mouseDown(screen.getAllByRole("gridcell")[0]!, { button: 0 }); + fireEvent.contextMenu(screen.getByRole("grid"), { clientX: 5, clientY: 5 }); + }; + open(); + expect(screen.getByRole("menuitemcheckbox", { name: /Open in Value Editor/ })).toHaveAttribute( + "aria-checked", + "true", + ); + fireEvent.click(screen.getByRole("menuitemcheckbox", { name: /Show Record View/ })); + expect(onPanelChange).toHaveBeenLastCalledWith("record"); + open(); + // The shown panel's entry hides it. + fireEvent.click(screen.getByRole("menuitemcheckbox", { name: /Open in Value Editor/ })); + expect(onPanelChange).toHaveBeenLastCalledWith(null); + + open(); + await act(async () => void fireEvent.click(screen.getByRole("menuitem", { name: /Export Table to Clipboard/ }))); + expect(writeText).toHaveBeenCalledWith(exportData("csv", table())); + + open(); + fireEvent.click(screen.getByRole("menuitem", { name: /Data Extractor/ })); + expect(screen.getByRole("menuitemcheckbox", { name: /^CSV/ })).toHaveAttribute("aria-checked", "true"); + fireEvent.click(screen.getByRole("menuitemcheckbox", { name: /SQL Inserts/ })); + expect(onExtractor).toHaveBeenCalledWith("sql"); + + // Without an extractor (a view with no toolbar one) only the panels are offered. + rerender( + <> + + + , + ); + open(); + expect(screen.queryByRole("menuitem", { name: /Export Table to Clipboard/ })).toBeNull(); + expect(screen.getByRole("menuitemcheckbox", { name: /Show Aggregate View/ })).toHaveAttribute( + "aria-checked", + "false", + ); + }); +}); diff --git a/src/features/database/ResultsView.tsx b/src/features/database/ResultsView.tsx index e352294f13..cecb862133 100644 --- a/src/features/database/ResultsView.tsx +++ b/src/features/database/ResultsView.tsx @@ -453,9 +453,9 @@ export function Result({ tab, onClose }: { tab: ResultTab; onClose?: () => void } }; - const showExport = async (at: { x: number; y: number }) => { - if (!r) return; - // What is exported or copied is the whole values, not the starts the page carries. + /** The result to export or copy: the whole values, not the starts the page carries. */ + const exportSource = async (): Promise => { + if (!r) return null; if (hasCutCells(r)) { try { await loadPage(tab); @@ -466,17 +466,14 @@ export function Result({ tab, onClose }: { tab: ResultTab; onClose?: () => void body: e instanceof Error ? e.message : String(e), key: "db-whole-value", }); - return; + return null; } } - showContextMenu( - at, - exportMenu( - { columns, rows: rowsOf(r), driver, table: queryTable(text, { driver }) }, - queryTable(text, { driver }), - extractor, - ), - ); + return { columns, rows: rowsOf(r), driver, table: queryTable(text, { driver }) }; + }; + const showExport = async (at: { x: number; y: number }) => { + const data = await exportSource(); + if (data) showContextMenu(at, exportMenu(data, queryTable(text, { driver }), extractor)); }; // Submit / Revert / Go to Column (⌘↩ / ⌥⌘Z / ⌘F12) reach the latest state through the handle, as in the table editor. @@ -635,6 +632,7 @@ export function Result({ tab, onClose }: { tab: ResultTab; onClose?: () => void panel={panel} onPanelChange={setPanel} copyFormat={copyFormatOf(extractor)} + extractor={{ value: extractor, onChange: setExtractor, table: exportSource }} searchOpen={searchOpen} onSearchOpenChange={setSearchOpen} firstRowNumber={(tab.page ?? 0) * (tab.pageSize ?? 0) + 1} diff --git a/src/features/database/TableEditor.tsx b/src/features/database/TableEditor.tsx index 2189cc033b..838a14bf4b 100644 --- a/src/features/database/TableEditor.tsx +++ b/src/features/database/TableEditor.tsx @@ -440,6 +440,16 @@ export function TableEditor({ input }: { input: EditorInput }) { panel={panel} onPanelChange={setPanel} copyFormat={copyFormatOf(extractor)} + extractor={{ + value: extractor, + onChange: setExtractor, + table: () => ({ + columns: gridColumns, + rows: page.result.rows, + table: ref.table, + driver: sourceById(ref.id)?.driver ?? "sqlite", + }), + }} searchOpen={searchOpen} onSearchOpenChange={setSearchOpen} firstRowNumber={offset + 1} diff --git a/src/platform/locales/text/en.json b/src/platform/locales/text/en.json index 055608e417..739dd43d95 100644 --- a/src/platform/locales/text/en.json +++ b/src/platform/locales/text/en.json @@ -4148,5 +4148,10 @@ "Semicolons": "Semicolons", "Quotes": "Quotes", "For the strings and imports the TypeScript server adds.": "For the strings and imports the TypeScript server adds.", - "The TypeScript server applies Spaces and Punctuation to Reformat Code and to the code it adds: quick fixes, imports, refactorings and organize imports. Files below a Prettier, Biome or oxfmt configuration are formatted by that tool. A .editorconfig's quote_type and ij_* properties come first. TSX files use the TypeScript settings, JSX files the JavaScript ones.": "The TypeScript server applies Spaces and Punctuation to Reformat Code and to the code it adds: quick fixes, imports, refactorings and organize imports. Files below a Prettier, Biome or oxfmt configuration are formatted by that tool. A .editorconfig's quote_type and ij_* properties come first. TSX files use the TypeScript settings, JSX files the JavaScript ones." + "The TypeScript server applies Spaces and Punctuation to Reformat Code and to the code it adds: quick fixes, imports, refactorings and organize imports. Files below a Prettier, Biome or oxfmt configuration are formatted by that tool. A .editorconfig's quote_type and ij_* properties come first. TSX files use the TypeScript settings, JSX files the JavaScript ones.": "The TypeScript server applies Spaces and Punctuation to Reformat Code and to the code it adds: quick fixes, imports, refactorings and organize imports. Files below a Prettier, Biome or oxfmt configuration are formatted by that tool. A .editorconfig's quote_type and ij_* properties come first. TSX files use the TypeScript settings, JSX files the JavaScript ones.", + "Show Record View": "Show Record View", + "Open in Value Editor": "Open in Value Editor", + "Show Aggregate View": "Show Aggregate View", + "Data Extractor": "Data Extractor", + "Export Table to Clipboard": "Export Table to Clipboard" } diff --git a/src/platform/locales/text/ru.json b/src/platform/locales/text/ru.json index 2300d21319..8dba0c9a02 100644 --- a/src/platform/locales/text/ru.json +++ b/src/platform/locales/text/ru.json @@ -10163,5 +10163,10 @@ "Allowed command pattern": "Шаблон разрешённой команды", "Blocked command pattern": "Шаблон заблокированной команды", "Mode applies to": "Режим действует для", - "Allow all optional permissions": "Разрешить все необязательные разрешения" + "Allow all optional permissions": "Разрешить все необязательные разрешения", + "Show Record View": "Показать представление записи", + "Open in Value Editor": "Открыть в редакторе значений", + "Show Aggregate View": "Показать агрегаты", + "Data Extractor": "Экстрактор данных", + "Export Table to Clipboard": "Экспортировать таблицу в буфер обмена" } diff --git a/src/platform/locales/text/tr.json b/src/platform/locales/text/tr.json index ac11dc1367..0948043be6 100644 --- a/src/platform/locales/text/tr.json +++ b/src/platform/locales/text/tr.json @@ -8824,5 +8824,10 @@ "Allowed command pattern": "İzin verilen komut kalıbı", "Blocked command pattern": "Engellenen komut kalıbı", "Mode applies to": "Modun uygulandığı yer", - "Allow all optional permissions": "Tüm isteğe bağlı izinlere izin ver" + "Allow all optional permissions": "Tüm isteğe bağlı izinlere izin ver", + "Show Record View": "Kayıt Görünümünü Göster", + "Open in Value Editor": "Değer Düzenleyicide Aç", + "Show Aggregate View": "Toplam Görünümünü Göster", + "Data Extractor": "Veri Çıkarıcı", + "Export Table to Clipboard": "Tabloyu Panoya Aktar" } diff --git a/src/platform/locales/text/zh-TW.json b/src/platform/locales/text/zh-TW.json index 1ef1355864..bec37c2387 100644 --- a/src/platform/locales/text/zh-TW.json +++ b/src/platform/locales/text/zh-TW.json @@ -9362,5 +9362,10 @@ "Allowed command pattern": "允許的命令模式", "Blocked command pattern": "封鎖的命令模式", "Mode applies to": "模式作用範圍", - "Allow all optional permissions": "允許全部可選權限" + "Allow all optional permissions": "允許全部可選權限", + "Show Record View": "顯示記錄檢視", + "Open in Value Editor": "在值編輯器中開啟", + "Show Aggregate View": "顯示彙總檢視", + "Data Extractor": "資料擷取器", + "Export Table to Clipboard": "將表格匯出到剪貼簿" } diff --git a/src/platform/locales/text/zh.json b/src/platform/locales/text/zh.json index ab7472554d..b47abbc63e 100644 --- a/src/platform/locales/text/zh.json +++ b/src/platform/locales/text/zh.json @@ -10592,5 +10592,10 @@ "Semicolons": "分号", "Quotes": "引号", "For the strings and imports the TypeScript server adds.": "用于 TypeScript 服务器添加的字符串和导入。", - "The TypeScript server applies Spaces and Punctuation to Reformat Code and to the code it adds: quick fixes, imports, refactorings and organize imports. Files below a Prettier, Biome or oxfmt configuration are formatted by that tool. A .editorconfig's quote_type and ij_* properties come first. TSX files use the TypeScript settings, JSX files the JavaScript ones.": "TypeScript 服务器将空格和标点设置用于重新格式化代码,以及它添加的代码:快速修复、导入、重构和优化导入。位于 Prettier、Biome 或 oxfmt 配置之下的文件由该工具格式化。.editorconfig 的 quote_type 和 ij_* 属性优先。TSX 文件使用 TypeScript 设置,JSX 文件使用 JavaScript 设置。" + "The TypeScript server applies Spaces and Punctuation to Reformat Code and to the code it adds: quick fixes, imports, refactorings and organize imports. Files below a Prettier, Biome or oxfmt configuration are formatted by that tool. A .editorconfig's quote_type and ij_* properties come first. TSX files use the TypeScript settings, JSX files the JavaScript ones.": "TypeScript 服务器将空格和标点设置用于重新格式化代码,以及它添加的代码:快速修复、导入、重构和优化导入。位于 Prettier、Biome 或 oxfmt 配置之下的文件由该工具格式化。.editorconfig 的 quote_type 和 ij_* 属性优先。TSX 文件使用 TypeScript 设置,JSX 文件使用 JavaScript 设置。", + "Show Record View": "显示记录视图", + "Open in Value Editor": "在值编辑器中打开", + "Show Aggregate View": "显示聚合视图", + "Data Extractor": "数据提取器", + "Export Table to Clipboard": "将表导出到剪贴板" } From fd4efff6e39f0fa2b9577b4864f06f24e5df7cdf Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Fri, 27 Nov 2026 03:54:09 +0800 Subject: [PATCH 2/2] feat(database): group and filter the Modify Table list (#6248) The Modify Table / Create Table list was one flat list of columns. It now groups Columns, Keys (the primary key as edited), Foreign Keys, Indexes and Triggers, each collapsible with its count, and a filter on its toolbar narrows the rows by name or type. The statements the dialog runs are unchanged. Fixes #6128 --- src/features/database/Database.module.css | 17 ++ src/features/database/ObjectDialogs.tsx | 152 ++++++++++++++++-- .../database/modifyTableGroups.test.tsx | 79 +++++++++ src/platform/locales/text/en.json | 6 +- src/platform/locales/text/ru.json | 6 +- src/platform/locales/text/tr.json | 6 +- src/platform/locales/text/zh-TW.json | 6 +- src/platform/locales/text/zh.json | 6 +- 8 files changed, 257 insertions(+), 21 deletions(-) create mode 100644 src/features/database/modifyTableGroups.test.tsx diff --git a/src/features/database/Database.module.css b/src/features/database/Database.module.css index f60c84d26a..c984087146 100644 --- a/src/features/database/Database.module.css +++ b/src/features/database/Database.module.css @@ -954,6 +954,23 @@ padding: 2px 4px; border-bottom: 1px solid var(--border); } +.modifyFilter { + flex: 1; + min-width: 0; +} +.modifyGroup { + display: flex; + align-items: center; + gap: var(--space-1); + height: 22px; + padding: 0 6px; + color: var(--fg-muted); + cursor: default; + white-space: nowrap; +} +.modifyGroup:hover { + color: var(--fg); +} .modifyList { flex: 1; overflow: auto; diff --git a/src/features/database/ObjectDialogs.tsx b/src/features/database/ObjectDialogs.tsx index 9232b5108c..02b982b7c3 100644 --- a/src/features/database/ObjectDialogs.tsx +++ b/src/features/database/ObjectDialogs.tsx @@ -4,7 +4,14 @@ * Preview of the SQL they run), Remove Data Source, Data Source from URL, and the Quick Documentation popup. */ import { useEffect, useMemo, useRef, useState } from "react"; -import { call, commands, type DbColumnInfo, type DbDriver, type DbTableGrant } from "@/platform/ipc"; +import { + call, + commands, + type DbColumnInfo, + type DbDriver, + type DbTableDetails, + type DbTableGrant, +} from "@/platform/ipc"; import { highlightInto } from "@/editor/lsp/markdown"; import { Button, @@ -14,6 +21,7 @@ import { Input, Popup, Icon, + SearchField, Select, T, Tabs, @@ -551,7 +559,8 @@ function ModifyTableDialog(props: ModifyProps) { if (table && !details) void loadDetails(id, schema, table); }, [details, id, schema, table]); if (!table) return ; - if (details?.status === "ok") return ; + if (details?.status === "ok") + return ; return ( { + const pk = columns.filter((c) => c.primaryKey && !c.dropped).map((c) => c.name); + const list = (names: readonly string[]) => `(${names.join(", ")})`; + return [ + { + id: "keys", + label: "Keys", + icon: "db-key", + rows: pk.length ? [{ key: "primary", name: "PRIMARY KEY", detail: list(pk) }] : [], + }, + { + id: "foreignKeys", + label: "Foreign Keys", + icon: "db-foreign-key", + rows: (details?.foreignKeys ?? []).map((fk, i) => ({ + key: `fk-${i}`, + name: list(fk.columns), + detail: `→ ${fk.refTable} ${list(fk.refColumns)}`, + })), + }, + { + id: "indexes", + label: "Indexes", + icon: "db-index", + rows: (details?.indexes ?? []).map((ix) => ({ + key: `ix-${ix.name}`, + name: ix.name, + detail: `${ix.unique ? "UNIQUE " : ""}${list(ix.columns)}`, + })), + }, + { + id: "triggers", + label: "Triggers", + icon: "db-trigger", + rows: (details?.triggers ?? []).map((t) => ({ + key: `tr-${t.name}`, + name: t.name, + detail: `${t.timing} ${t.events}`.toUpperCase(), + })), + }, + ]; +} + function ModifyTableForm({ id, schema, @@ -572,7 +638,8 @@ function ModifyTableForm({ focusColumn, addColumn, initial, -}: ModifyProps & { initial: DbColumnInfo[] | null }) { + details, +}: ModifyProps & { initial: DbColumnInfo[] | null; details?: DbTableDetails }) { const driver = driverOf(id); const [name, setName] = useState(table ?? "table_name"); const [columns, setColumns] = useState(() => { @@ -611,6 +678,28 @@ function ModifyTableForm({ } }; const locked = !!current && !canAlterColumn(driver, current); + // The list's filter (names and types) and its collapsed groups. + const [filter, setFilter] = useState(""); + const [collapsed, setCollapsed] = useState>(new Set()); + const query = filter.trim().toLowerCase(); + const matches = (...texts: string[]) => !query || texts.some((t) => t.toLowerCase().includes(query)); + const shownColumns = columns.filter((c) => matches(c.name, c.dataType)); + const groups = objectGroups(columns, details) + .map((g) => ({ ...g, rows: g.rows.filter((r) => matches(r.name, r.detail)) })) + .filter((g) => g.rows.length); + const toggleGroup = (group: string) => + setCollapsed((c) => { + const next = new Set(c); + if (!next.delete(group)) next.add(group); + return next; + }); + const groupHeader = (group: string, label: string, count: number) => ( +
toggleGroup(group)}> + + {tx(label)} + {count} +
+ ); const showGrants = !!table && grantsSupported(driver); const [tab, setTab] = useState<"columns" | "grants">("columns"); const title = table ? `Modify Table ${table}` : "Create Table"; @@ -672,21 +761,52 @@ function ModifyTableForm({ disabled={!current} onClick={remove} /> +
- {columns.map((c) => ( -
setSelected(c.key)} - > - - {c.name || ""} - {c.dataType} +
+ {groupHeader("columns", "Columns", shownColumns.length)} + {!collapsed.has("columns") && + shownColumns.map((c) => ( +
setSelected(c.key)} + > + + {c.name || ""} + {c.dataType} +
+ ))} +
+ {groups.map((g) => ( +
+ {groupHeader(g.id, g.label, g.rows.length)} + {!collapsed.has(g.id) && + g.rows.map((r) => ( +
+ + {r.name} + {r.detail} +
+ ))}
))}
diff --git a/src/features/database/modifyTableGroups.test.tsx b/src/features/database/modifyTableGroups.test.tsx new file mode 100644 index 0000000000..5438f27b01 --- /dev/null +++ b/src/features/database/modifyTableGroups.test.tsx @@ -0,0 +1,79 @@ +import { afterEach, describe, expect, it } from "vitest"; +import { fireEvent, render, screen, within } from "@testing-library/react"; +import { ObjectDialogs } from "./ObjectDialogs"; +import { detailsKey, openDialog, useDatabase } from "./store"; + +const column = (name: string, dataType: string, primaryKey = false) => ({ + name, + dataType, + nullable: !primaryKey, + default: null, + primaryKey, +}); + +function open() { + useDatabase.setState({ + details: { + [detailsKey("db", "main", "orders")]: { + status: "ok", + value: { + columns: [column("id", "integer", true), column("customer_id", "integer"), column("note", "text")], + indexes: [{ name: "orders_customer", unique: false, columns: ["customer_id"] }], + foreignKeys: [ + { + schema: "main", + table: "orders", + columns: ["customer_id"], + refSchema: "main", + refTable: "customers", + refColumns: ["id"], + }, + ], + triggers: [], + }, + }, + }, + } as never); + openDialog({ kind: "modifyTable", id: "db", schema: "main", table: "orders" }); + render(); +} + +const rows = (group: string) => + within(screen.getByRole("group", { name: group })) + .queryAllByRole("option") + .map((o) => o.textContent); + +afterEach(() => useDatabase.setState({ dialog: null, details: {} } as never)); + +describe("Modify Table's list (DataGrip)", () => { + it("groups the columns, keys, foreign keys and indexes, and filters them by name or type", () => { + open(); + expect(rows("Columns")).toEqual(["idinteger", "customer_idinteger", "notetext"]); + expect(rows("Keys")).toEqual(["PRIMARY KEY(id)"]); + expect(rows("Foreign Keys")).toEqual(["(customer_id)→ customers (id)"]); + expect(rows("Indexes")).toEqual(["orders_customer(customer_id)"]); + // No triggers: no group. + expect(screen.queryByRole("group", { name: "Triggers" })).toBeNull(); + + // A group collapses from its header. + fireEvent.mouseDown(within(screen.getByRole("group", { name: "Indexes" })).getByText("Indexes")); + expect(rows("Indexes")).toEqual([]); + + fireEvent.change(screen.getByRole("textbox", { name: "Filter columns" }), { target: { value: "TEXT" } }); + expect(rows("Columns")).toEqual(["notetext"]); + expect(screen.queryByRole("group", { name: "Foreign Keys" })).toBeNull(); + + fireEvent.change(screen.getByRole("textbox", { name: "Filter columns" }), { target: { value: "customer" } }); + expect(rows("Columns")).toEqual(["customer_idinteger"]); + expect(rows("Foreign Keys")).toEqual(["(customer_id)→ customers (id)"]); + }); + + it("keeps Keys on the primary key as edited in Create Table", () => { + openDialog({ kind: "modifyTable", id: "db", schema: "main", table: null }); + render(); + expect(rows("Keys")).toEqual(["PRIMARY KEY(id)"]); + fireEvent.click(screen.getByRole("button", { name: "Add Column" })); + fireEvent.click(screen.getByRole("checkbox", { name: "Primary key" })); + expect(rows("Keys")).toEqual(["PRIMARY KEY(id, column_2)"]); + }); +}); diff --git a/src/platform/locales/text/en.json b/src/platform/locales/text/en.json index 739dd43d95..63f9dc0623 100644 --- a/src/platform/locales/text/en.json +++ b/src/platform/locales/text/en.json @@ -4153,5 +4153,9 @@ "Open in Value Editor": "Open in Value Editor", "Show Aggregate View": "Show Aggregate View", "Data Extractor": "Data Extractor", - "Export Table to Clipboard": "Export Table to Clipboard" + "Export Table to Clipboard": "Export Table to Clipboard", + "Keys": "Keys", + "Triggers": "Triggers", + "Filter by name or type": "Filter by name or type", + "Filter columns": "Filter columns" } diff --git a/src/platform/locales/text/ru.json b/src/platform/locales/text/ru.json index 8dba0c9a02..f76521bbd3 100644 --- a/src/platform/locales/text/ru.json +++ b/src/platform/locales/text/ru.json @@ -10168,5 +10168,9 @@ "Open in Value Editor": "Открыть в редакторе значений", "Show Aggregate View": "Показать агрегаты", "Data Extractor": "Экстрактор данных", - "Export Table to Clipboard": "Экспортировать таблицу в буфер обмена" + "Export Table to Clipboard": "Экспортировать таблицу в буфер обмена", + "Keys": "Ключи", + "Triggers": "Триггеры", + "Filter by name or type": "Фильтр по имени или типу", + "Filter columns": "Фильтр столбцов" } diff --git a/src/platform/locales/text/tr.json b/src/platform/locales/text/tr.json index 0948043be6..8a451215fa 100644 --- a/src/platform/locales/text/tr.json +++ b/src/platform/locales/text/tr.json @@ -8829,5 +8829,9 @@ "Open in Value Editor": "Değer Düzenleyicide Aç", "Show Aggregate View": "Toplam Görünümünü Göster", "Data Extractor": "Veri Çıkarıcı", - "Export Table to Clipboard": "Tabloyu Panoya Aktar" + "Export Table to Clipboard": "Tabloyu Panoya Aktar", + "Keys": "Anahtarlar", + "Triggers": "Tetikleyiciler", + "Filter by name or type": "Ada veya türe göre filtrele", + "Filter columns": "Sütunları filtrele" } diff --git a/src/platform/locales/text/zh-TW.json b/src/platform/locales/text/zh-TW.json index bec37c2387..8c6cf26b29 100644 --- a/src/platform/locales/text/zh-TW.json +++ b/src/platform/locales/text/zh-TW.json @@ -9367,5 +9367,9 @@ "Open in Value Editor": "在值編輯器中開啟", "Show Aggregate View": "顯示彙總檢視", "Data Extractor": "資料擷取器", - "Export Table to Clipboard": "將表格匯出到剪貼簿" + "Export Table to Clipboard": "將表格匯出到剪貼簿", + "Keys": "鍵", + "Triggers": "觸發器", + "Filter by name or type": "依名稱或類型篩選", + "Filter columns": "篩選欄" } diff --git a/src/platform/locales/text/zh.json b/src/platform/locales/text/zh.json index b47abbc63e..e9a1216ed3 100644 --- a/src/platform/locales/text/zh.json +++ b/src/platform/locales/text/zh.json @@ -10597,5 +10597,9 @@ "Open in Value Editor": "在值编辑器中打开", "Show Aggregate View": "显示聚合视图", "Data Extractor": "数据提取器", - "Export Table to Clipboard": "将表导出到剪贴板" + "Export Table to Clipboard": "将表导出到剪贴板", + "Keys": "键", + "Triggers": "触发器", + "Filter by name or type": "按名称或类型过滤", + "Filter columns": "过滤列" }