From dda9611265999c6118fd30ea74dcafc341ece52a Mon Sep 17 00:00:00 2001 From: Jozef Marko Date: Fri, 13 Sep 2024 11:38:15 +0200 Subject: [PATCH] allowExternalTarget refactoring --- .../dmn-editor/src/diagram/connections/isValidConnection.ts | 6 ++++-- packages/dmn-editor/src/mutations/addEdge.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/dmn-editor/src/diagram/connections/isValidConnection.ts b/packages/dmn-editor/src/diagram/connections/isValidConnection.ts index 0ac384e4ce4..33f177c8e02 100644 --- a/packages/dmn-editor/src/diagram/connections/isValidConnection.ts +++ b/packages/dmn-editor/src/diagram/connections/isValidConnection.ts @@ -40,7 +40,9 @@ export function _checkIsValidConnection( sourceNode: { type?: string; data: DmnDiagramNodeData } | undefined, targetNode: { type?: string; data: DmnDiagramNodeData } | undefined, edgeType: string | null | undefined, - allowExternalTarget?: boolean + extraArg?: { + allowExternalTarget: boolean; + } ) { if (!sourceNode?.type || !targetNode?.type || !edgeType) { return false; @@ -48,7 +50,7 @@ export function _checkIsValidConnection( // External nodes cannot be targeted by default // However there are exceptions, for example adding a waypoint on the edge - if (!allowExternalTarget && targetNode.data.dmnObjectQName.prefix) { + if (!extraArg?.allowExternalTarget && targetNode.data.dmnObjectQName.prefix) { return false; } diff --git a/packages/dmn-editor/src/mutations/addEdge.ts b/packages/dmn-editor/src/mutations/addEdge.ts index 3909648d388..18ec3bf95d5 100644 --- a/packages/dmn-editor/src/mutations/addEdge.ts +++ b/packages/dmn-editor/src/mutations/addEdge.ts @@ -227,7 +227,7 @@ export function addEdgeTargetingExternalNode({ keepWaypoints: boolean; existingEdgeId?: string; }) { - if (!_checkIsValidConnection(sourceNode, targetNode, edge.type, true)) { + if (!_checkIsValidConnection(sourceNode, targetNode, edge.type, { allowExternalTarget: true })) { throw new Error(`DMN MUTATION: Invalid structure: (${sourceNode.type}) --${edge.type}--> (${targetNode.type}) `); }