ljmotta commented on code in PR #2849:
URL: 
https://github.com/apache/incubator-kie-tools/pull/2849#discussion_r1933983816


##########
packages/online-editor/src/dmnRunner/DmnRunnerTable.tsx:
##########
@@ -32,8 +32,12 @@ import setObjectValueByPath from "lodash/set";
 import cloneDeep from "lodash/cloneDeep";
 import { DmnRunnerProviderActionType } from "./DmnRunnerTypes";
 import { DmnRunnerExtendedServicesError } from "./DmnRunnerContextProvider";
+import { MessageBusClientApi } from "@kie-tools-core/envelope-bus/dist/api";
+import { NewDmnEditorEnvelopeApi } from 
"@kie-tools/dmn-editor-envelope/dist/NewDmnEditorEnvelopeApi";
+import { EmbeddedEditorRef } from "@kie-tools-core/editor/dist/embedded";
+import { useSettings } from "../settings/SettingsContext";
 
-export function DmnRunnerTable() {
+export function DmnRunnerTable(props: { editor: EmbeddedEditorRef | undefined 
}) {

Review Comment:
   I'm don't think we want to have an `undefined` `editor` as props of the 
`DmnRunnerTable`. Also, the `getEnvelopeServer()` is the only property of 
`editor` that is used, which could be accordlying typed to avoid casting. 



##########
packages/online-editor/src/editor/EditorPage.tsx:
##########
@@ -468,6 +468,7 @@ Error details: ${err}`);
                 workspaceFile={file.workspaceFile}
                 workspaces={workspaces}
                 dmnLanguageService={dmnLanguageService}
+                editor={editor}

Review Comment:
   As mentioned, we could pass the `editorEnvelopeServer`.



##########
packages/online-editor/src/editor/EditorPageDockContextProvider.tsx:
##########
@@ -186,7 +189,7 @@ export function EditorPageDockContextProvider({
       case PanelId.DMN_RUNNER_TABLE:
         return (
           <DmnRunnerErrorBoundary>
-            <DmnRunnerTable />
+            <DmnRunnerTable editor={editor} />

Review Comment:
   Same.



##########
packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx:
##########
@@ -228,8 +246,33 @@ function OutputsBeeTable({ id, i18n, outputsPropertiesMap, 
results, scrollablePa
     [getRowValue]
   );
 
+  const onOpenBoxedExpressionHeaderButtonClick = useCallback(
+    (clickedDecisionId: string) => {
+      (results?.[0] ?? []).flatMap(({ decisionId: resultDecisionId }) => {
+        if (clickedDecisionId === resultDecisionId) {
+          openBoxedExpressionEditor?.(resultDecisionId);
+        }
+      });
+    },
+    [openBoxedExpressionEditor, results]
+  );

Review Comment:
   Well, everytime we click on the button we will search the array to check if 
`decisionId` is part of the `results`. Why not save the `result` `decisionIds` 
in a `set`?
   
   ```
   const resultsDecisionIds = useMemo(() => results?.[0]?.reduce((set, result) 
=> {
     set.add(result.decisionId);
     return set;
   }, new Set()), [results]);
   
   ... 
   onClick={() => resultsDecisionIds.has(decisionId) && 
openBoxedExpressionEditor?.(decisionId)}
   ```
   
   (I didn't test the code above)



##########
packages/online-editor/src/dmnRunner/DmnRunnerTable.tsx:
##########
@@ -137,6 +144,18 @@ export function DmnRunnerTable() {
                           i18n={i18n.dmnRunner.table}
                           jsonSchemaBridge={jsonSchemaBridge}
                           results={results}
+                          openBoxedExpressionEditor={
+                            !isLegacyDmnEditor
+                              ? (nodeId: string) => {
+                                  const newDmnEditorEnvelopeApi = 
props.editor?.getEnvelopeServer()
+                                    .envelopeApi as unknown as 
MessageBusClientApi<NewDmnEditorEnvelopeApi>;

Review Comment:
   Why the `as unknown` is required?



##########
packages/boxed-expression-component/src/BoxedExpressionEditorContext.css:
##########
@@ -99,3 +99,9 @@
   font-size: smaller;
   color: #1b515f;
 }
+
+.kie-tools--bee--header-cell-element-extension {

Review Comment:
   I don't want to be picky here, but for this particular case, we don't use 
the `kie-tools--bee` prefix. For the `boxed-expression-component` we are using 
multiple classes.



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