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

[Nu-1792] properties save fix when fragment is in different group than fragments #6725

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading