Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kie-issues#1298: Decision Services & multiple DRDs: make it possible o add external Decisions to a Decision Service #2508

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
b690ebb
kie-issues#1298: Decision Services & multiple DRDs: make it possible …
danielzhe Jul 31, 2024
33de8ea
Tests e2e
danielzhe Aug 2, 2024
2db60f6
webkit
danielzhe Aug 2, 2024
b55113d
Code review. More tests. Fixed an issue about moving nodes from DS to…
danielzhe Aug 5, 2024
24f1b15
Tests screenshots 1
danielzhe Aug 5, 2024
f916099
Tests screenshots 2
danielzhe Aug 5, 2024
99924ea
Tests screenshots 3
danielzhe Aug 6, 2024
d64a04e
Better screenshots for test.
danielzhe Aug 6, 2024
a078041
Mutations now does not count with "correct parameters".
danielzhe Aug 6, 2024
c9f88bf
Href.
danielzhe Aug 7, 2024
411e61d
Merge branch 'main' into included-ds
danielzhe Aug 7, 2024
6cd536f
Update packages/dmn-editor/src/mutations/addDecisionToDecisionService.ts
danielzhe Aug 7, 2024
a44b7da
Update packages/dmn-editor/src/diagram/Diagram.tsx
danielzhe Aug 7, 2024
fad6167
Update packages/dmn-editor/src/mutations/deleteDecisionFromDecisionSe…
danielzhe Aug 7, 2024
3ee4271
Fix build error (??????)
danielzhe Aug 7, 2024
a84bea2
Merge branch 'main' into included-ds
danielzhe Aug 9, 2024
90c03ff
Fixed the invocation string
danielzhe Aug 14, 2024
c3c23dd
Merge branch 'main' into included-ds
danielzhe Aug 14, 2024
54b419c
Fixed hooks
danielzhe Aug 19, 2024
40a0fdf
Merge branch 'main' into included-ds
danielzhe Aug 22, 2024
227ee5a
Merge branch 'main' into included-ds
danielzhe Sep 2, 2024
3d8abb5
Handles 3rd level of included models
danielzhe Sep 2, 2024
9d7a04e
Fix
danielzhe Sep 3, 2024
a5f3e71
Update packages/dmn-editor/src/propertiesPanel/DecisionServicePropert…
danielzhe Sep 5, 2024
8bbb1cf
Fixing hooks and renaming variable
danielzhe Sep 5, 2024
81d260f
Reduce nesting. Remove unused parameters.
danielzhe Sep 9, 2024
1bdc614
.
tiagobento Sep 11, 2024
ffa1867
Merge pull request #8 from tiagobento/included-ds-pair-programming-da…
danielzhe Sep 11, 2024
2921171
Merge branch 'main' into included-ds
danielzhe Sep 11, 2024
e22fcd1
Refactor DmnEditorRoot
danielzhe Sep 12, 2024
3cb35a5
Refactor DmnEditorRoot
danielzhe Sep 12, 2024
334cf35
Clean
danielzhe Sep 12, 2024
bd5786c
clean
danielzhe Sep 12, 2024
0e90a76
Update packages/dmn-editor/src/mutations/deleteImport.ts
danielzhe Sep 19, 2024
a03e182
Fixes issues 3 and 4
danielzhe Sep 25, 2024
d9408e7
decisionHref
danielzhe Sep 25, 2024
4759ae3
hook
danielzhe Sep 25, 2024
91a815f
Revert
danielzhe Sep 26, 2024
702f44f
Fix 3 and 4 issues
danielzhe Sep 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
230 changes: 180 additions & 50 deletions packages/dmn-editor-envelope/src/DmnEditorRoot.tsx

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion packages/dmn-editor/src/DmnEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,9 @@ export const DmnEditorInternal = ({
</Tab>

<Tab eventKey={DmnEditorTab.INCLUDED_MODELS} title={tabTitle.includedModels}>
{navigationTab === DmnEditorTab.INCLUDED_MODELS && <IncludedModels />}
<div data-testid={"kie-tools--dmn-editor--included-models-container"}>
{navigationTab === DmnEditorTab.INCLUDED_MODELS && <IncludedModels />}
</div>
</Tab>
</Tabs>
</div>
Expand Down
5 changes: 4 additions & 1 deletion packages/dmn-editor/src/autolayout/AutolayoutButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ export function AutolayoutButton() {
__readonly_parentNodesById,
__readonly_drdIndex: s.computed(s).getDrdIndex(),
__readonly_dmnObjectNamespace: s.dmn.model.definitions["@_namespace"],
__readonly_externalDmnsIndex: s.computed(s).getExternalModelTypesByNamespace(externalModelsByNamespace).dmns,
__readonly_externalDmnsIndex: s
.computed(s)
.getDirectlyIncludedExternalModelsByNamespace(externalModelsByNamespace).dmns,
__readonly_externalModelsByNamespace: externalModelsByNamespace,
});
});
}, [dmnEditorStoreApi, externalModelsByNamespace]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ export function BoxedExpressionScreen({ container }: { container: React.RefObjec
const isPropertiesPanelOpen = useDmnEditorStore((s) => s.boxedExpressionEditor.propertiesPanel.isOpen);

const externalDmnsByNamespace = useDmnEditorStore(
(s) => s.computed(s).getExternalModelTypesByNamespace(externalModelsByNamespace).dmns
(s) => s.computed(s).getDirectlyIncludedExternalModelsByNamespace(externalModelsByNamespace).dmns
);
const dataTypesTree = useDmnEditorStore((s) => s.computed(s).getDataTypes(externalModelsByNamespace).dataTypesTree);
const importsByNamespace = useDmnEditorStore((s) => s.computed(s).importsByNamespace());
const externalPmmlsByNamespace = useDmnEditorStore(
(s) => s.computed(s).getExternalModelTypesByNamespace(externalModelsByNamespace).pmmls
(s) => s.computed(s).getDirectlyIncludedExternalModelsByNamespace(externalModelsByNamespace).pmmls
);
const isAlternativeInputDataShape = useDmnEditorStore((s) => s.computed(s).isAlternativeInputDataShape());
const drdIndex = useDmnEditorStore((s) => s.computed(s).getDrdIndex());
Expand Down
42 changes: 28 additions & 14 deletions packages/dmn-editor/src/diagram/Diagram.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@
shapeId: targetNode.data.shape["@_id"],
},
keepWaypoints: false,
externalModelsByNamespace,
});
});
},
Expand Down Expand Up @@ -337,6 +338,7 @@
})["@_height"],
},
},
externalModelsByNamespace,
});
state.diagram._selectedNodes = [newNodeId];
state.focus.consumableId = newNodeId;
Expand All @@ -352,7 +354,7 @@
const state = dmnEditorStoreApi.getState();
const externalDmnsIndex = state
.computed(state)
.getExternalModelTypesByNamespace(externalModelsByNamespace).dmns;
.getDirectlyIncludedExternalModelsByNamespace(externalModelsByNamespace).dmns;

