fix(objects): open view data tab on double-click and stop source toggle-off

This commit is contained in:
Terry Yao authored and GitHub committed 2026-09-20 13:49:05 +08:00
1 parent 555cb25c4f
commit 853a408d30
3 files changed
+24 -14

No files matched your search

@@ -76,8 +76,8 @@ describe("doubleClickRowAction", () => {
expect(doubleClickRowAction(row("TABLE", "orders"))).toBe("open-table");
});
it("returns open-source for VIEW", () => {
expect(doubleClickRowAction(row("VIEW", "v_orders"))).toBe("open-source");
it.each(["VIEW", "MATERIALIZED_VIEW"] as const)("returns open-table for %s like the sidebar data nodes", (type) => {
expect(doubleClickRowAction(row(type, "v_orders"))).toBe("open-table");
});
it("returns open-source for PROCEDURE", () => {
@@ -123,9 +123,9 @@ describe("resolveRowClickAction", () => {
expect(result.isDouble).toBe(false);
});
it("double click on VIEW returns open-source", () => {
it("double click on VIEW returns open-table", () => {
const result = resolveRowClickAction(viewRow, 2, "single");
expect(result.action).toBe("open-source");
expect(result.action).toBe("open-table");
expect(result.isDouble).toBe(true);
});
});
@@ -149,9 +149,9 @@ describe("resolveRowClickAction", () => {
expect(result.isDouble).toBe(true);
});
it("double click on VIEW returns open-source", () => {
it("double click on VIEW returns open-table", () => {
const result = resolveRowClickAction(viewRow, 2, "double");
expect(result.action).toBe("open-source");
expect(result.action).toBe("open-table");
expect(result.isDouble).toBe(true);
});
});
@@ -165,8 +165,12 @@ describe("shouldDeferSingleClick", () => {
expect(shouldDeferSingleClick(tableRow, "table-info")).toBe(true);
});
it("does not defer VIEW open-source (same single/double action)", () => {
expect(shouldDeferSingleClick(viewRow, "open-source")).toBe(false);
it("defers VIEW open-source (distinct single/double actions)", () => {
expect(shouldDeferSingleClick(viewRow, "open-source")).toBe(true);
});
it("does not defer PROCEDURE open-source (same single/double action)", () => {
expect(shouldDeferSingleClick(row("PROCEDURE", "sp_run"), "open-source")).toBe(false);
});
it("does not defer none action", () => {
@@ -26,14 +26,15 @@ export function singleClickRowAction(row: ObjectBrowserRow | null | undefined, d
/**
* Determine the action for a double click on an object browser row.
* - TABLE → open-table (open table data tab)
* - VIEW/MATERIALIZED_VIEW/PROCEDURE/FUNCTION/TRIGGER/SEQUENCE/PACKAGE/PACKAGE_BODY/TYPE/TYPE_BODY → open-source
* - TABLE/VIEW/MATERIALIZED_VIEW → open-table (open data tab, matching the
* sidebar's data-node double-click behavior)
* - PROCEDURE/FUNCTION/TRIGGER/SEQUENCE/PACKAGE/PACKAGE_BODY/TYPE/TYPE_BODY → open-source
* - otherwise → none
*/
export function doubleClickRowAction(row: ObjectBrowserRow | null | undefined, dbType?: DatabaseType): ObjectBrowserRowAction {
if (!row) return "none";
if (dbType === "mongodb") return mongoObjectBrowserRowAction(row);
if (row.type === "TABLE") return "open-table";
if (row.type === "TABLE" || row.type === "VIEW" || row.type === "MATERIALIZED_VIEW") return "open-table";
if (row.type === "EVENT") return "open-source";
if (row.type === "TYPE" && customTypeCapabilities(dbType).details) return "type-info";
if (canOpenSource(row, dbType)) return "open-source";