This is an automated email from the ASF dual-hosted git repository.
thiagoelg pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-tools.git
The following commit(s) were added to refs/heads/main by this push:
new 3d44bd4b83c NO-ISSUE: Improve and refactor subprocess mutations (#3609)
3d44bd4b83c is described below
commit 3d44bd4b83c69949eba110b17474261fadc57bf0
Author: Rajalakshmy S <[email protected]>
AuthorDate: Mon Jun 1 20:18:34 2026 +0530
NO-ISSUE: Improve and refactor subprocess mutations (#3609)
Co-authored-by: Rajalakshmy S <[email protected]>
---
.../src/mutations/moveNodesInsideSubProcess.ts | 26 ++++++++++------------
.../src/mutations/moveNodesOutOfSubProcess.ts | 10 ++++-----
2 files changed, 16 insertions(+), 20 deletions(-)
diff --git a/packages/bpmn-editor/src/mutations/moveNodesInsideSubProcess.ts
b/packages/bpmn-editor/src/mutations/moveNodesInsideSubProcess.ts
index 8cd564b6426..06e8565c079 100644
--- a/packages/bpmn-editor/src/mutations/moveNodesInsideSubProcess.ts
+++ b/packages/bpmn-editor/src/mutations/moveNodesInsideSubProcess.ts
@@ -41,10 +41,8 @@ export function moveNodesInsideSubProcess({
throw new Error(`Cannot find subprocess with ID:
${__readonly_subProcessId}`);
}
- const flowElementsToMove:
Normalized<Unpacked<Normalized<BPMN20__tProcess>["flowElement"]>>[] = [];
- const artifactsToMove: Normalized<
- ElementExclusion<Unpacked<Normalized<BPMN20__tProcess>["artifact"]>,
"association">
- >[] = [];
+ const flowElementsToMove:
Unpacked<Normalized<BPMN20__tProcess>["flowElement"]>[] = [];
+ const artifactsToMove:
ElementExclusion<Unpacked<Normalized<BPMN20__tProcess>["artifact"]>,
"association">[] = [];
const nodeIdsToMoveInside = new Set(__readonly_nodeIds);
const subProcessNodes = new Set<string>();
@@ -54,9 +52,10 @@ export function moveNodesInsideSubProcess({
}
});
- const toMove:
Normalized<Unpacked<Normalized<BPMN20__tProcess>["flowElement"]>>[] = [];
-
- const collectElements = (flowElements:
Normalized<BPMN20__tProcess>["flowElement"]): void => {
+ const collectElements = (
+ flowElements: Normalized<BPMN20__tProcess>["flowElement"],
+ collected: Unpacked<Normalized<BPMN20__tProcess>["flowElement"]>[]
+ ): void => {
if (!flowElements) {
return;
}
@@ -68,25 +67,24 @@ export function moveNodesInsideSubProcess({
flowElement["@_attachedToRef"] &&
nodeIdsToMoveInside.has(flowElement["@_attachedToRef"]))
) {
- toMove.push(...flowElements.splice(i, 1));
+ collected.push(...flowElements.splice(i, 1));
} else if (shouldMoveSequenceFlow(flowElement, nodeIdsToMoveInside,
subProcessNodes)) {
// If the source and target are both outside of the sub-process
// or if the source and target is already in the sub process the
sequenceFlow must be copied
- toMove.push(...flowElements.splice(i, 1));
+ collected.push(...flowElements.splice(i, 1));
} else if (isSubProcessElement(flowElement) && flowElement.flowElement) {
- collectElements(flowElement.flowElement);
+ collectElements(flowElement.flowElement, collected);
}
}
};
- collectElements(process.flowElement ?? []);
- flowElementsToMove.push(...toMove);
+ collectElements(process.flowElement ?? [], flowElementsToMove);
for (let i = 0; i < (process.artifact ?? []).length; i++) {
const artifact = (process.artifact ?? [])[i];
if (artifact.__$$element !== "association" &&
nodeIdsToMoveInside.has(artifact["@_id"])) {
- const spliced = process.artifact?.splice(i, 1) ?? [];
- artifactsToMove.push(...spliced.filter((a) => a.__$$element !==
"association"));
+ const removedArtifacts = process.artifact?.splice(i, 1) ?? [];
+ artifactsToMove.push(...removedArtifacts.filter((a) => a.__$$element !==
"association"));
i--; // repeat one index because we just altered the array we're
iterating over.
}
}
diff --git a/packages/bpmn-editor/src/mutations/moveNodesOutOfSubProcess.ts
b/packages/bpmn-editor/src/mutations/moveNodesOutOfSubProcess.ts
index e7576d888fd..75e3b312e1d 100644
--- a/packages/bpmn-editor/src/mutations/moveNodesOutOfSubProcess.ts
+++ b/packages/bpmn-editor/src/mutations/moveNodesOutOfSubProcess.ts
@@ -157,10 +157,8 @@ export function moveNodesOutOfSubProcess({
findParentFlowElements(process.flowElement ?? [],
__readonly_subProcessId ?? "") ?? process.flowElement ?? [];
}
- const flowElementsToMove:
Normalized<Unpacked<Normalized<BPMN20__tProcess>["flowElement"]>>[] = [];
- const artifactsToMove: Normalized<
- ElementExclusion<Unpacked<Normalized<BPMN20__tProcess>["artifact"]>,
"association">
- >[] = [];
+ const flowElementsToMove:
Unpacked<Normalized<BPMN20__tProcess>["flowElement"]>[] = [];
+ const artifactsToMove:
ElementExclusion<Unpacked<Normalized<BPMN20__tProcess>["artifact"]>,
"association">[] = [];
const nodeIdsToMoveOut = new Set(__readonly_nodeIds);
@@ -230,8 +228,8 @@ export function moveNodesOutOfSubProcess({
for (let i = 0; i < (subProcess.artifact ?? []).length; i++) {
const artifact = (subProcess.artifact ?? [])[i];
if (artifact.__$$element !== "association" &&
nodeIdsToMoveOut.has(artifact["@_id"])) {
- const spliced = subProcess.artifact?.splice(i, 1) ?? [];
- artifactsToMove.push(...spliced.filter((a) => a.__$$element !==
"association"));
+ const removedArtifacts = subProcess.artifact?.splice(i, 1) ?? [];
+ artifactsToMove.push(...removedArtifacts.filter((a) => a.__$$element !==
"association"));
i--; // repeat one index because we just altered the array we're
iterating over.
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]