const externalNodeDmn = externalDmnsIndex.get(externalNode.externalDrgElementNamespace);
const externalDrgElement = (externalNodeDmn?.model.definitions.drgElement ?? []).find(
Expand Down Expand Up @@ -429,7 +431,7 @@
__readonly_drdIndex: drdIndex,
__readonly_externalDmnsIndex: dereferencedState
.computed(dereferencedState)
.getExternalModelTypesByNamespace(externalModelsByNamespace).dmns,
.getDirectlyIncludedExternalModelsByNamespace(externalModelsByNamespace).dmns,
__readonly_indexedDrd: dereferencedState.computed(dereferencedState).indexedDrd(),
__readonly_indexedDrdContainingDecisionServiceDepiction: indexedDrdContainingDecisionServiceDepiction!,
__readonly_containedDecisionHrefsRelativeToThisDmn: containedDecisionHrefsRelativeToThisDmn,
Expand Down Expand Up @@ -481,7 +483,7 @@
const drdIndex = dereferencedState.computed(dereferencedState).getDrdIndex();
const externalDmnsIndex = dereferencedState
.computed(dereferencedState)
.getExternalModelTypesByNamespace(externalModelsByNamespace).dmns;
.getDirectlyIncludedExternalModelsByNamespace(externalModelsByNamespace).dmns;

const {
strategyForAddingDecisionServiceToDrd,
Expand Down Expand Up @@ -528,7 +530,7 @@
__readonly_drdIndex: drdIndex,
__readonly_externalDmnsIndex: dereferencedState
.computed(dereferencedState)
.getExternalModelTypesByNamespace(externalModelsByNamespace).dmns,
.getDirectlyIncludedExternalModelsByNamespace(externalModelsByNamespace).dmns,
__readonly_indexedDrd: dereferencedState.computed(dereferencedState).indexedDrd(),
__readonly_indexedDrdContainingDecisionServiceDepiction: indexedDrdContainingDecisionServiceDepiction!,
__readonly_containedDecisionHrefsRelativeToThisDmn: containedDecisionHrefsRelativeToThisDmn,
Expand Down Expand Up @@ -670,6 +672,7 @@
})["@_height"],
},
},
externalModelsByNamespace,
});

