jomarko commented on code in PR #2546:
URL: 
https://github.com/apache/incubator-kie-tools/pull/2546#discussion_r1765044440


##########
packages/dmn-editor/src/diagram/edges/usePotentialWaypointControls.ts:
##########
@@ -74,10 +80,86 @@ export function usePotentialWaypointControls(
   }, [snapGrid, potentialWaypoint]);
 
   const onDoubleClick = useCallback(() => {
-    if (!potentialWaypoint || !snappedPotentialWaypoint || edgeIndex === 
undefined) {
+    if (!potentialWaypoint || !snappedPotentialWaypoint) {
       return;
     }
 
+    if (edgeIndex === undefined) {
+      /**
+       * This means we are adding a first wayipoint to one of following edges:
+       * - an edge in a non default DRD
+       * - an edge targeting an external node
+       */
+      dmnEditorStoreApi.setState((state) => {
+        const nodesById = 
state.computed(state).getDiagramData(externalModelsByNamespace).nodesById;
+        const edge = 
state.computed(state).getDiagramData(externalModelsByNamespace).edgesById.get(edgeId);
+        if (
+          edge === undefined ||
+          edge.type === undefined ||
+          edge.data === undefined ||
+          edge.data?.dmnShapeSource === undefined ||
+          edge.data?.dmnShapeTarget === undefined
+        ) {
+          console.debug(`DMN MUTATION: We can not add DMNEdge for '${edgeId}' 
edge into diagram.`);
+          return;
+        }
+        const edgeSourceBounds = edge.data?.dmnShapeSource["dc:Bounds"];
+        const edgeTargetBounds = edge.data?.dmnShapeTarget["dc:Bounds"];
+
+        if (edgeSourceBounds === undefined || edgeTargetBounds === undefined) {

Review Comment:
   I tried to do my best with the null checks simplification, lets have a look 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to