Skip to content

Commit

Permalink
remove extraArg
Browse files Browse the repository at this point in the history
  • Loading branch information
jomarko committed Sep 19, 2024
1 parent cb56865 commit 63c9187
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ export function _checkIsValidConnection(

// External nodes cannot be targeted by default
// However there are exceptions, for example adding a waypoint on the edge
const isExternalNode = targetNode.data.dmnObjectQName.prefix != undefined;
if (!extraArg?.allowExternalTarget && isExternalNode) {
const isTargetExternalNode = targetNode.data.dmnObjectQName.prefix != undefined;
if (!extraArg?.allowExternalTarget && isTargetExternalNode) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export function usePotentialWaypointControls(
return;
}

const isExternalNode = targetNode.data.dmnObjectQName.prefix !== undefined;
const isTargetExternalNode = targetNode.data.dmnObjectQName.prefix !== undefined;

addEdge({
definitions: state.dmn.model.definitions,
Expand Down Expand Up @@ -148,9 +148,7 @@ export function usePotentialWaypointControls(
shapeId: edge.data?.dmnShapeTarget["@_id"],
},
keepWaypoints: false,
extraArg: {
requirementEdgeTargetingExternalNodeId: isExternalNode ? edgeId : undefined,
},
requirementEdgeTargetingExternalNodeId: isTargetExternalNode ? edgeId : undefined,
});

console.debug(`DMN MUTATION: DMNEdge for '${edgeId}' edge was added into diagram.`);
Expand Down
12 changes: 4 additions & 8 deletions packages/dmn-editor/src/mutations/addEdge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function addEdge({
targetNode,
edge,
keepWaypoints,
extraArg,
requirementEdgeTargetingExternalNodeId,
}: {
definitions: Normalized<DMN15__tDefinitions>;
drdIndex: number;
Expand All @@ -74,20 +74,16 @@ export function addEdge({
autoPositionedEdgeMarker: AutoPositionedEdgeMarker | undefined;
};
keepWaypoints: boolean;
extraArg?: {
requirementEdgeTargetingExternalNodeId: string | undefined;
};
requirementEdgeTargetingExternalNodeId?: string;
}) {
const externalTargetAllowed = extraArg !== undefined && extraArg.requirementEdgeTargetingExternalNodeId !== undefined;
const externalTargetAllowed = requirementEdgeTargetingExternalNodeId !== undefined;
if (!_checkIsValidConnection(sourceNode, targetNode, edge.type, { allowExternalTarget: externalTargetAllowed })) {
throw new Error(`DMN MUTATION: Invalid structure: (${sourceNode.type}) --${edge.type}--> (${targetNode.type}) `);
}

const newEdgeId = generateUuid();

let existingEdgeId: string | undefined = externalTargetAllowed
? extraArg!.requirementEdgeTargetingExternalNodeId
: undefined;
let existingEdgeId: string | undefined = requirementEdgeTargetingExternalNodeId;

// Associations
if (edge.type === EDGE_TYPES.association) {
Expand Down

0 comments on commit 63c9187

Please sign in to comment.