state.diagram._selectedNodes = [newDmnObejctHref];
Expand Down Expand Up @@ -754,7 +757,7 @@
__readonly_dmnObjectNamespace: node.data.dmnObjectNamespace,
__readonly_externalDmnsIndex: state
.computed(state)
.getExternalModelTypesByNamespace(externalModelsByNamespace).dmns,
.getDirectlyIncludedExternalModelsByNamespace(externalModelsByNamespace).dmns,
change: {
isExternal: !!node.data.dmnObjectQName.prefix,
nodeType: node.type as NodeType,
Expand Down Expand Up @@ -872,10 +875,11 @@
__readonly_dmnObjectQName: node.data.dmnObjectQName,
__readonly_dmnObjectId: node.data.dmnObject?.["@_id"],
__readonly_nodeNature: nodeNatures[node.type as NodeType],
mode: NodeDeletionMode.FROM_DRG_AND_ALL_DRDS,
__readonly_externalModelTypesByNamespace: state
__readonly_mode: NodeDeletionMode.FROM_DRG_AND_ALL_DRDS,
__readonly_externalDmnsIndex: state
.computed(state)
.getExternalModelTypesByNamespace(externalModelsByNamespace),
.getDirectlyIncludedExternalModelsByNamespace(externalModelsByNamespace).dmns,
__readonly_externalModelsByNamespace: externalModelsByNamespace,
});
state.dispatch(state).diagram.setNodeStatus(node.id, {
selected: false,
Expand All @@ -897,7 +901,7 @@
}
});
},
[reactFlowInstance, dmnEditorStoreApi, externalModelsByNamespace]
[dmnEditorStoreApi, externalModelsByNamespace]
);

const resetToBeforeEditingBegan = useCallback(() => {
Expand Down Expand Up @@ -990,8 +994,9 @@
for (let i = 0; i < selectedNodes.length; i++) {
deleteDecisionFromDecisionService({
definitions: state.dmn.model.definitions,
decisionId: selectedNodes[i].data.dmnObject!["@_id"]!, // We can assume that all selected nodes are Decisions because the contaiment was validated above.
decisionHref: selectedNodes[i].id, // We can assume that all selected nodes are Decisions because the contaiment was validated above.
decisionServiceId: p.data.dmnObject!["@_id"]!,
externalModelsByNamespace,
});
}
} else {
Expand All @@ -1007,12 +1012,13 @@
addDecisionToDecisionService({
definitions: state.dmn.model.definitions,
drdIndex: state.computed(state).getDrdIndex(),
decisionId: selectedNodes[i].data.dmnObject!["@_id"]!, // We can assume that all selected nodes are Decisions because the contaiment was validated above.
decisionHref: selectedNodes[i].id, // We can assume that all selected nodes are Decisions because the contaiment was validated above.
decisionServiceId: state
.computed(state)
.getDiagramData(externalModelsByNamespace)
.nodesById.get(dropTargetNode.id)!.data.dmnObject!["@_id"]!,
snapGrid: state.diagram.snapGrid,
externalModelsByNamespace,
});
}
} else {
Expand All @@ -1026,7 +1032,7 @@
resetToBeforeEditingBegan();
}
},
[dmnEditorStoreApi, externalModelsByNamespace, resetToBeforeEditingBegan]
[dmnEditorStoreApi, externalModelsByNamespace, resetToBeforeEditingBegan, thisDmn.model.definitions]

Check warning on line 1035 in packages/dmn-editor/src/diagram/Diagram.tsx

View workflow job for this annotation

GitHub Actions / run (ubuntu-latest, 2)

React Hook useCallback has an unnecessary dependency: 'thisDmn.model.definitions'. Either exclude it or remove the dependency array

Check warning on line 1035 in packages/dmn-editor/src/diagram/Diagram.tsx

View workflow job for this annotation

GitHub Actions / run (macos-13, 2)

React Hook useCallback has an unnecessary dependency: 'thisDmn.model.definitions'. Either exclude it or remove the dependency array

Check warning on line 1035 in packages/dmn-editor/src/diagram/Diagram.tsx

View workflow job for this annotation

GitHub Actions / run (windows-latest, 2)

React Hook useCallback has an unnecessary dependency: 'thisDmn.model.definitions'. Either exclude it or remove the dependency array
);

