tiagobento commented on code in PR #3046:
URL: 
https://github.com/apache/incubator-kie-tools/pull/3046#discussion_r2103720360


##########
packages/dmn-editor/src/diagram/nodes/Nodes.tsx:
##########
@@ -843,13 +854,50 @@ export const DecisionServiceNode = React.memo(
       (s) => (isHovered || isResizing) && s.diagram.draggingNodes.length === 0
     );
     const isDropTarget = useDmnEditorStore((s) => s.diagram.dropTargetNode?.id 
=== id);
+    const dmnEditorStoreApi = useDmnEditorStoreApi();
+
+    const dropPoint = useMemo(
+      () => ({
+        x: shape["dc:Bounds"]?.["@_x"] ?? 0,
+        y: shape["dc:Bounds"]?.["@_y"] ?? 0,
+      }),
+      [shape]
+    );
 
     const { isEditingLabel, setEditingLabel, triggerEditing, 
triggerEditingIfEnter } = useEditableNodeLabel(id);
     useHoveredNodeAlwaysOnTop(ref, zIndex, shouldActLikeHovered, dragging, 
selected, isEditingLabel);
 
-    const dmnEditorStoreApi = useDmnEditorStoreApi();
+    let expandButtonClassname = 
"kie-dmn-editor--decision-service-collapsed-button";

Review Comment:
   Not a good practice to have a mutable variable like this directly inside a 
Function Component. Please wrap this logic inside a `useMemo`.



##########
packages/dmn-editor/src/diagram/nodes/Nodes.tsx:
##########
@@ -883,6 +931,170 @@ export const DecisionServiceNode = React.memo(
       };
     }, [decisionService.encapsulatedDecision, decisionService.outputDecision, 
dmnEditorStoreApi, id]);
 
+    const defaultSizeNode = DEFAULT_NODE_SIZES[NODE_TYPES.decisionService]({
+      snapGrid: snapGrid,
+    });
+
+    const { computed, ...state } = dmnEditorStoreApi.getState();
+    const dereferencedState: State = { computed, 
...JSON.parse(JSON.stringify(state)) };
+    const drdIndex = 
dereferencedState.computed(dereferencedState).getDrdIndex();
+
+    const drds = 
dereferencedState.dmn.model.definitions["dmndi:DMNDI"]?.["dmndi:DMNDiagram"] ?? 
[];
+    let indexedDrdContainingDecisionServiceDepiction: 
ReturnType<Computed["indexedDrd"]> | undefined;
+    for (let i = 0; i < drds.length; i++) {
+      if (
+        dereferencedState.dmn.model.definitions["@_namespace"] ===
+          dereferencedState.dmn.model.definitions["@_namespace"] &&
+        i === drdIndex
+      ) {
+        continue;
+      }
+
+      const _indexedDrd = computeIndexedDrd(
+        dereferencedState.dmn.model.definitions["@_namespace"],
+        dereferencedState.dmn.model.definitions,
+        i
+      );
+      const dsShape = _indexedDrd.dmnShapesByHref.get(id);
+      const hasCompleteExpandedDepictionOfDecisionService =
+        dsShape &&
+        !(dsShape["@_isCollapsed"] ?? false) &&
+        decisionsInCurrentDecisionService.every((dHref) => 
_indexedDrd.dmnShapesByHref.has(dHref));
+      if (hasCompleteExpandedDepictionOfDecisionService) {
+        indexedDrdContainingDecisionServiceDepiction = _indexedDrd;
+        break;
+      }
+    }

Review Comment:
   Un-memoized logic too.



-- 
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