Files
dbx/src/lib/sidebarTreeItemLayout.ts
T
t8y2 53a45330a6 feat(sidebar): group objects by type and add Object Browser context menus (#222)
Sidebar tree now groups database objects into Tables, Views, Procedures,
and Functions folders instead of a flat list. Empty groups are hidden
and each group shows its item count.

Object Browser rows now have right-click context menus with actions
like View Data, New Query, View Source, and Drop.
2026-05-12 14:33:52 +08:00

31 lines
738 B
TypeScript

import type { TreeNodeType } from "@/types/database";
const leafTypes: Set<TreeNodeType> = new Set([
"column",
"index",
"fkey",
"trigger",
"procedure",
"function",
"object-browser",
"redis-db",
"mongo-collection",
"saved-sql-file",
]);
export function treeItemPaddingLeft(depth: number): string {
return `${depth * 16 + 8}px`;
}
export function canTreeNodeExpand(type: TreeNodeType): boolean {
return !leafTypes.has(type);
}
export function canTreeNodeShowExpander({ type, childCount }: { type: TreeNodeType; childCount?: number }): boolean {
if (!canTreeNodeExpand(type)) return false;
if (type === "saved-sql-root" || type === "saved-sql-folder") {
return (childCount ?? 0) > 0;
}
return true;
}