This is an automated email from the ASF dual-hosted git repository.

tiagobento pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-tools.git


The following commit(s) were added to refs/heads/main by this push:
     new 022c6c4db9b kie-issues#885: On the DMN Editor, Association edges 
coming out of an InputData node are rendered as an Information Requirement edge 
when the target end is dragged (#2156)
022c6c4db9b is described below

commit 022c6c4db9bb0696ac64c8849c0c474a4981da30
Author: Tiago Bento <[email protected]>
AuthorDate: Tue Feb 13 12:16:10 2024 -0500

    kie-issues#885: On the DMN Editor, Association edges coming out of an 
InputData node are rendered as an Information Requirement edge when the target 
end is dragged (#2156)
---
 packages/dmn-editor/src/diagram/Diagram.tsx                |  8 ++++----
 .../dmn-editor/src/diagram/connections/ConnectionLine.tsx  | 14 +++++++-------
 packages/dmn-editor/src/mutations/addConnectedNode.ts      |  6 +++---
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/packages/dmn-editor/src/diagram/Diagram.tsx 
b/packages/dmn-editor/src/diagram/Diagram.tsx
index e6adf4d04e1..3fb72742c7b 100644
--- a/packages/dmn-editor/src/diagram/Diagram.tsx
+++ b/packages/dmn-editor/src/diagram/Diagram.tsx
@@ -493,8 +493,8 @@ export const Diagram = React.forwardRef<DiagramRef, { 
container: React.RefObject
           const newNodeType = state.diagram.ongoingConnection.handleId as 
NodeType;
           const sourceNodeType = sourceNode.type as NodeType;
 
-          const edge = getDefaultEdgeTypeBetween(sourceNodeType as NodeType, 
newNodeType);
-          if (!edge) {
+          const edgeType = getDefaultEdgeTypeBetween(sourceNodeType as 
NodeType, newNodeType);
+          if (!edgeType) {
             throw new Error(`DMN DIAGRAM: Invalid structure: ${sourceNodeType} 
--(any)--> ${newNodeType}`);
           }
 
@@ -503,7 +503,7 @@ export const Diagram = React.forwardRef<DiagramRef, { 
container: React.RefObject
           const { id, href: newDmnObejctHref } = addConnectedNode({
             definitions: state.dmn.model.definitions,
             drdIndex: state.diagram.drdIndex,
-            edge,
+            edgeType,
             sourceNode: {
               href: sourceNode.id,
               type: sourceNodeType as NodeType,
@@ -1285,7 +1285,7 @@ function DmnDiagramEmptyState({
                   const { href: decisionNodeHref } = addConnectedNode({
                     definitions: state.dmn.model.definitions,
                     drdIndex: state.diagram.drdIndex,
-                    edge: EDGE_TYPES.informationRequirement,
+                    edgeType: EDGE_TYPES.informationRequirement,
                     sourceNode: {
                       href: inputDataNodeHref,
                       type: NODE_TYPES.inputData,
diff --git a/packages/dmn-editor/src/diagram/connections/ConnectionLine.tsx 
b/packages/dmn-editor/src/diagram/connections/ConnectionLine.tsx
index 6dd7833a71c..0830064b255 100644
--- a/packages/dmn-editor/src/diagram/connections/ConnectionLine.tsx
+++ b/packages/dmn-editor/src/diagram/connections/ConnectionLine.tsx
@@ -43,12 +43,12 @@ import { useExternalModels } from 
"../../includedModels/DmnEditorDependenciesCon
 export function ConnectionLine({ toX, toY, fromNode, fromHandle }: 
RF.ConnectionLineComponentProps) {
   const snapGrid = useDmnEditorStore((s) => s.diagram.snapGrid);
   const { externalModelsByNamespace } = useExternalModels();
-  const edge = useDmnEditorStore((s) =>
+  const edgeBeingUpdated = useDmnEditorStore((s) =>
     s.diagram.edgeIdBeingUpdated
       ? 
s.computed(s).getDiagramData(externalModelsByNamespace).edgesById.get(s.diagram.edgeIdBeingUpdated)
       : undefined
   );
-  const kieEdgePath = useKieEdgePath(edge?.source, edge?.target, edge?.data);
+  const kieEdgePath = useKieEdgePath(edgeBeingUpdated?.source, 
edgeBeingUpdated?.target, edgeBeingUpdated?.data);
   const isAlternativeInputDataShape = useDmnEditorStore((s) => 
s.computed(s).isAlternativeInputDataShape());
   // This works because nodes are configured with:
   // - Source handles with ids matching EDGE_TYPES or NODE_TYPES
@@ -68,13 +68,13 @@ export function ConnectionLine({ toX, toY, fromNode, 
fromHandle }: RF.Connection
   });
 
   const connectionLinePath =
-    edge && kieEdgePath.points
+    edgeBeingUpdated && kieEdgePath.points
       ? isUpdatingFromSourceHandle
         ? pointsToPath([{ "@_x": toX, "@_y": toY }, 
...kieEdgePath.points.slice(1)]) // First point is being dragged
         : pointsToPath([...kieEdgePath.points.slice(0, -1), { "@_x": toX, 
"@_y": toY }]) // Last point is being dragged
       : `M${fromX},${fromY} L${toX},${toY}`;
 
-  const handleId = isUpdatingFromSourceHandle ? edge?.type : fromHandle?.id;
+  const handleId = isUpdatingFromSourceHandle ? edgeBeingUpdated?.type : 
edgeBeingUpdated?.type ?? fromHandle?.id;
 
   // Edges
   if (handleId === EDGE_TYPES.informationRequirement) {
@@ -97,14 +97,14 @@ export function ConnectionLine({ toX, toY, fromNode, 
fromHandle }: RF.Connection
       { x: fromX, y: fromY, width: 1, height: 1 }
     );
 
-    const edge = getDefaultEdgeTypeBetween(fromNode?.type as NodeType, 
handleId as NodeType);
-    if (!edge) {
+    const edgeType = getDefaultEdgeTypeBetween(fromNode?.type as NodeType, 
handleId as NodeType);
+    if (!edgeType) {
       throw new Error(`Invalid structure: ${fromNode?.type} --(any)--> 
${handleId}`);
     }
 
     const path = `M${fromX},${fromY} L${toXauto},${toYauto}`;
 
-    const edgeSvg = switchExpression(edge, {
+    const edgeSvg = switchExpression(edgeType, {
       [EDGE_TYPES.informationRequirement]: <InformationRequirementPath 
d={path} />,
       [EDGE_TYPES.knowledgeRequirement]: <KnowledgeRequirementPath d={path} />,
       [EDGE_TYPES.authorityRequirement]: <AuthorityRequirementPath d={path} 
centerToConnectionPoint={false} />,
diff --git a/packages/dmn-editor/src/mutations/addConnectedNode.ts 
b/packages/dmn-editor/src/mutations/addConnectedNode.ts
index 769e536179a..ca57bc17eb5 100644
--- a/packages/dmn-editor/src/mutations/addConnectedNode.ts
+++ b/packages/dmn-editor/src/mutations/addConnectedNode.ts
@@ -43,13 +43,13 @@ export function addConnectedNode({
   drdIndex,
   sourceNode,
   newNode,
-  edge,
+  edgeType,
 }: {
   definitions: DMN15__tDefinitions;
   drdIndex: number;
   sourceNode: { type: NodeType; href: string; bounds: DC__Bounds; shapeId: 
string | undefined };
   newNode: { type: NodeType; bounds: DC__Bounds };
-  edge: EdgeType;
+  edgeType: EdgeType;
 }) {
   const newDmnObjectId = generateUuid();
   const newDmnObjectHref = buildXmlHref({ id: newDmnObjectId });
@@ -57,7 +57,7 @@ export function addConnectedNode({
   const nature = nodeNatures[newNode.type];
 
   if (nature === NodeNature.DRG_ELEMENT) {
-    const requirements = getRequirementsFromEdge(sourceNode, newEdgeId, edge);
+    const requirements = getRequirementsFromEdge(sourceNode, newEdgeId, 
edgeType);
 
     definitions.drgElement ??= [];
     const variableBase = {


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

Reply via email to