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#1547: DMN Editor: Render evaluation highlights in the Boxed Expression Editor #2681

Merged
merged 26 commits into from
Dec 18, 2024

Conversation

jomarko
Copy link
Contributor

@jomarko jomarko commented Oct 18, 2024

Closes: apache/incubator-kie-issues/issues/1547

checklist

  • decision table
  • conditional
  • context additional row
  • nested expressions

testing

New Evaluation Hits stories were added into Conditional and Decision Table stories.

@tiagobento tiagobento changed the title kie-issues#1547: Render evaluation highlights in the Boxed Expression… kie-issues#1547: Render evaluation highlights in the Boxed Expression Editor Oct 22, 2024
@@ -203,6 +203,46 @@
border: 0;
}

.expression-container .table-component tr.evaluation-highlights-row-overlay > td:first-child::before {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

first-child here was my decision to use, otherwise there is problem, when then/ else branch has nested decision table, but not all decision table rules were evaluated. see:
Screenshot 2024-10-30 132337

@jomarko jomarko marked this pull request as ready for review October 30, 2024 15:11
@jomarko jomarko requested a review from tiagobento as a code owner October 30, 2024 15:11
@jomarko jomarko changed the title kie-issues#1547: Render evaluation highlights in the Boxed Expression Editor kie-issues#1547: DMN Editor: Render evaluation highlights in the Boxed Expression Editor Oct 31, 2024
Copy link
Contributor

@ljmotta ljmotta left a comment

Choose a reason for hiding this comment

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

@jomarko Thanks a lot for your PR. I didn't have time to manually test it, but I will. Until then, I've made some comments inline.

/** Index of the column, where the evaluation hits count should be displayed. If not set, evaluation hits count number is not shown. */
evaluationHitsCountColumnIndex?: number;
/** Method should return true for table rows, that can display evaluation hits count, false otherwise. If not set, BeeTableBody defaults to false. */
getEvaluationHitsCountSupportedByRow?: (row: ReactTable.Row<R>) => boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

The name is a little strange for me. The idea is to the get if a row supports (or not) the "EvaluationHitsCount". I don't think the "ByRow" makes sense, so:

  • isEvaluationHitCountSupported(row: Row): The is tells the method will be boolean
  • supportsEvaluationHitCount(row: Row)

Another idea is to use the args: { row: Row }, but I don't think is necessary, as we just have one parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

understand, done

@@ -247,6 +256,8 @@ export function ConditionalExpression({
shouldRenderRowIndexColumn={false}
shouldShowRowsInlineControls={false}
shouldShowColumnsInlineControls={false}
evaluationHitsCountColumnIndex={1}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why 1? Could you please add a comment here? Or make it a variable with a very good name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed from the codebase

@@ -1073,6 +1077,8 @@ export function DecisionTableExpression({
shouldRenderRowIndexColumn={true}
shouldShowRowsInlineControls={true}
shouldShowColumnsInlineControls={true}
evaluationHitsCountColumnIndex={0}
Copy link
Contributor

Choose a reason for hiding this comment

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

I get the 0 here, but it would be good to add a comment too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed from the codebase

Comment on lines 89 to 96
const rowKey = getRowKey(row);
const isEvalationHitsCountSupportedByRow: boolean = getEvaluationHitsCountSupportedByRow?.(row) ?? false;
const rowEvaluationHitsCount = evaluationHitsCountPerId ? evaluationHitsCountPerId?.get(rowKey) ?? 0 : undefined;
const canDisplayEvaluationHitsCountRowOverlay =
rowEvaluationHitsCount !== undefined && isEvalationHitsCountSupportedByRow === true;
const rowClassName = canDisplayEvaluationHitsCountRowOverlay
? rowKey + (rowEvaluationHitsCount > 0 ? " evaluation-hits-count-row-overlay" : "")
: rowKey;
Copy link
Contributor

Choose a reason for hiding this comment

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

This part is a little dense, a lot of information here.

  • Could you please inline the isEvalationHitsCountSupportedByRow as it's used only one time?
  • I'm not sure about this one, but can you force the ternary to be written in multiple lines?
  • Could you please add a line break between? As multiple ternaries can be very difficult to read.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the ternary operator is tricky

there is an eslint rule, that would force what you propose:

https://eslint.style/rules/js/multiline-ternary

However once I used it in project and formatted ternary operators as multiple lines, the current prettier configuration, the pre-commit hook for formatting we have reverted those changes, or adapted them in a way, that caused eslint again complaining..

So we have currently a prettier configuration that is not compatible with this eslint rule.

Comment on lines 234 to 238
const evaluationHitsCountBadgeClassName = canDisplayEvaluationHitsCountBadge
? (evaluationHitsCount ?? 0) > 0
? "evaluation-hits-count-badge-colored"
: "evaluation-hits-count-badge-non-colored"
: "";
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, use an useMemo hook 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.

thank you, used

@ljmotta
Copy link
Contributor

ljmotta commented Dec 10, 2024

@jomarko Thanks for applying the changes.

After manually testing it, I could find a CSS that will highlight as first discussed:

.expression-container-box .conditional-expression .table-component tr.evaluation-hits-count-row-overlay > td:first-child::before {
  content: "";
  position: absolute;
  background-color: rgb(215, 201, 255, 0.5);
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

.expression-container-box .conditional-expression .table-component tr.evaluation-hits-count-row-overlay > td > div > div > div > .logic-type-selected-header::before {
  content: "";
  position: absolute;
  background-color: rgb(215, 201, 255, 0.5);
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

.expression-container-box .decision-table-expression .table-component tr.evaluation-hits-count-row-overlay > td::before {
  content: "";
  position: absolute;
  background-color: rgb(215, 201, 255, 0.5);
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

You will need to add a conditional-expression class to the ConditionalExpression.tsx file:

      <div className={"conditional-expression"} data-testid={"kie-tools--boxed-expression-component---conditional"}>
        <BeeTable<ROWTYPE>
           ...

image

I guess it can be simplified, but I broke into the conditional-expression, decision-table-expression and logic-type-selected-header CSS.

@jomarko jomarko added the pr: wip PR is still under development label Dec 12, 2024
@jomarko jomarko removed the pr: wip PR is still under development label Dec 13, 2024
@jomarko jomarko requested a review from kbowers-ibm December 13, 2024 13:06
Copy link
Contributor

@kbowers-ibm kbowers-ibm left a comment

Choose a reason for hiding this comment

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

Thanks @jomarko everything looks great to me!

Copy link
Contributor

@ljmotta ljmotta left a comment

Choose a reason for hiding this comment

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

@jomarko I've just one last comment regarding the boxedExpressionStoriesWrapper.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's not necessary to modify the BoxedExpressionEditorStoryArgs type, as the BoxedExpressionEditorProps already contains the evaluationHitsCountById property.

Also, the useState isn't required.

The evaluationHitsCountById should have the same value as other props:

evaluationHitsCountById={props?.evaluationHitsCountById ?? args?.evaluationHitsCountById}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thank you, I am happy we can keep it simple

@jomarko jomarko requested a review from ljmotta December 18, 2024 07:44
@jomarko jomarko merged commit 74659fd into apache:main Dec 18, 2024
15 checks passed
@jomarko jomarko deleted the kie-issues#1547 branch December 18, 2024 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants