-
Notifications
You must be signed in to change notification settings - Fork 201
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#1741: Sandbox: Add “Open Boxed Expression Editor” button in the DMN Runner table output columns #2849
base: main
Are you sure you want to change the base?
Conversation
…n in the DMN Runner form output cards Closes: apache/incubator-kie-issues#1595
@tiagobento @kbowers-ibm @ljmotta or anyone else, I will write down my analysis of the problem #2849 (comment), it is the thing that runner output columns are not resizable, there is missing the resize handler. It was introduced by changes regarding The missing resize handler in dmn runner outputs columns is a problem because of this two things Too long header textMakes header unreadable and in combination with new arrow up button quite 'messy'. Too long data textSo here are some options I see. Please comment them or bring other so we can decide what option is the best. 01 'Weak' ReadOnly modeWe could change the Pros
Cons
02 'allowResizing' propertyWe could introduce additional property Pros
Cons
03 'width' computationWe could reuse the column width computation for given text as we have here: https://github.com/apache/incubator-kie-tools/blob/main/packages/dmn-editor/src/boxedExpressions/getDefaultColumnWidth.tsx directly in Pros
Cons
|
Thanks for the detailed analysis @jomarko - you've clearly put a lot of thought and effort into this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jomarko Thanks for the PR, I've made some comments inline. Please let me know if you have any questions or need further explanation.
!isLegacyDmnEditor | ||
? (nodeId: string) => { | ||
const newDmnEditorEnvelopeApi = props.editor?.getEnvelopeServer() | ||
.envelopeApi as unknown as MessageBusClientApi<NewDmnEditorEnvelopeApi>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the as unknown
is required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
export function DmnRunnerTable() { | ||
export function DmnRunnerTable(props: { editor: EmbeddedEditorRef | undefined }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -468,6 +468,7 @@ Error details: ${err}`); | |||
workspaceFile={file.workspaceFile} | |||
workspaces={workspaces} | |||
dmnLanguageService={dmnLanguageService} | |||
editor={editor} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned, we could pass the editorEnvelopeServer
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -186,7 +189,7 @@ export function EditorPageDockContextProvider({ | |||
case PanelId.DMN_RUNNER_TABLE: | |||
return ( | |||
<DmnRunnerErrorBoundary> | |||
<DmnRunnerTable /> | |||
<DmnRunnerTable editor={editor} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -99,3 +99,9 @@ | |||
font-size: smaller; | |||
color: #1b515f; | |||
} | |||
|
|||
.kie-tools--bee--header-cell-element-extension { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am sorry I used wrong prefix, as you mentioned and I noticed, we use multiple prefixes, and I am sorry, I didn't figure out from the codebase which prefix should I use in my PR.
Is header-cell-element-extension
fine for you? I see we have header-cell
or header-cell-info
already in use.
const onOpenBoxedExpressionHeaderButtonClick = useCallback( | ||
(clickedDecisionId: string) => { | ||
(results?.[0] ?? []).flatMap(({ decisionId: resultDecisionId }) => { | ||
if (clickedDecisionId === resultDecisionId) { | ||
openBoxedExpressionEditor?.(resultDecisionId); | ||
} | ||
}); | ||
}, | ||
[openBoxedExpressionEditor, results] | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, I like this incorporated
@jomarko I agree with @kbowers-ibm . Both option 1 and 2 would require to persist the column size, or closing and opening the DMN Runner Table would reset to the original size. |
Column width checks
|
* Wrapping 'getDefaultColumnWidth' to add additional space for the '<ArrowUp />' icon in the runner outputs columns. | ||
*/ | ||
const getDefaultDmnRunnerOutputColumnWidth = useCallback((label, dataType) => { | ||
return getDefaultColumnWidth({ name: label, typeRef: dataType }) + 100; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please extract 100
to a nice constant and give it a long and descriptive name 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tiagobento good feedback, thank you. done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great - thanks for the changes to the widths Jozef! This is a much better solution than adding back resizing, as the bug with column sizes not persisting means it would still be messy. Whereas this is simple, effective and looks very clean 🙇
minWidth: Math.max( | ||
(parentColumnMinWidth ?? columnMinWidth) / Object.entries(myObject).length, | ||
columnMinWidth | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing hooks dependencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tiagobento thank you for spotting, changes pushed
Closes apache/incubator-kie-issues#1741
The dmn runner outputs table introduces a button in the header cell top right corner for navigating into the bound expression. It means the boxed expression editor is open for the given dmn runner result.