feat(sidebar): extend table grouping to all object containers

This commit is contained in:
ReadMe.md authored and GitHub committed 2026-09-22 15:52:04 +08:00
1 parent e1a512fd59
commit 591e8f4909
20 files changed
+607 -169

No files matched your search

@@ -85,7 +85,7 @@ import { canTreeNodePin, canTreeNodeShowExpander } from "@/lib/sidebar/sidebarTr
import { sidebarConnectionVisibleFilterMenu } from "@/lib/sidebar/sidebarVisibleFilterMenu";
import { supportsSidebarObjectNameFilter } from "@/lib/sidebar/sidebarObjectNameFilter";
import { connectionGroupDestinationRows } from "@/lib/sidebar/sidebarLayout";
import { hasTableVGroupEntries, selectedTableVGroupMoveTargets, tableVGroupDestinationRows, tableVGroupPathForTable, tableVGroupsEnabled } from "@/lib/table/tableVGroup";
import { hasTableVGroupEntries, isTableVGroupContainerNode, isTableVGroupGroupableRowType, resolveTableVGroupScopeFromNode, selectedTableVGroupMoveTargets, tableVGroupDestinationRows, tableVGroupPathForTable, tableVGroupScopeKey, tableVGroupsEnabled } from "@/lib/table/tableVGroup";
import { objectTypesForGroupNode } from "@/lib/table/tableTree";
import { loadSidebarObjectGroup } from "@/lib/sidebar/sidebarObjectGroupRouting";
import { requestObjectBrowserSearchFocus } from "@/lib/tabs/objectBrowserSearchFocus";
@@ -5958,6 +5958,11 @@ function buildSpecialSidebarMenu(context: SidebarMenuFactoryContext): boolean {
if (currentDatabaseType() === "hbase" && node.type === "table") {
items.push({ label: t("contextMenu.copyName"), action: copyName, icon: Copy, shortcut: shortcutCopyName.value });
// HBase 表行走本特化分支(先于 buildObjectSidebarMenu 的统一注入短路),分组移动入口需在此补齐。
if (isTableVGroupGroupableRowType(node.type) && !!tableVGroupScopeKey(resolveTableVGroupScopeFromNode(connectionStore.treeNodes, node))) {
const vgroupMoveItems = buildTableVGroupMoveMenuItems(node);
if (vgroupMoveItems.length) items.push({ label: t("tableVGroup.moveToGroup"), icon: FolderInput, children: vgroupMoveItems });
}
items.push({ label: "", separator: true });
items.push({ label: t("contextMenu.viewData"), action: openDataImmediately, icon: TableProperties });
items.push({
@@ -6150,6 +6155,15 @@ function buildSpecialSidebarMenu(context: SidebarMenuFactoryContext): boolean {
function buildObjectSidebarMenu(context: SidebarMenuFactoryContext): boolean {
const { node, items, deleteMenuLabel, deleteMenuAction, truncateMenuLabel, truncateMenuAction, emptyMenuLabel, emptyMenuAction, batchAutoIncrementCount, autoIncrementMenuLabel, autoIncrementMenuAction } = context;
// 虚拟分组移动入口:对所有可分组行类型统一注入(含 procedure/function/trigger/
// sequence/event/synonym/job/package/type 等专属分支——它们各自 return true,
// 若只在 table/view/mv 分支注入,这些行将没有任何分组入口)。表行保持原行为
// (simple 模式也能经「移动到新分组」建组);其余行须已处于同类别分组容器内,
// 否则解析不出 scope,菜单只会静默失败。
if (isTableVGroupGroupableRowType(node.type) && (node.type === "table" || !!tableVGroupScopeKey(resolveTableVGroupScopeFromNode(connectionStore.treeNodes, node)))) {
const vgroupMoveItems = buildTableVGroupMoveMenuItems(node);
if (vgroupMoveItems.length) items.push({ label: t("tableVGroup.moveToGroup"), icon: FolderInput, children: vgroupMoveItems });
}
// 6. Table / View / Materialized View
if (node.type === "table" || node.type === "view" || node.type === "materialized_view") {
if (currentDatabaseType() === "victoriametrics" && node.type === "table") {
@@ -6169,10 +6183,6 @@ function buildObjectSidebarMenu(context: SidebarMenuFactoryContext): boolean {
}
const destructiveActions: ContextMenuItem[] = [];
items.push(copyNameMenuItem());
if (node.type === "table") {
const vgroupMoveItems = buildTableVGroupMoveMenuItems(node);
if (vgroupMoveItems.length) items.push({ label: t("tableVGroup.moveToGroup"), icon: FolderInput, children: vgroupMoveItems });
}
items.push({ label: t("contextMenu.newQuery"), action: newQuery, icon: TerminalSquare });
if (node.type === "table" && supportsAiAssistantContext(currentDatabaseType())) {
items.push(addToAiMenuItem(node));
@@ -6590,20 +6600,21 @@ function buildTableVGroupMoveMenuItems(node: TreeNode): ContextMenuItem[] {
const layout = connectionStore.tableVGroupLayoutFor(node);
const targets = selectedTableVGroupMoveTargets(node, selectedTreeNodesInVisibleOrder());
const targetNames = targets.map((target) => target.label);
const targetsInGroup = (groupId: string) => targetNames.every((name) => tableVGroupPathForTable(layout, name).includes(groupId));
const targetRowType = targets[0]?.type;
const targetsInGroup = (groupId: string) => targetNames.every((name) => tableVGroupPathForTable(layout, name, targetRowType).includes(groupId));
const items: ContextMenuItem[] = tableVGroupDestinationRows(layout).map((row) => ({
label: row.name,
title: row.path.join(" / "),
disabled: targetNames.length > 0 && targetsInGroup(row.id),
action: () => {
for (const name of targetNames) connectionStore.moveTableToVGroup(node, name, row.id);
for (const name of targetNames) connectionStore.moveTableToVGroup(node, name, row.id, targetRowType);
},
}));
if (targetNames.some((name) => tableVGroupPathForTable(layout, name).length > 0)) {
if (targetNames.some((name) => tableVGroupPathForTable(layout, name, targetRowType).length > 0)) {
items.push({
label: t("tableVGroup.removeFromGroup"),
action: () => {
for (const name of targetNames) connectionStore.moveTableToVGroup(node, name, null);
for (const name of targetNames) connectionStore.moveTableToVGroup(node, name, null, targetRowType);
},
});
}
@@ -6623,7 +6634,7 @@ function buildTableVGroupMoveMenuItems(node: TreeNode): ContextMenuItem[] {
}
function appendTableVGroupContainerItems(node: TreeNode, items: ContextMenuItem[]) {
if (node.type !== "database" && node.type !== "schema" && node.type !== "linked-server-schema" && node.type !== "group-tables") return;
if (!isTableVGroupContainerNode(node)) return;
const layout = connectionStore.tableVGroupLayoutFor(node);
if (!hasTableVGroupEntries(layout)) return;
const enabled = tableVGroupsEnabled(layout);