feat(sidebar): refresh data tables on double click
This commit is contained in:
7 files changed
+342
-23
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" | "open-object-browser" | "open-object-browser-and-expand" | "open-source" | "open-saved-sql" | "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 SidebarSelectionCopyAction = "copy-name" | "none";
|
||||
export type SidebarActivation = "single" | "double";
|
||||
|
||||
@@ -45,6 +45,7 @@ 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";
|
||||
if (activation === "double") {
|
||||
if (dataNodeTypes.has(type)) return "open-data";
|
||||
if (sourceNodeTypes.has(type)) return "open-source";
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import type { QueryResult, QueryTab } from "@/types/database";
|
||||
|
||||
export type DataTableDoubleClickAction = "activate" | "open" | "refresh" | "none";
|
||||
|
||||
function isErrorResult(result: QueryResult | undefined): boolean {
|
||||
return result?.columns.length === 1 && result.columns[0] === "Error";
|
||||
}
|
||||
@@ -9,3 +11,14 @@ export function canActivateExistingDataTableTab(tab: QueryTab, options: { activa
|
||||
if (isErrorResult(tab.result)) return false;
|
||||
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";
|
||||
if (!tab) return activation === "double" ? "open" : "none";
|
||||
if (!canActivateExistingDataTableTab(tab)) return "open";
|
||||
return tab.isExecuting ? "activate" : "refresh";
|
||||
}
|
||||
Reference in new issue
Block a user