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


##########
packages/scesim-editor/src/drawer/TestScenarioDrawerSettingsPanel.tsx:
##########
@@ -27,21 +28,104 @@ import { TextInput } from 
"@patternfly/react-core/dist/js/components/TextInput";
 import { Title } from "@patternfly/react-core/dist/js/components/Title";
 import { Tooltip } from "@patternfly/react-core/dist/esm/components/Tooltip";
 
+import { useCancelableEffect } from 
"@kie-tools-core/react-hooks/dist/useCancelableEffect";
+
 import { SceSim__settingsType } from 
"@kie-tools/scesim-marshaller/dist/schemas/scesim-1_8/ts-gen/types";
 
 import { useTestScenarioEditorI18n } from "../i18n";
 import { useTestScenarioEditorStore, useTestScenarioEditorStoreApi } from 
"../store/TestScenarioStoreContext";
+import { useExternalModels } from 
"../externalModels/TestScenarioEditorDependenciesContext";
+import { ExternalDmn } from "../TestScenarioEditor";
+import { useTestScenarioEditor } from "../TestScenarioEditorContext";
 
 import "./TestScenarioDrawerSettingsPanel.css";
-import { useTestScenarioEditor } from "../TestScenarioEditorContext";
 
 function TestScenarioDrawerSettingsPanel() {
   const { i18n } = useTestScenarioEditorI18n();
   const { openFileNormalizedPosixPathRelativeToTheWorkspaceRoot } = 
useTestScenarioEditor();
+  const { onRequestExternalModelsAvailableToInclude, 
onRequestExternalModelByPath } = useExternalModels();
+  const [allDmnModelNormalizedPosixRelativePaths, 
setAllDmnModelNormalizedPosixRelativePaths] = useState<
+    string[] | undefined
+  >(undefined);
+  const [callBackError, setCallBackError] = useState<any>(undefined);

Review Comment:
   "callBackError" is not really a very descriptive name. WDYT about 
"dmnNotFoundError"?



##########
packages/scesim-editor/src/drawer/TestScenarioDrawerSettingsPanel.tsx:
##########
@@ -27,21 +28,104 @@ import { TextInput } from 
"@patternfly/react-core/dist/js/components/TextInput";
 import { Title } from "@patternfly/react-core/dist/js/components/Title";
 import { Tooltip } from "@patternfly/react-core/dist/esm/components/Tooltip";
 
+import { useCancelableEffect } from 
"@kie-tools-core/react-hooks/dist/useCancelableEffect";
+
 import { SceSim__settingsType } from 
"@kie-tools/scesim-marshaller/dist/schemas/scesim-1_8/ts-gen/types";
 
 import { useTestScenarioEditorI18n } from "../i18n";
 import { useTestScenarioEditorStore, useTestScenarioEditorStoreApi } from 
"../store/TestScenarioStoreContext";
+import { useExternalModels } from 
"../externalModels/TestScenarioEditorDependenciesContext";
+import { ExternalDmn } from "../TestScenarioEditor";
+import { useTestScenarioEditor } from "../TestScenarioEditorContext";
 
 import "./TestScenarioDrawerSettingsPanel.css";
-import { useTestScenarioEditor } from "../TestScenarioEditorContext";
 
 function TestScenarioDrawerSettingsPanel() {
   const { i18n } = useTestScenarioEditorI18n();
   const { openFileNormalizedPosixPathRelativeToTheWorkspaceRoot } = 
useTestScenarioEditor();
+  const { onRequestExternalModelsAvailableToInclude, 
onRequestExternalModelByPath } = useExternalModels();
+  const [allDmnModelNormalizedPosixRelativePaths, 
setAllDmnModelNormalizedPosixRelativePaths] = useState<
+    string[] | undefined
+  >(undefined);
+  const [callBackError, setCallBackError] = useState<any>(undefined);
   const settingsModel = useTestScenarioEditorStore((state) => 
state.scesim.model.ScenarioSimulationModel.settings);
+  const [selectedDMNPathRelativeToThisScesim, 
setSelectedDMNPathRelativeToThisScesim] = useState<string | undefined>(
+    settingsModel.dmnFilePath?.__$$text
+  );
   const testScenarioEditorStoreApi = useTestScenarioEditorStoreApi();
   const testScenarioType = settingsModel.type?.__$$text.toUpperCase();
 
+  const [selectedDmnModel, setSelectedDmnModel] = useState<ExternalDmn | 
undefined>(undefined);
+
+  /* Retrieving all the DMN available in the project */
+  useCancelableEffect(
+    useCallback(
+      ({ canceled }) => {
+        onRequestExternalModelsAvailableToInclude?.()
+          .then((paths) => {
+            if (canceled.get()) {
+              return;
+            }
+            setAllDmnModelNormalizedPosixRelativePaths(
+              paths.sort((modelA, modelB) => 
basename(modelA).localeCompare(basename(modelB)))
+            );
+          })
+          .catch((err) => {
+            console.error(err);
+          });
+      },
+      [onRequestExternalModelsAvailableToInclude]
+    )
+  );
+
+  /** This callback return the unmarshalled representation of a DMN model 
given its path */
+  useCancelableEffect(
+    useCallback(
+      ({ canceled }) => {
+        if (!selectedDMNPathRelativeToThisScesim || 
onRequestExternalModelByPath === undefined) {
+          return;
+        }
+        onRequestExternalModelByPath(selectedDMNPathRelativeToThisScesim)
+          .then((externalDMNModel) => {
+            console.trace("[TestScenarioDrawerSettingsPanel] The below 
external DMN model have been loaded");
+            console.trace(externalDMNModel);
+
+            if (canceled.get() || !externalDMNModel) {
+              setSelectedDmnModel(undefined);
+              return;
+            }
+
+            setSelectedDmnModel(externalDMNModel);
+            testScenarioEditorStoreApi.setState((state) => {
+              
state.scesim.model.ScenarioSimulationModel.settings.dmnFilePath!.__$$text =
+                selectedDMNPathRelativeToThisScesim;
+              
state.scesim.model.ScenarioSimulationModel.settings.dmnName!.__$$text =
+                externalDMNModel.model.definitions["@_name"];
+              
state.scesim.model.ScenarioSimulationModel.settings.dmnNamespace!.__$$text =
+                externalDMNModel.model.definitions["@_namespace"];
+            });
+            setCallBackError(undefined);
+          })
+          .catch((err) => {
+            setSelectedDmnModel(undefined);
+            setCallBackError(err);
+            console.error(
+              `[TestScenarioDrawerSettingsPanel] An error occurred when 
parsing the selected model '${selectedDMNPathRelativeToThisScesim}'. Please 
double-check it is a non-empty valid model.`
+            );
+            console.error(err);
+          });
+      },
+      [onRequestExternalModelByPath, selectedDMNPathRelativeToThisScesim, 
testScenarioEditorStoreApi]
+    )
+  );
+
+  const isSelectedDmnInvalid = useMemo(
+    () =>
+      callBackError !== undefined ||
+      selectedDmnModel?.normalizedPosixPathRelativeToTheOpenFile !== 
settingsModel.dmnFilePath?.__$$text,
+    [callBackError, 
selectedDmnModel?.normalizedPosixPathRelativeToTheOpenFile, 
settingsModel.dmnFilePath?.__$$text]
+  );

Review Comment:
   Maybe invert the negated variable? It's easier to understand when soemthing 
is "valid" than when it's "invalid". WDYT?



##########
packages/scesim-editor/src/creation/TestScenarioCreationPanel.tsx:
##########
@@ -37,45 +39,142 @@ import CubesIcon from 
"@patternfly/react-icons/dist/esm/icons/cubes-icon";
 import { useTestScenarioEditorStoreApi } from 
"../store/TestScenarioStoreContext";
 import { useTestScenarioEditorI18n } from "../i18n";
 
+import { useExternalModels } from 
"../externalModels/TestScenarioEditorDependenciesContext";
+import { ExternalDmn } from "../TestScenarioEditor";
+import { createNewDmnTypeTestScenario } from 
"../mutations/createNewDmnTypeTestScenario";
+import { createNewRuleTypeTestScenario } from 
"../mutations/createNewRuleTypeTestScenario";
+
 import "./TestScenarioCreationPanel.css";
 
 function TestScenarioCreationPanel() {
   const { i18n } = useTestScenarioEditorI18n();
+  const { onRequestExternalModelsAvailableToInclude, 
onRequestExternalModelByPath } = useExternalModels();
+  const testScenarioEditorStoreApi = useTestScenarioEditorStoreApi();
 
-  const assetsOption = [
-    { value: "", label: i18n.creationPanel.assetsOption.noChoice, disabled: 
true },
-    { value: "DMN", label: i18n.creationPanel.assetsOption.dmn, disabled: 
false },
-    { value: "RULE", label: i18n.creationPanel.assetsOption.rule, disabled: 
false },
-  ];
-
+  const [allDmnModelNormalizedPosixRelativePaths, 
setAllDmnModelNormalizedPosixRelativePaths] = useState<
+    string[] | undefined
+  >(undefined);
   const [assetType, setAssetType] = React.useState<"" | "DMN" | "RULE">("");
+  const [callBackError, setCallBackError] = useState<any>(undefined);
   const [isAutoFillTableEnabled, setAutoFillTableEnabled] = 
React.useState(true);
   const [isStatelessSessionRule, setStatelessSessionRule] = 
React.useState(false);
   const [isTestSkipped, setTestSkipped] = React.useState(false);
   const [kieSessionRule, setKieSessionRule] = React.useState("");
   const [ruleFlowGroup, setRuleFlowGroup] = React.useState("");
-  const testScenarioEditorStoreApi = useTestScenarioEditorStoreApi();
+  const [selectedDmnModel, setSelectedDmnModel] = useState<ExternalDmn | 
undefined>(undefined);
+  const [selectedDmnModelPathRelativeToThisScesim, 
setSelectedDmnModelPathRelativeToThisScesim] = useState<
+    string | undefined
+  >(undefined);
+
+  const assetsOption = [
+    { value: "", label: i18n.creationPanel.assetsOption.noChoice, disabled: 
true },
+    { value: "DMN", label: i18n.creationPanel.assetsOption.dmn, disabled: 
false },
+    { value: "RULE", label: i18n.creationPanel.assetsOption.rule, disabled: 
false },
+  ];
+
+  /** This callback retrieves all the avaiable DMN files available in the 
user's project */
+  useCancelableEffect(
+    useCallback(
+      ({ canceled }) => {
+        onRequestExternalModelsAvailableToInclude?.()
+          .then((dmnModelNormalizedPosixPathRelativePaths) => {
+            console.trace("[TestScenarioCreationPanel] The below external DMN 
models have been found");
+            console.trace(dmnModelNormalizedPosixPathRelativePaths);
+
+            if (canceled.get()) {
+              return;
+            }
+            setAllDmnModelNormalizedPosixRelativePaths(
+              dmnModelNormalizedPosixPathRelativePaths.sort((modelA, modelB) =>
+                basename(modelA).localeCompare(basename(modelB))
+              )
+            );
+          })
+          .catch((err) => {
+            setCallBackError(err);
+            console.error(
+              `[TestScenarioCreationPanel] The below error when trying to 
retrieve all the External DMN files from the project.`
+            );
+            console.error(err);
+          });
+      },
+      [onRequestExternalModelsAvailableToInclude]
+    )
+  );
+
+  /** This callback return the unmarshalled representation of a DMN model 
given its path */

Review Comment:
   Same.



##########
packages/scesim-editor/src/creation/TestScenarioCreationPanel.tsx:
##########
@@ -37,45 +39,142 @@ import CubesIcon from 
"@patternfly/react-icons/dist/esm/icons/cubes-icon";
 import { useTestScenarioEditorStoreApi } from 
"../store/TestScenarioStoreContext";
 import { useTestScenarioEditorI18n } from "../i18n";
 
+import { useExternalModels } from 
"../externalModels/TestScenarioEditorDependenciesContext";
+import { ExternalDmn } from "../TestScenarioEditor";
+import { createNewDmnTypeTestScenario } from 
"../mutations/createNewDmnTypeTestScenario";
+import { createNewRuleTypeTestScenario } from 
"../mutations/createNewRuleTypeTestScenario";
+
 import "./TestScenarioCreationPanel.css";
 
 function TestScenarioCreationPanel() {
   const { i18n } = useTestScenarioEditorI18n();
+  const { onRequestExternalModelsAvailableToInclude, 
onRequestExternalModelByPath } = useExternalModels();
+  const testScenarioEditorStoreApi = useTestScenarioEditorStoreApi();
 
-  const assetsOption = [
-    { value: "", label: i18n.creationPanel.assetsOption.noChoice, disabled: 
true },
-    { value: "DMN", label: i18n.creationPanel.assetsOption.dmn, disabled: 
false },
-    { value: "RULE", label: i18n.creationPanel.assetsOption.rule, disabled: 
false },
-  ];
-
+  const [allDmnModelNormalizedPosixRelativePaths, 
setAllDmnModelNormalizedPosixRelativePaths] = useState<
+    string[] | undefined
+  >(undefined);
   const [assetType, setAssetType] = React.useState<"" | "DMN" | "RULE">("");
+  const [callBackError, setCallBackError] = useState<any>(undefined);
   const [isAutoFillTableEnabled, setAutoFillTableEnabled] = 
React.useState(true);
   const [isStatelessSessionRule, setStatelessSessionRule] = 
React.useState(false);
   const [isTestSkipped, setTestSkipped] = React.useState(false);
   const [kieSessionRule, setKieSessionRule] = React.useState("");
   const [ruleFlowGroup, setRuleFlowGroup] = React.useState("");
-  const testScenarioEditorStoreApi = useTestScenarioEditorStoreApi();
+  const [selectedDmnModel, setSelectedDmnModel] = useState<ExternalDmn | 
undefined>(undefined);
+  const [selectedDmnModelPathRelativeToThisScesim, 
setSelectedDmnModelPathRelativeToThisScesim] = useState<
+    string | undefined
+  >(undefined);
+
+  const assetsOption = [
+    { value: "", label: i18n.creationPanel.assetsOption.noChoice, disabled: 
true },
+    { value: "DMN", label: i18n.creationPanel.assetsOption.dmn, disabled: 
false },
+    { value: "RULE", label: i18n.creationPanel.assetsOption.rule, disabled: 
false },
+  ];
+
+  /** This callback retrieves all the avaiable DMN files available in the 
user's project */
+  useCancelableEffect(
+    useCallback(
+      ({ canceled }) => {
+        onRequestExternalModelsAvailableToInclude?.()
+          .then((dmnModelNormalizedPosixPathRelativePaths) => {
+            console.trace("[TestScenarioCreationPanel] The below external DMN 
models have been found");
+            console.trace(dmnModelNormalizedPosixPathRelativePaths);
+
+            if (canceled.get()) {
+              return;
+            }
+            setAllDmnModelNormalizedPosixRelativePaths(
+              dmnModelNormalizedPosixPathRelativePaths.sort((modelA, modelB) =>
+                basename(modelA).localeCompare(basename(modelB))
+              )
+            );
+          })
+          .catch((err) => {
+            setCallBackError(err);
+            console.error(
+              `[TestScenarioCreationPanel] The below error when trying to 
retrieve all the External DMN files from the project.`
+            );
+            console.error(err);
+          });
+      },
+      [onRequestExternalModelsAvailableToInclude]
+    )
+  );
+
+  /** This callback return the unmarshalled representation of a DMN model 
given its path */
+  useCancelableEffect(
+    useCallback(
+      ({ canceled }) => {
+        if (!selectedDmnModelPathRelativeToThisScesim || 
onRequestExternalModelByPath === undefined) {
+          return;
+        }
+
+        onRequestExternalModelByPath(selectedDmnModelPathRelativeToThisScesim)
+          .then((externalDMNModel) => {
+            console.trace("[TestScenarioCreationPanel] The below external DMN 
model have been loaded");
+            console.trace(externalDMNModel);
+
+            if (canceled.get() || !externalDMNModel) {
+              return;
+            }
+
+            setSelectedDmnModel(externalDMNModel);
+          })
+          .catch((err) => {
+            setCallBackError(err);
+            console.error(
+              `[TestScenarioCreationPanel] An error occurred when parsing the 
selected model '${selectedDmnModelPathRelativeToThisScesim}'. Please 
double-check it is a non-empty valid model.`
+            );
+            console.error(err);
+          });
+      },
+      [onRequestExternalModelByPath, selectedDmnModelPathRelativeToThisScesim]
+    )
+  );
+
+  /* If any error occurs during the execution of useCancelableEffect's 
callback,    */
+  /* it throws the error that will be catched by the ErrorBoundary.            
     */
+  useEffect(() => {
+    if (callBackError) {
+      throw callBackError;
+    }
+  }, [callBackError]);

Review Comment:
   If we're letting error propagete, why do we need the `callBackError` state? 
Why not let them explode when they happen? Mapping errors as state is usually 
for a try/catch-like mechanism, when we want the screen to show a different UI 
for when errors occur.



##########
packages/scesim-editor/src/creation/TestScenarioCreationPanel.tsx:
##########
@@ -37,45 +39,142 @@ import CubesIcon from 
"@patternfly/react-icons/dist/esm/icons/cubes-icon";
 import { useTestScenarioEditorStoreApi } from 
"../store/TestScenarioStoreContext";
 import { useTestScenarioEditorI18n } from "../i18n";
 
+import { useExternalModels } from 
"../externalModels/TestScenarioEditorDependenciesContext";
+import { ExternalDmn } from "../TestScenarioEditor";
+import { createNewDmnTypeTestScenario } from 
"../mutations/createNewDmnTypeTestScenario";
+import { createNewRuleTypeTestScenario } from 
"../mutations/createNewRuleTypeTestScenario";
+
 import "./TestScenarioCreationPanel.css";
 
 function TestScenarioCreationPanel() {
   const { i18n } = useTestScenarioEditorI18n();
+  const { onRequestExternalModelsAvailableToInclude, 
onRequestExternalModelByPath } = useExternalModels();
+  const testScenarioEditorStoreApi = useTestScenarioEditorStoreApi();
 
-  const assetsOption = [
-    { value: "", label: i18n.creationPanel.assetsOption.noChoice, disabled: 
true },
-    { value: "DMN", label: i18n.creationPanel.assetsOption.dmn, disabled: 
false },
-    { value: "RULE", label: i18n.creationPanel.assetsOption.rule, disabled: 
false },
-  ];
-
+  const [allDmnModelNormalizedPosixRelativePaths, 
setAllDmnModelNormalizedPosixRelativePaths] = useState<
+    string[] | undefined
+  >(undefined);
   const [assetType, setAssetType] = React.useState<"" | "DMN" | "RULE">("");
+  const [callBackError, setCallBackError] = useState<any>(undefined);
   const [isAutoFillTableEnabled, setAutoFillTableEnabled] = 
React.useState(true);
   const [isStatelessSessionRule, setStatelessSessionRule] = 
React.useState(false);
   const [isTestSkipped, setTestSkipped] = React.useState(false);
   const [kieSessionRule, setKieSessionRule] = React.useState("");
   const [ruleFlowGroup, setRuleFlowGroup] = React.useState("");
-  const testScenarioEditorStoreApi = useTestScenarioEditorStoreApi();
+  const [selectedDmnModel, setSelectedDmnModel] = useState<ExternalDmn | 
undefined>(undefined);
+  const [selectedDmnModelPathRelativeToThisScesim, 
setSelectedDmnModelPathRelativeToThisScesim] = useState<
+    string | undefined
+  >(undefined);
+
+  const assetsOption = [
+    { value: "", label: i18n.creationPanel.assetsOption.noChoice, disabled: 
true },
+    { value: "DMN", label: i18n.creationPanel.assetsOption.dmn, disabled: 
false },
+    { value: "RULE", label: i18n.creationPanel.assetsOption.rule, disabled: 
false },
+  ];
+
+  /** This callback retrieves all the avaiable DMN files available in the 
user's project */

Review Comment:
   This is not a "callback", but rather an "effect". It doesn't return 
anything, it sets a state. 



##########
packages/scesim-editor/src/drawer/TestScenarioDrawerSettingsPanel.tsx:
##########
@@ -27,21 +28,104 @@ import { TextInput } from 
"@patternfly/react-core/dist/js/components/TextInput";
 import { Title } from "@patternfly/react-core/dist/js/components/Title";
 import { Tooltip } from "@patternfly/react-core/dist/esm/components/Tooltip";
 
+import { useCancelableEffect } from 
"@kie-tools-core/react-hooks/dist/useCancelableEffect";
+
 import { SceSim__settingsType } from 
"@kie-tools/scesim-marshaller/dist/schemas/scesim-1_8/ts-gen/types";
 
 import { useTestScenarioEditorI18n } from "../i18n";
 import { useTestScenarioEditorStore, useTestScenarioEditorStoreApi } from 
"../store/TestScenarioStoreContext";
+import { useExternalModels } from 
"../externalModels/TestScenarioEditorDependenciesContext";
+import { ExternalDmn } from "../TestScenarioEditor";
+import { useTestScenarioEditor } from "../TestScenarioEditorContext";
 
 import "./TestScenarioDrawerSettingsPanel.css";
-import { useTestScenarioEditor } from "../TestScenarioEditorContext";
 
 function TestScenarioDrawerSettingsPanel() {
   const { i18n } = useTestScenarioEditorI18n();
   const { openFileNormalizedPosixPathRelativeToTheWorkspaceRoot } = 
useTestScenarioEditor();
+  const { onRequestExternalModelsAvailableToInclude, 
onRequestExternalModelByPath } = useExternalModels();
+  const [allDmnModelNormalizedPosixRelativePaths, 
setAllDmnModelNormalizedPosixRelativePaths] = useState<
+    string[] | undefined
+  >(undefined);
+  const [callBackError, setCallBackError] = useState<any>(undefined);
   const settingsModel = useTestScenarioEditorStore((state) => 
state.scesim.model.ScenarioSimulationModel.settings);
+  const [selectedDMNPathRelativeToThisScesim, 
setSelectedDMNPathRelativeToThisScesim] = useState<string | undefined>(
+    settingsModel.dmnFilePath?.__$$text
+  );
   const testScenarioEditorStoreApi = useTestScenarioEditorStoreApi();
   const testScenarioType = settingsModel.type?.__$$text.toUpperCase();
 
+  const [selectedDmnModel, setSelectedDmnModel] = useState<ExternalDmn | 
undefined>(undefined);
+
+  /* Retrieving all the DMN available in the project */
+  useCancelableEffect(
+    useCallback(
+      ({ canceled }) => {
+        onRequestExternalModelsAvailableToInclude?.()
+          .then((paths) => {
+            if (canceled.get()) {
+              return;
+            }
+            setAllDmnModelNormalizedPosixRelativePaths(
+              paths.sort((modelA, modelB) => 
basename(modelA).localeCompare(basename(modelB)))
+            );
+          })
+          .catch((err) => {
+            console.error(err);
+          });
+      },
+      [onRequestExternalModelsAvailableToInclude]
+    )
+  );
+
+  /** This callback return the unmarshalled representation of a DMN model 
given its path */
+  useCancelableEffect(
+    useCallback(
+      ({ canceled }) => {
+        if (!selectedDMNPathRelativeToThisScesim || 
onRequestExternalModelByPath === undefined) {
+          return;
+        }
+        onRequestExternalModelByPath(selectedDMNPathRelativeToThisScesim)
+          .then((externalDMNModel) => {
+            console.trace("[TestScenarioDrawerSettingsPanel] The below 
external DMN model have been loaded");
+            console.trace(externalDMNModel);
+
+            if (canceled.get() || !externalDMNModel) {
+              setSelectedDmnModel(undefined);

Review Comment:
   Residual "callBackError" here.



##########
packages/scesim-editor/src/creation/TestScenarioCreationPanel.tsx:
##########
@@ -99,9 +198,30 @@ function TestScenarioCreationPanel() {
         </FormGroup>
         {assetType === "DMN" && (
           <>
-            <FormGroup label={i18n.creationPanel.dmnGroup} isRequired>
-              <FormSelect id="dmn-select" name="dmn-select" value={""} 
isDisabled>
-                <FormSelectOption isDisabled={true} key={0} value={""} 
label={i18n.creationPanel.dmnNoChoice} />
+            <FormGroup isRequired label={i18n.creationPanel.dmnGroup}>
+              <FormSelect
+                id="dmn-select"
+                name="dmn-select"
+                onChange={(dmnModelPathRelativeToThisScesim) => {
+                  if (typeof dmnModelPathRelativeToThisScesim !== "string") {

Review Comment:
   We usually trust the type system for such cases. What's the case where this 
would not be a string?



##########
packages/scesim-editor/src/drawer/TestScenarioDrawerSettingsPanel.tsx:
##########
@@ -27,21 +28,104 @@ import { TextInput } from 
"@patternfly/react-core/dist/js/components/TextInput";
 import { Title } from "@patternfly/react-core/dist/js/components/Title";
 import { Tooltip } from "@patternfly/react-core/dist/esm/components/Tooltip";
 
+import { useCancelableEffect } from 
"@kie-tools-core/react-hooks/dist/useCancelableEffect";
+
 import { SceSim__settingsType } from 
"@kie-tools/scesim-marshaller/dist/schemas/scesim-1_8/ts-gen/types";
 
 import { useTestScenarioEditorI18n } from "../i18n";
 import { useTestScenarioEditorStore, useTestScenarioEditorStoreApi } from 
"../store/TestScenarioStoreContext";
+import { useExternalModels } from 
"../externalModels/TestScenarioEditorDependenciesContext";
+import { ExternalDmn } from "../TestScenarioEditor";
+import { useTestScenarioEditor } from "../TestScenarioEditorContext";
 
 import "./TestScenarioDrawerSettingsPanel.css";
-import { useTestScenarioEditor } from "../TestScenarioEditorContext";
 
 function TestScenarioDrawerSettingsPanel() {
   const { i18n } = useTestScenarioEditorI18n();
   const { openFileNormalizedPosixPathRelativeToTheWorkspaceRoot } = 
useTestScenarioEditor();
+  const { onRequestExternalModelsAvailableToInclude, 
onRequestExternalModelByPath } = useExternalModels();
+  const [allDmnModelNormalizedPosixRelativePaths, 
setAllDmnModelNormalizedPosixRelativePaths] = useState<
+    string[] | undefined
+  >(undefined);
+  const [callBackError, setCallBackError] = useState<any>(undefined);
   const settingsModel = useTestScenarioEditorStore((state) => 
state.scesim.model.ScenarioSimulationModel.settings);
+  const [selectedDMNPathRelativeToThisScesim, 
setSelectedDMNPathRelativeToThisScesim] = useState<string | undefined>(
+    settingsModel.dmnFilePath?.__$$text
+  );
   const testScenarioEditorStoreApi = useTestScenarioEditorStoreApi();
   const testScenarioType = settingsModel.type?.__$$text.toUpperCase();
 
+  const [selectedDmnModel, setSelectedDmnModel] = useState<ExternalDmn | 
undefined>(undefined);
+
+  /* Retrieving all the DMN available in the project */
+  useCancelableEffect(
+    useCallback(
+      ({ canceled }) => {
+        onRequestExternalModelsAvailableToInclude?.()
+          .then((paths) => {
+            if (canceled.get()) {
+              return;
+            }
+            setAllDmnModelNormalizedPosixRelativePaths(
+              paths.sort((modelA, modelB) => 
basename(modelA).localeCompare(basename(modelB)))
+            );
+          })
+          .catch((err) => {
+            console.error(err);
+          });
+      },
+      [onRequestExternalModelsAvailableToInclude]
+    )
+  );
+
+  /** This callback return the unmarshalled representation of a DMN model 
given its path */
+  useCancelableEffect(
+    useCallback(
+      ({ canceled }) => {
+        if (!selectedDMNPathRelativeToThisScesim || 
onRequestExternalModelByPath === undefined) {
+          return;
+        }
+        onRequestExternalModelByPath(selectedDMNPathRelativeToThisScesim)
+          .then((externalDMNModel) => {

Review Comment:
   
   ```suggestion
             .then((externalDmnModel) => {
   ```



##########
packages/scesim-editor/src/mutations/updateColumn.ts:
##########
@@ -77,7 +77,7 @@ export function updateColumn({
     const factMappingValueToUpdate = 
factMappingValues[factMappingValueToUpdateIndex];
     factMappingValueToUpdate.factIdentifier.className = { __$$text: 
factClassName };
     factMappingValueToUpdate.factIdentifier.name = { __$$text: factName };
-    //factMappingValueToUpdate.rawValue = { __$$text: update.value },  //TODO 
2 related see kie-issues#1514
+    //factMappingValueToUpdate.rawValue = { __$$text: update.value, "@_class": 
"string" },  //TODO 2 related see kie-issues#1514

Review Comment:
   Can you please update the description of 
https://github.com/apache/incubator-kie-issues/issues/1514? Thanks!



##########
packages/scesim-editor/src/creation/TestScenarioCreationPanel.tsx:
##########
@@ -37,45 +39,142 @@ import CubesIcon from 
"@patternfly/react-icons/dist/esm/icons/cubes-icon";
 import { useTestScenarioEditorStoreApi } from 
"../store/TestScenarioStoreContext";
 import { useTestScenarioEditorI18n } from "../i18n";
 
+import { useExternalModels } from 
"../externalModels/TestScenarioEditorDependenciesContext";
+import { ExternalDmn } from "../TestScenarioEditor";
+import { createNewDmnTypeTestScenario } from 
"../mutations/createNewDmnTypeTestScenario";
+import { createNewRuleTypeTestScenario } from 
"../mutations/createNewRuleTypeTestScenario";
+
 import "./TestScenarioCreationPanel.css";
 
 function TestScenarioCreationPanel() {
   const { i18n } = useTestScenarioEditorI18n();
+  const { onRequestExternalModelsAvailableToInclude, 
onRequestExternalModelByPath } = useExternalModels();
+  const testScenarioEditorStoreApi = useTestScenarioEditorStoreApi();
 
-  const assetsOption = [
-    { value: "", label: i18n.creationPanel.assetsOption.noChoice, disabled: 
true },
-    { value: "DMN", label: i18n.creationPanel.assetsOption.dmn, disabled: 
false },
-    { value: "RULE", label: i18n.creationPanel.assetsOption.rule, disabled: 
false },
-  ];
-
+  const [allDmnModelNormalizedPosixRelativePaths, 
setAllDmnModelNormalizedPosixRelativePaths] = useState<
+    string[] | undefined
+  >(undefined);
   const [assetType, setAssetType] = React.useState<"" | "DMN" | "RULE">("");
+  const [callBackError, setCallBackError] = useState<any>(undefined);

Review Comment:
   Same as the other one. Please use a more descriptive name...



##########
packages/scesim-editor/src/drawer/TestScenarioDrawerSettingsPanel.tsx:
##########
@@ -27,21 +28,104 @@ import { TextInput } from 
"@patternfly/react-core/dist/js/components/TextInput";
 import { Title } from "@patternfly/react-core/dist/js/components/Title";
 import { Tooltip } from "@patternfly/react-core/dist/esm/components/Tooltip";
 
+import { useCancelableEffect } from 
"@kie-tools-core/react-hooks/dist/useCancelableEffect";
+
 import { SceSim__settingsType } from 
"@kie-tools/scesim-marshaller/dist/schemas/scesim-1_8/ts-gen/types";
 
 import { useTestScenarioEditorI18n } from "../i18n";
 import { useTestScenarioEditorStore, useTestScenarioEditorStoreApi } from 
"../store/TestScenarioStoreContext";
+import { useExternalModels } from 
"../externalModels/TestScenarioEditorDependenciesContext";
+import { ExternalDmn } from "../TestScenarioEditor";
+import { useTestScenarioEditor } from "../TestScenarioEditorContext";
 
 import "./TestScenarioDrawerSettingsPanel.css";
-import { useTestScenarioEditor } from "../TestScenarioEditorContext";
 
 function TestScenarioDrawerSettingsPanel() {
   const { i18n } = useTestScenarioEditorI18n();
   const { openFileNormalizedPosixPathRelativeToTheWorkspaceRoot } = 
useTestScenarioEditor();
+  const { onRequestExternalModelsAvailableToInclude, 
onRequestExternalModelByPath } = useExternalModels();
+  const [allDmnModelNormalizedPosixRelativePaths, 
setAllDmnModelNormalizedPosixRelativePaths] = useState<
+    string[] | undefined
+  >(undefined);
+  const [callBackError, setCallBackError] = useState<any>(undefined);
   const settingsModel = useTestScenarioEditorStore((state) => 
state.scesim.model.ScenarioSimulationModel.settings);
+  const [selectedDMNPathRelativeToThisScesim, 
setSelectedDMNPathRelativeToThisScesim] = useState<string | undefined>(

Review Comment:
   
   ```suggestion
     const [selectedDmnPathRelativeToThisSceSim, 
setSelectedDmnPathRelativeToThisSceSim] = useState<string | undefined>(
   ```



##########
packages/scesim-editor/src/drawer/TestScenarioDrawerDataSelectorPanel.tsx:
##########
@@ -517,17 +536,23 @@ function TestScenarioDataSelectorPanel() {
                 toolbar={treeViewSearchToolbar}
               />
             </div>
-          ) : (
-            <Bullseye>
-              <EmptyState>
-                <EmptyStateIcon icon={treeViewEmptyStatus.icon} />
-                <Title headingLevel="h4" size="lg">
-                  {treeViewEmptyStatus.title}
-                </Title>
-                
<EmptyStateBody>{treeViewEmptyStatus.description}</EmptyStateBody>
-              </EmptyState>
-            </Bullseye>
-          )}
+          )) ||
+            (treeViewEmptyStatus.visibility === "hidden" && (
+              <Bullseye>
+                <EmptyState>
+                  <EmptyStateIcon icon={treeViewEmptyStatus.icon} />
+                  <Title headingLevel="h4" size="lg">
+                    {treeViewEmptyStatus.title}
+                  </Title>
+                  
<EmptyStateBody>{treeViewEmptyStatus.description}</EmptyStateBody>
+                </EmptyState>
+              </Bullseye>
+            )) ||
+            (treeViewEmptyStatus.visibility === "loading" && (
+              <Bullseye style={{ paddingTop: "10px" }}>
+                <Spinner aria-label="Contents of the basic example" />

Review Comment:
   Is this `aria-label` correct?



##########
packages/scesim-editor/src/TestScenarioEditor.tsx:
##########
@@ -165,15 +168,32 @@ export type TestScenarioSelectedColumnMetaData = {
 function TestScenarioMainPanel() {
   const { i18n } = useTestScenarioEditorI18n();
   const { commandsRef } = useCommands();
+  const { externalModelsByNamespace } = useExternalModels();
   const testScenarioEditorStoreApi = useTestScenarioEditorStoreApi();
-  const navigation = useTestScenarioEditorStore((s) => s.navigation);
-  const scesimModel = useTestScenarioEditorStore((s) => s.scesim.model);
-  const isAlertEnabled = true; // Will be managed in kie-issue#970
+  const navigation = useTestScenarioEditorStore((state) => state.navigation);
+  const scesimModel = useTestScenarioEditorStore((state) => 
state.scesim.model);
+  const testScenarioDmnNamespace = 
scesimModel.ScenarioSimulationModel.settings.dmnNamespace?.__$$text;
+  const testScenarioDmnFilePath = 
scesimModel.ScenarioSimulationModel.settings.dmnFilePath?.__$$text;
   const testScenarioType = 
scesimModel.ScenarioSimulationModel.settings.type?.__$$text.toUpperCase();
 
   const scenarioTableScrollableElementRef = useRef<HTMLDivElement | 
null>(null);
   const backgroundTableScrollableElementRef = useRef<HTMLDivElement | 
null>(null);
 
+  /* RULE-based Test Scenario are still not supported. The Notification will 
always be active in such a case
+     In DMN-based Test Scenario, the notification will be active if: 
+     - The DMN model with the target reference is missing at all
+     - The DMN model with the target reference is found, but in a different 
location */
+  const isMissingDataObjectsNotificationEnabled = useMemo(() => {
+    const isReferencedDMNFileMissing =

Review Comment:
   
   ```suggestion
       const isReferencedDmnFileMissing =
   ```



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