const onEdgesChange = useCallback<RF.OnEdgesChange>(
Expand All @@ -1047,6 +1053,7 @@
drdIndex: state.computed(state).getDrdIndex(),
edge: { id: change.id, dmnObject: edge.data.dmnObject },
mode: EdgeDeletionMode.FROM_DRG_AND_ALL_DRDS,
externalModelsByNamespace,
});
state.dispatch(state).diagram.setEdgeStatus(change.id, {
selected: false,
Expand Down Expand Up @@ -1125,6 +1132,7 @@
shapeId: targetNode.data.shape["@_id"],
},
keepWaypoints: true,
externalModelsByNamespace,
});

// The DMN Edge changed nodes, so we need to delete the old one, but keep the waypoints on the same DRD.
Expand All @@ -1134,6 +1142,7 @@
drdIndex: state.computed(state).getDrdIndex(),
edge: { id: oldEdge.id, dmnObject: oldEdge.data!.dmnObject },
mode: EdgeDeletionMode.FROM_DRG_AND_ALL_DRDS,
externalModelsByNamespace,
});

const deletedWaypoints = deletedDmnEdgeOnCurrentDrd?.["di:waypoint"];
Expand Down Expand Up @@ -1380,7 +1389,7 @@

const externalModelTypesByNamespace = dereferencedState
.computed(dereferencedState)
.getExternalModelTypesByNamespace(externalModelsByNamespace);
.getDirectlyIncludedExternalModelsByNamespace(externalModelsByNamespace);

autoGenerateDrd({
model: dereferencedState.dmn.model,
Expand Down Expand Up @@ -1434,7 +1443,8 @@
__readonly_dmnObjectNamespace: dereferencedState.dmn.model.definitions["@_namespace"],
__readonly_externalDmnsIndex: dereferencedState
.computed(dereferencedState)
.getExternalModelTypesByNamespace(externalModelsByNamespace).dmns,
.getDirectlyIncludedExternalModelsByNamespace(externalModelsByNamespace).dmns,
__readonly_externalModelsByNamespace: externalModelsByNamespace,
});
s.dmn.model = dereferencedState.dmn.model;
});
Expand Down Expand Up @@ -1463,6 +1473,7 @@
isReadOnly?: boolean;
}) {
const dmnEditorStoreApi = useDmnEditorStoreApi();
const { externalModelsByNamespace } = useExternalModels();

return (
<Bullseye
Expand Down Expand Up @@ -1524,6 +1535,7 @@
})["@_height"],
},
},
externalModelsByNamespace,
});

const drgElementIndex = (state.dmn.model.definitions.drgElement ?? []).length - 1;
Expand Down Expand Up @@ -1584,6 +1596,7 @@
type: NODE_TYPES.inputData,
bounds: inputDataNodeBounds,
},
externalModelsByNamespace,
});

const { href: decisionNodeHref } = addConnectedNode({
Expand All @@ -1609,6 +1622,7 @@
})["@_height"],
},
},
externalModelsByNamespace,
});

state.diagram._selectedNodes = [decisionNodeHref];
Expand Down
49 changes: 35 additions & 14 deletions packages/dmn-editor/src/diagram/DiagramCommands.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export function DiagramCommands(props: {}) {
drdIndex: state.computed(state).getDrdIndex(),
edge: { id: edge.id, dmnObject: edge.data!.dmnObject },
mode: EdgeDeletionMode.FROM_DRG_AND_ALL_DRDS,
externalModelsByNamespace,
});
state.dispatch(state).diagram.setEdgeStatus(edge.id, {
selected: false,
Expand All @@ -156,10 +157,11 @@ export function DiagramCommands(props: {}) {
__readonly_dmnObjectQName: node.data.dmnObjectQName,
__readonly_dmnObjectId: node.data.dmnObject?.["@_id"],
__readonly_nodeNature: nodeNatures[node.type as NodeType],
mode: NodeDeletionMode.FROM_DRG_AND_ALL_DRDS,
__readonly_externalModelTypesByNamespace: state
__readonly_mode: NodeDeletionMode.FROM_DRG_AND_ALL_DRDS,
__readonly_externalDmnsIndex: state
.computed(state)
.getExternalModelTypesByNamespace(externalModelsByNamespace),
.getDirectlyIncludedExternalModelsByNamespace(externalModelsByNamespace).dmns,
__readonly_externalModelsByNamespace: externalModelsByNamespace,
});
state.dispatch(state).diagram.setNodeStatus(node.id, {
selected: false,
Expand Down Expand Up @@ -239,12 +241,25 @@ export function DiagramCommands(props: {}) {
definitions: state.dmn.model.definitions,
drdIndex: state.computed(state).getDrdIndex(),
});
diagramElements.push(...clipboard.shapes.map((s) => ({ ...s, __$$element: "dmndi:DMNShape" as const })));
diagramElements.push(...clipboard.edges.map((s) => ({ ...s, __$$element: "dmndi:DMNEdge" as const })));
diagramElements.push(
...clipboard.shapes.map((s) => ({
...s,
__$$element: "dmndi:DMNShape" as const,
}))
);
diagramElements.push(
...clipboard.edges.map((s) => ({
...s,
__$$element: "dmndi:DMNEdge" as const,
}))
);

widths.push(...clipboard.widths);

repopulateInputDataAndDecisionsOnAllDecisionServices({ definitions: state.dmn.model.definitions });
repopulateInputDataAndDecisionsOnAllDecisionServices({
definitions: state.dmn.model.definitions,
externalModelsByNamespace,
});

state.diagram._selectedNodes = [...clipboard.drgElements, ...clipboard.artifacts].map((s) =>
buildXmlHref({ id: s["@_id"]! })
Expand All @@ -256,7 +271,7 @@ export function DiagramCommands(props: {}) {
});
});
};
}, [dmnEditorStoreApi, commandsRef]);
}, [dmnEditorStoreApi, commandsRef, externalModelsByNamespace]);

