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#970: Test Scenario Editor: Integrate the @kie-tools/scesim-editor component with the DMN Marshaller #2887

Open
wants to merge 75 commits into
base: main
Choose a base branch
from

Conversation

yesamer
Copy link
Contributor

@yesamer yesamer commented Jan 30, 2025

Closes apache/incubator-kie-issues#970

This PR integrates the new Scesim Editor with the DMN Marshaller, making it possible to retrieve required information from an External DMN Model.

To whoever will review and test this PR, please consider some KI have already reported here

In addition, some use cases are still not fully implemented (eg. collections, expressions, nested data objects)
Those will be managed with apache/incubator-kie-issues#1514

Some examples:

Opening an existing Scesim file:

Screen.Recording.2025-02-05.at.15.24.17.mov

Creating a new DMN-based Scesim file with auto-population

Screen.Recording.2025-02-05.at.15.17.19.mov

Creating a new DMN-based Scesim file without auto-population

Screen.Recording.2025-02-05.at.15.19.16.mov

Opening an existing DMN-based Scesim file with the referenced DMN file removed

Screen.Recording.2025-02-05.at.15.27.45.mov

Opening an existing DMN-based Scesim file with the referenced DMN file moved to another location

Screen.Recording.2025-02-05.at.16.43.28.mov

Blocked by #2866. Required to update the tests.

@yesamer yesamer added pr: DO NOT MERGE Draft PR, not ready for merging pr: wip PR is still under development area:scesim labels Jan 30, 2025
@yesamer yesamer requested a review from tiagobento as a code owner January 30, 2025 16:19
@jomarko
Copy link
Contributor

jomarko commented Jan 31, 2025

🥳 🍾 🚀

Copy link
Contributor

@tiagobento tiagobento left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider my comment inline. Thank you!

const settingsModel = useTestScenarioEditorStore((state) => state.scesim.model.ScenarioSimulationModel.settings);
const [selectedDMNPathRelativeToThisScesim, setSelectedDMNPathRelativeToThisScesim] = useState<string | undefined>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const [selectedDMNPathRelativeToThisScesim, setSelectedDMNPathRelativeToThisScesim] = useState<string | undefined>(
const [selectedDmnPathRelativeToThisSceSim, setSelectedDmnPathRelativeToThisSceSim] = useState<string | undefined>(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

console.trace(externalDMNModel);

if (canceled.get() || !externalDMNModel) {
setSelectedDmnModel(undefined);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Residual "callBackError" here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ehm, what do you mean? Should I update the callBackError?

const [allDmnModelNormalizedPosixRelativePaths, setAllDmnModelNormalizedPosixRelativePaths] = useState<
string[] | undefined
>(undefined);
const [callBackError, setCallBackError] = useState<any>(undefined);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine with me, done

return;
}
onRequestExternalModelByPath(selectedDMNPathRelativeToThisScesim)
.then((externalDMNModel) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.then((externalDMNModel) => {
.then((externalDmnModel) => {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

callBackError !== undefined ||
selectedDmnModel?.normalizedPosixPathRelativeToTheOpenFile !== settingsModel.dmnFilePath?.__$$text,
[callBackError, selectedDmnModel?.normalizedPosixPathRelativeToTheOpenFile, settingsModel.dmnFilePath?.__$$text]
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

De Morgan likes this element

)
);

/** This callback return the unmarshalled representation of a DMN model given its path */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

if (callBackError) {
throw callBackError;
}
}, [callBackError]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good observation, so it's enough to rethrow the error inside the catch block, right?

id="dmn-select"
name="dmn-select"
onChange={(dmnModelPathRelativeToThisScesim) => {
if (typeof dmnModelPathRelativeToThisScesim !== "string") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree is not necessary at all. Removed.

@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please update the description of apache/incubator-kie-issues#1514? Thanks!

- 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 =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const isReferencedDMNFileMissing =
const isReferencedDmnFileMissing =

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@jomarko
Copy link
Contributor

jomarko commented Feb 18, 2025

Postponing my review after code changes required by @tiagobento are in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test Scenario Editor: Integrate the @kie-tools/scesim-editor component with the DMN Marshaller
4 participants