fix(sidebar): preserve existing table data tabs
This commit is contained in:
1 parent
61f442f9b9
commit
678033c82e
5 files changed
+33
-75
No files matched your search
@@ -2,7 +2,7 @@ import type { ObjectSourceKind, TreeNode, TreeNodeType } from "@/types/database"
|
||||
import { matchesShortcut, type ShortcutLikeEvent } from "@/lib/editor/keyboardShortcuts";
|
||||
|
||||
export type TreeNodeRowAction = "open-data" | "toggle" | "none";
|
||||
export type TreeNodeRowDoubleClickAction = "open-data" | "refresh-data" | "open-object-browser" | "open-object-browser-and-expand" | "open-source" | "open-saved-sql" | "toggle" | "none";
|
||||
export type TreeNodeRowDoubleClickAction = "open-data" | "activate-data" | "open-object-browser" | "open-object-browser-and-expand" | "open-source" | "open-saved-sql" | "toggle" | "none";
|
||||
export type SidebarSelectionCopyAction = "copy-name" | "none";
|
||||
export type SidebarActivation = "single" | "double";
|
||||
|
||||
@@ -48,7 +48,9 @@ export function shouldRunTreeNodeRowAction(action: TreeNodeRowAction, clickDetai
|
||||
}
|
||||
|
||||
export function treeNodeRowDoubleClickAction(type: TreeNodeType, canOpenObjectBrowser: boolean, activation: SidebarActivation = "single", canExpand = false): TreeNodeRowDoubleClickAction {
|
||||
if (type === "table") return "refresh-data";
|
||||
// Single-click activation already handles the first click in a dblclick
|
||||
// sequence. Only double-click activation needs a second-stage table action.
|
||||
if (type === "table") return activation === "double" ? "activate-data" : "none";
|
||||
if (activation === "double") {
|
||||
if (dataNodeTypes.has(type)) return "open-data";
|
||||
if (sourceNodeTypes.has(type)) return "open-source";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { QueryResult, QueryTab } from "@/types/database";
|
||||
|
||||
export type DataTableDoubleClickAction = "activate" | "open" | "refresh" | "none";
|
||||
export type DataTableDoubleClickAction = "activate" | "open" | "none";
|
||||
|
||||
function isErrorResult(result: QueryResult | undefined): boolean {
|
||||
return result?.columns.length === 1 && result.columns[0] === "Error";
|
||||
@@ -12,13 +12,9 @@ export function canActivateExistingDataTableTab(tab: QueryTab, options: { activa
|
||||
return !!tab.result || !!tab.results?.length;
|
||||
}
|
||||
|
||||
export function canRefreshDataTableFromSingleActivationDoubleClick(tab: QueryTab | undefined): boolean {
|
||||
return !!tab && !tab.isExecuting && canActivateExistingDataTableTab(tab);
|
||||
}
|
||||
|
||||
export function dataTableDoubleClickAction(tab: QueryTab | undefined, activation: "single" | "double", singleActivationRefreshAllowed = false): DataTableDoubleClickAction {
|
||||
if (activation === "single" && !singleActivationRefreshAllowed) return "none";
|
||||
export function dataTableDoubleClickAction(tab: QueryTab | undefined, activation: "single" | "double"): DataTableDoubleClickAction {
|
||||
if (activation === "single") return "none";
|
||||
if (!tab) return activation === "double" ? "open" : "none";
|
||||
if (!canActivateExistingDataTableTab(tab)) return "open";
|
||||
return tab.isExecuting ? "activate" : "refresh";
|
||||
return "activate";
|
||||
}
|
||||
Reference in new issue
Block a user