feat(sidebar): support hierarchical batch connection moves

This commit is contained in:
二丫讲梵 authored and GitHub committed 2026-08-22 19:18:11 +08:00
1 parent 36c9500a4e
commit 904efff6b3
10 files changed
+105 -38

No files matched your search

@@ -42,6 +42,10 @@ export function selectedConnectionDisconnectTargets(currentNode: TreeNode, selec
return selectedConnectionActionTargets(currentNode, selectedNodes);
}
export function selectedConnectionMoveTargets(currentNode: TreeNode, selectedNodes: TreeNode[]): ConnectionTreeNode[] {
return selectedConnectionActionTargets(currentNode, selectedNodes);
}
export function selectedConnectionClipboardTargets(currentNode: TreeNode, selectedNodes: TreeNode[]): ConnectionTreeNode[] {
return selectedConnectionActionTargets(currentNode, selectedNodes);
}
@@ -337,6 +337,36 @@ export function buildConnectionGroupPathMap(layout: SidebarLayout): Map<string,
return paths;
}
export interface ConnectionGroupDestinationRow {
id: string;
name: string;
depth: number;
path: string[];
}
/** Build selectable connection-group destinations in the same tree order as the sidebar. */
export function connectionGroupDestinationRows(layout: SidebarLayout): ConnectionGroupDestinationRow[] {
const groupMap = new Map(layout.groups.map((group) => [group.id, group]));
const rows: ConnectionGroupDestinationRow[] = [];
const seen = new Set<string>();
const visit = (entries: SidebarOrderEntry[], parentPath: string[]) => {
for (const entry of entries) {
if (entry.type !== "group" || seen.has(entry.id)) continue;
const group = groupMap.get(entry.id);
if (!group) continue;
seen.add(entry.id);
const path = [...parentPath, group.name];
rows.push({ id: group.id, name: group.name, depth: parentPath.length, path });
visit(entryChildren(entry), path);
}
};
visit(layout.order, []);
return rows;
}
function findGroupEntry(entries: SidebarOrderEntry[], groupId: string): Extract<SidebarOrderEntry, { type: "group" }> | null {
for (const entry of entries) {
if (entry.type !== "group") continue;