// Select/deselect all nodes
useEffect(() => {
Expand Down Expand Up @@ -317,12 +332,13 @@ export function DiagramCommands(props: {}) {
padding: CONTAINER_NODES_DESIRABLE_PADDING,
}),
},
externalModelsByNamespace,
});

state.dispatch(state).diagram.setNodeStatus(newNodeId, { selected: true });
});
};
}, [dmnEditorStoreApi, commandsRef, rf]);
}, [dmnEditorStoreApi, commandsRef, rf, externalModelsByNamespace]);

// Toggle hierarchy highlights
useEffect(() => {
Expand Down Expand Up @@ -369,7 +385,7 @@ export function DiagramCommands(props: {}) {
canRemoveNodeFromDrdOnly({
__readonly_externalDmnsIndex: state
.computed(state)
.getExternalModelTypesByNamespace(externalModelsByNamespace).dmns,
.getDirectlyIncludedExternalModelsByNamespace(externalModelsByNamespace).dmns,
definitions: state.dmn.model.definitions,
__readonly_drdIndex: state.computed(state).getDrdIndex(),
__readonly_dmnObjectNamespace:
Expand All @@ -380,7 +396,7 @@ export function DiagramCommands(props: {}) {
canRemoveNodeFromDrdOnly({
__readonly_externalDmnsIndex: state
.computed(state)
.getExternalModelTypesByNamespace(externalModelsByNamespace).dmns,
.getDirectlyIncludedExternalModelsByNamespace(externalModelsByNamespace).dmns,
definitions: state.dmn.model.definitions,
__readonly_drdIndex: state.computed(state).getDrdIndex(),
__readonly_dmnObjectNamespace:
Expand All @@ -393,8 +409,12 @@ export function DiagramCommands(props: {}) {
drdIndex: state.computed(state).getDrdIndex(),
edge: { id: edge.id, dmnObject: edge.data!.dmnObject },
mode: EdgeDeletionMode.FROM_CURRENT_DRD_ONLY,
externalModelsByNamespace,
});
state.dispatch(state).diagram.setEdgeStatus(edge.id, {
selected: false,
draggingWaypoint: false,
});
state.dispatch(state).diagram.setEdgeStatus(edge.id, { selected: false, draggingWaypoint: false });
}
}

Expand All @@ -406,15 +426,16 @@ export function DiagramCommands(props: {}) {
const { deletedDmnShapeOnCurrentDrd: deletedShape } = deleteNode({
definitions: state.dmn.model.definitions,
__readonly_drgEdges: [], // Deleting from DRD only.
__readonly_externalModelTypesByNamespace: state
__readonly_externalDmnsIndex: state
.computed(state)
.getExternalModelTypesByNamespace(externalModelsByNamespace),
.getDirectlyIncludedExternalModelsByNamespace(externalModelsByNamespace).dmns,
__readonly_drdIndex: state.computed(state).getDrdIndex(),
__readonly_dmnObjectNamespace: node.data.dmnObjectNamespace ?? state.dmn.model.definitions["@_namespace"],
__readonly_dmnObjectQName: node.data.dmnObjectQName,
__readonly_dmnObjectId: node.data.dmnObject?.["@_id"],
__readonly_nodeNature: nodeNatures[node.type as NodeType],
mode: NodeDeletionMode.FROM_CURRENT_DRD_ONLY,
__readonly_mode: NodeDeletionMode.FROM_CURRENT_DRD_ONLY,
__readonly_externalModelsByNamespace: externalModelsByNamespace,
});

if (deletedShape) {
Expand Down
Loading
Loading