Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): SubWork Flow Multi Select Deletion #743

Merged
merged 11 commits into from
Jan 9, 2025
6 changes: 4 additions & 2 deletions ui/src/lib/yjs/useYWorkflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,23 +147,25 @@ export default ({
(nodeIds: string[]) =>
undoTrackerActionWrapper(() => {
const workflowIds: string[] = [];
const localWorkflows = [...rawWorkflows];

const removeNodes = (nodeIds: string[]) => {
nodeIds.forEach((nid) => {
if (nid === DEFAULT_ENTRY_GRAPH_ID) return;

const index = rawWorkflows.findIndex((w) => w.id === nid);
const index = localWorkflows.findIndex((w) => w.id === nid);
if (index === -1) return;

// Loop over workflow at current index and remove any subworkflow nodes
(rawWorkflows[index].nodes as Node[]).forEach((node) => {
(localWorkflows[index].nodes as Node[]).forEach((node) => {
if (node.type === "subworkflow") {
removeNodes([node.id]);
}
});

workflowIds.push(nid);
yWorkflows.delete(index);
localWorkflows.splice(index, 1);
});
};

Expand Down
Loading