Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(structure): add action names to column icon tooltips

zipg3156f36fac8b
diff --git a/apps/desktop/src/components/structure/TableStructureEditor.primaryKey.spec.ts b/apps/desktop/src/components/structure/TableStructureEditor.primaryKey.spec.ts
index 573c520c9b..7fc58b7c74 100644
--- a/apps/desktop/src/components/structure/TableStructureEditor.primaryKey.spec.ts
+++ b/apps/desktop/src/components/structure/TableStructureEditor.primaryKey.spec.ts
@@ -761,14 +761,30 @@ describe("TableStructureEditor action column", () => {
expect(copyTooltip?.getAttribute("delay-duration")).toBe("500");
expect(deleteTooltip?.getAttribute("delay-duration")).toBe("500");
expect(root.querySelector("[data-add-column-shortcut-content]")?.textContent).toBe("Shift+Enter");
- expect(root.querySelector("[data-copy-column-shortcut-content]")?.textContent).toBe("⌘/Ctrl+D");
- expect(root.querySelector("[data-delete-column-shortcut-content]")?.textContent?.trim()).toBe("⌘/Ctrl+Del");
+ // The add control already renders its label, so that hint stays a bare shortcut.
expect(root.querySelector("[data-add-column-shortcut-content]")?.textContent).not.toContain("structureEditor.addColumn");
- expect(root.querySelector("[data-copy-column-shortcut-content]")?.textContent).not.toContain("structureEditor.copyColumn");
+ // The icon-only copy/delete controls must name the action next to the shortcut (#9870).
+ expect(root.querySelector("[data-copy-column-shortcut-content]")?.textContent).toBe("structureEditor.copyColumn⌘/Ctrl+D");
+ expect(root.querySelector("[data-delete-column-shortcut-content]")?.textContent).toBe("structureEditor.drop⌘/Ctrl+Del");
expect(copyTooltip?.querySelector("button")?.hasAttribute("title")).toBe(false);
expect(deleteTooltip?.querySelector("button")?.hasAttribute("title")).toBe(false);
});
+ it("names the delete control after the action it currently performs", async () => {
+ const root = await mountEditor("dameng");
+
+ const persistedDelete = root.querySelector<HTMLButtonElement>('button[aria-label="structureEditor.drop"]');
+ if (!persistedDelete) throw new Error("Missing delete button for the persisted column");
+ persistedDelete.click();
+ await vi.waitFor(() => expect(root.querySelector("[data-delete-column-shortcut-content]")?.textContent).toBe("structureEditor.restore⌘/Ctrl+Del"));
+
+ buttonWithText(root, "structureEditor.addColumn").click();
+ await vi.waitFor(() => expect(root.querySelector('[data-column-row-index="1"]')).not.toBeNull());
+ const addedRow = root.querySelector('[data-column-row-index="1"]');
+ expect(addedRow?.querySelector('button[aria-label="structureEditor.remove"]')).not.toBeNull();
+ expect(addedRow?.querySelector("[data-delete-column-shortcut-content]")?.textContent).toBe("structureEditor.remove⌘/Ctrl+Del");
+ });
+
it("adds a field below the focused input on Shift+Enter", async () => {
const root = await mountEditor("dameng");
const sourceInput = root.querySelector<HTMLInputElement>('[data-column-row-index="0"] [data-column-name-input]');
diff --git a/apps/desktop/src/components/structure/TableStructureEditor.vue b/apps/desktop/src/components/structure/TableStructureEditor.vue
index fc6dee7307..9013be198a 100644
--- a/apps/desktop/src/components/structure/TableStructureEditor.vue
+++ b/apps/desktop/src/components/structure/TableStructureEditor.vue
@@ -3774,6 +3774,17 @@ function columnContextMenuItems(column: EditableStructureColumn): ContextMenuIte
];
}
+/**
+ * The delete control is icon-only and swaps between three actions, so its
+ * tooltip has to name the action instead of only showing the shortcut (#9870).
+ */
+function deleteColumnActionLabel(column: EditableStructureColumn): string {
+ if (!column.original) {
+ return t("structureEditor.remove");
+ }
+ return column.markedForDrop ? t("structureEditor.restore") : t("structureEditor.drop");
+}
+
function isColumnNameDisabled(column: EditableStructureColumn): boolean {
return column.markedForDrop || (!!column.original && !structureCapabilities.value.renameColumn);
}
@@ -5031,7 +5042,10 @@ watch(
<Copy :class="structureIconClass" />
</Button>
</TooltipTrigger>
- <TooltipContent side="bottom" class="font-mono font-medium" data-copy-column-shortcut-content>⌘/Ctrl+D</TooltipContent>
+ <TooltipContent side="bottom" data-copy-column-shortcut-content>
+ <span>{{ t("structureEditor.copyColumn") }}</span>
+ <span data-slot="kbd" class="font-mono font-medium opacity-70">⌘/Ctrl+D</span>
+ </TooltipContent>
</Tooltip>
<Tooltip :delay-duration="FIELD_SHORTCUT_TOOLTIP_DELAY_MS" data-delete-column-shortcut-tooltip>
<TooltipTrigger as-child>
@@ -5043,8 +5057,9 @@ watch(
<X :class="structureIconClass" />
</Button>
</TooltipTrigger>
- <TooltipContent side="bottom" class="font-mono font-medium" data-delete-column-shortcut-content>
- {{ column.markedForDrop ? t("structureEditor.restore") : "⌘/Ctrl+Del" }}
+ <TooltipContent side="bottom" data-delete-column-shortcut-content>
+ <span>{{ deleteColumnActionLabel(column) }}</span>
+ <span data-slot="kbd" class="font-mono font-medium opacity-70">⌘/Ctrl+Del</span>
</TooltipContent>
</Tooltip>
</div>
diff --git a/docs/screenshots/issue-9870-column-action-copy-after.png b/docs/screenshots/issue-9870-column-action-copy-after.png
new file mode 100644
index 0000000000..fb577276cf
Binary files /dev/null and b/docs/screenshots/issue-9870-column-action-copy-after.png differ
diff --git a/docs/screenshots/issue-9870-column-action-copy-before.png b/docs/screenshots/issue-9870-column-action-copy-before.png
new file mode 100644
index 0000000000..51e327537e
Binary files /dev/null and b/docs/screenshots/issue-9870-column-action-copy-before.png differ
diff --git a/docs/screenshots/issue-9870-column-action-drop-after.png b/docs/screenshots/issue-9870-column-action-drop-after.png
new file mode 100644
index 0000000000..8a6e1345a1
Binary files /dev/null and b/docs/screenshots/issue-9870-column-action-drop-after.png differ
diff --git a/docs/screenshots/issue-9870-column-action-drop-before.png b/docs/screenshots/issue-9870-column-action-drop-before.png
new file mode 100644
index 0000000000..5b3430d68e
Binary files /dev/null and b/docs/screenshots/issue-9870-column-action-drop-before.png differ
diff --git a/docs/screenshots/issue-9870-column-action-remove-after.png b/docs/screenshots/issue-9870-column-action-remove-after.png
new file mode 100644
index 0000000000..9e01c494f3
Binary files /dev/null and b/docs/screenshots/issue-9870-column-action-remove-after.png differ
diff --git a/docs/screenshots/issue-9870-column-action-remove-before.png b/docs/screenshots/issue-9870-column-action-remove-before.png
new file mode 100644
index 0000000000..86e9e3c1e9
Binary files /dev/null and b/docs/screenshots/issue-9870-column-action-remove-before.png differ