yesamer commented on code in PR #2887:
URL:
https://github.com/apache/incubator-kie-tools/pull/2887#discussion_r1959420580
##########
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:
Done
##########
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:
Done
--
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]