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