tiagobento commented on code in PR #2508:
URL:
https://github.com/apache/incubator-kie-tools/pull/2508#discussion_r1745885743
##########
packages/dmn-editor/src/store/computed/computeContainingDecisionServiceHrefsByDecisionHrefs.ts.ts:
##########
@@ -23,45 +23,45 @@ import { State } from "../Store";
export function computeContainingDecisionServiceHrefsByDecisionHrefs({
thisDmnsNamespace,
- drgElementsNamespace,
- drgElements,
+ drgElementsNamespaceByNamespace,
Review Comment:
This new name doesn't make much sense to me. Would you mind explaining it
please?
##########
packages/dmn-editor/src/propertiesPanel/DecisionServiceProperties.tsx:
##########
@@ -70,10 +74,23 @@ export function DecisionServiceProperties({
(s) =>
s.computed(s).getExternalModelTypesByNamespace(externalModelsByNamespace).dmns
);
+ const allExternalDmns = Object.entries(externalModelsByNamespace ??
{}).reduce((acc, [namespace, externalModel]) => {
+ if (!externalModel) {
+ console.warn(`DMN EDITOR: Could not find model with namespace
'${namespace}'. Ignoring.`);
+ return acc;
+ } else {
+ if (externalModel.type === "dmn") {
+ acc.push(externalModel);
+ }
+
+ return acc;
+ }
+ }, new Array<Normalized<ExternalDmn>>());
Review Comment:
Please check hook dependencies.
##########
packages/dmn-editor/src/mutations/addEdge.ts:
##########
@@ -188,7 +190,7 @@ export function addEdge({
// Replace with the new one.
diagramElements.push(newDmnEdge);
- repopulateInputDataAndDecisionsOnAllDecisionServices({ definitions });
+ repopulateInputDataAndDecisionsOnAllDecisionServices({ definitions,
externalModelsByNamespace: undefined });
Review Comment:
This doesn't look right..
##########
packages/dmn-editor-envelope/src/DmnEditorRoot.tsx:
##########
@@ -645,6 +734,19 @@ function ExternalModelsManager({
}
}
+ const dmnsByNamespace = getDmnsByNamespace(resources);
+ for (const dmn of dmnsByNamespace.values()) {
+ const content = dmn.content ?? "";
+ const model = normalize(getMarshaller(content, { upgradeTo: "latest"
}).parser.parse());
+ loadDependentModels(
+ model,
+ externalModelsIndex,
+ dmnsByNamespace,
+ loadedDmnsByPathRelativeToTheWorkspaceRoot,
+ thisDmnsNormalizedPosixPathRelativeToTheWorkspaceRoot
+ );
+ }
Review Comment:
Missing hook dependencies.
##########
packages/dmn-editor/src/propertiesPanel/DecisionServiceProperties.tsx:
##########
@@ -70,10 +74,23 @@ export function DecisionServiceProperties({
(s) =>
s.computed(s).getExternalModelTypesByNamespace(externalModelsByNamespace).dmns
);
+ const allExternalDmns = Object.entries(externalModelsByNamespace ??
{}).reduce((acc, [namespace, externalModel]) => {
+ if (!externalModel) {
+ console.warn(`DMN EDITOR: Could not find model with namespace
'${namespace}'. Ignoring.`);
+ return acc;
+ } else {
+ if (externalModel.type === "dmn") {
+ acc.push(externalModel);
+ }
+
+ return acc;
+ }
Review Comment:
```suggestion
if (!externalModel) {
console.warn(`DMN EDITOR: Could not find model with namespace
'${namespace}'. Ignoring.`);
return acc;
}
if (externalModel.type === "dmn") {
acc.push(externalModel);
}
return acc;
```
##########
packages/dmn-editor/src/store/computed/computeContainingDecisionServiceHrefsByDecisionHrefs.ts.ts:
##########
@@ -23,45 +23,45 @@ import { State } from "../Store";
export function computeContainingDecisionServiceHrefsByDecisionHrefs({
thisDmnsNamespace,
- drgElementsNamespace,
- drgElements,
+ drgElementsNamespaceByNamespace,
}: {
thisDmnsNamespace: string;
- drgElementsNamespace: string;
- drgElements: State["dmn"]["model"]["definitions"]["drgElement"];
+ drgElementsNamespaceByNamespace: Map<string,
State["dmn"]["model"]["definitions"]["drgElement"]>;
}) {
- drgElements ??= [];
+ drgElementsNamespaceByNamespace ??= new Map();
Review Comment:
The type of this parameter says it can never be undefined, so this line
doesn't really do anything.
##########
packages/dmn-editor/src/diagram/Diagram.tsx:
##########
@@ -876,6 +879,7 @@ export const Diagram = React.forwardRef<DiagramRef, {
container: React.RefObject
__readonly_externalModelTypesByNamespace: state
.computed(state)
.getExternalModelTypesByNamespace(externalModelsByNamespace),
+ externalModelsByNamespace,
Review Comment:
React hook dependency missing.
--
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]