Skip to content

Commit

Permalink
[Nu-1792] properties save fix when fragment is in different group tha…
Browse files Browse the repository at this point in the history
…n fragments (#6725)

* NU-1792 properties save fix when fragment is in a different group than fragments

* NU-1792 format message

(cherry picked from commit bb82d34)
  • Loading branch information
Dzuming committed Sep 4, 2024
1 parent 42e60a0 commit 30c2fef
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import fp from "lodash/fp";
import { NodeType, ProcessDefinitionData } from "../../../types";

/*
* TODO: It's a workaround
* There may be situations where an open scenario has its fragment parameters edited by a different owner
* In such cases, we need to align the fragmentInput properties with the updated state of the fragment process definition data.
*/
export function alignFragmentWithSchema(processDefinitionData: ProcessDefinitionData, fragmentNode: NodeType) {
const fragmentId = fragmentNode.ref.id;
const fragmentSchema = processDefinitionData.componentGroups
.find((componentGroups) => {
return componentGroups.name === "fragments";
})
.components.find((obj) => obj.node.ref.id === fragmentId);
// This is a workaround. We cannot look for the fragment schema only in the fragments group,
// because fragmentInput can be moved to a different group.
// In this case, there was an error, which is why we need to iterate through all groups.
.flatMap((componentGroups) => componentGroups.components)
.find((obj) => obj?.node?.ref?.id === fragmentId);
const fragmentSchemaParameters = fragmentSchema.node.ref.parameters;
const mergedParameters = fragmentSchemaParameters.map(
(param) => fragmentNode.ref.parameters.find((nodeParam) => nodeParam.name === param.name) || param,
Expand Down

0 comments on commit 30c2fef

Please sign in to comment.