From 9e0a39b50bb8769ca8d98e6d340b3c0b17d256bb Mon Sep 17 00:00:00 2001 From: Nicolas Van Labeke Date: Tue, 23 Apr 2024 13:06:11 +0100 Subject: [PATCH] fix(20321): fix bug with the dual iteration of transitions and pipelines --- .../designer/operation/OperationNode.utils.ts | 33 ++++++++++--------- .../transition/TransitionNode.utils.ts | 2 +- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/hivemq-edge/src/frontend/src/extensions/datahub/designer/operation/OperationNode.utils.ts b/hivemq-edge/src/frontend/src/extensions/datahub/designer/operation/OperationNode.utils.ts index 20be1776a3..db6edd2b36 100644 --- a/hivemq-edge/src/frontend/src/extensions/datahub/designer/operation/OperationNode.utils.ts +++ b/hivemq-edge/src/frontend/src/extensions/datahub/designer/operation/OperationNode.utils.ts @@ -2,7 +2,14 @@ import { Connection, getConnectedEdges, getIncomers, Node, NodeAddChange, XYPosi import i18n from '@/config/i18n.config.ts' -import { BehaviorPolicy, DataPolicy, PolicyOperation, Schema, SchemaReference, Script } from '@/api/__generated__' +import { + BehaviorPolicyOnTransition, + DataPolicy, + PolicyOperation, + Schema, + SchemaReference, + Script, +} from '@/api/__generated__' import { DataHubNodeType, DataPolicyData, @@ -221,26 +228,20 @@ export function checkValidityPipeline( } export const loadBehaviorPolicyPipelines = ( - behaviorPolicy: BehaviorPolicy, - transitionNode: Node, + behaviorPolicyTransition: BehaviorPolicyOnTransition, + transitionNode: Node, schemas: Schema[], scripts: Script[] ) => { - const newNodes: (NodeAddChange | Connection)[] = [] - - for (const transition of behaviorPolicy.onTransitions || []) { - const activeTransition = getActiveTransition(transition) - if (!activeTransition) - throw new Error(i18n.t('datahub:error.loading.operation.noTransition', { source: activeTransition }) as string) + const activeTransition = getActiveTransition(behaviorPolicyTransition) + if (!activeTransition) + throw new Error(i18n.t('datahub:error.loading.operation.noTransition', { source: activeTransition }) as string) - const transitionOnEvent = transition[activeTransition] - if (!transitionOnEvent) - throw new Error(i18n.t('datahub:error.loading.operation.noTransition', { source: activeTransition }) as string) + const transitionOnEvent = behaviorPolicyTransition[activeTransition] + if (!transitionOnEvent) + throw new Error(i18n.t('datahub:error.loading.operation.noTransition', { source: activeTransition }) as string) - const pipelines = loadPipeline(transitionNode, transitionOnEvent.pipeline, null, schemas, scripts) - newNodes.push(...pipelines) - } - return newNodes + return loadPipeline(transitionNode, transitionOnEvent.pipeline, null, schemas, scripts) } export const loadDataPolicyPipelines = ( diff --git a/hivemq-edge/src/frontend/src/extensions/datahub/designer/transition/TransitionNode.utils.ts b/hivemq-edge/src/frontend/src/extensions/datahub/designer/transition/TransitionNode.utils.ts index 30d2424cb7..c17acf4a46 100644 --- a/hivemq-edge/src/frontend/src/extensions/datahub/designer/transition/TransitionNode.utils.ts +++ b/hivemq-edge/src/frontend/src/extensions/datahub/designer/transition/TransitionNode.utils.ts @@ -145,7 +145,7 @@ export const loadTransitions = ( position: { ...shiftBottom() }, data: extractEventStates(model, behaviorPolicyTransition), } - const pipelines = loadBehaviorPolicyPipelines(behaviorPolicy, transitionNode, schemas, scripts) + const pipelines = loadBehaviorPolicyPipelines(behaviorPolicyTransition, transitionNode, schemas, scripts) newNodes.push( { item: transitionNode, type: 'add' } as NodeAddChange,