-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Canvas] Layout engine integration simplification #33702
Conversation
Pinging @elastic/kibana-canvas |
💚 Build Succeeded |
d9a1689
to
bd3af51
Compare
ace6772
to
7d0f141
Compare
b41778e
to
a3688f3
Compare
💚 Build Succeeded |
a3688f3
to
1a4988c
Compare
💚 Build Succeeded |
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.
Initial feedback, have not run this yet.
nit: nitpicky stuff you can choose to ignore
Q: question
CR: change requested
also curious if you have plans to slim down the WorkpadPage component in the future, it's a beast now...
@@ -32,6 +33,7 @@ export const routes = [ | |||
dispatch(setAssets(assets)); | |||
dispatch(setWorkpad(workpad, { loadPages: false })); | |||
dispatch(setPage(pageNumber - 1)); | |||
dispatch(selectToplevelNodes([])); |
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.
Q: Was this just an oversight in the old code, where selected elements were not cleared?
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.
In the old code, we cleared the selection via the middleware (I think circuitously, by clearing it in the aero
store which then updated back redux
) so it just used a different - and simpler - mechanism there. But glad you asked because:
I'm not proposing this for this PR, but adding this line (and similar ones) made me ponder if our currently fairly lean reducers should be able to do more. For example, here, we issue four dispatches. combineReducers
is nice when state slices are truly independent, but it's not possible to implement a new version of setPage
that would also vacate the transient.selectedToplevelNodes
array. I'm biased toward one user action = one Redux action (sans async stuff like server response) and the Redux doc has a pertinent note on combineReducers
.
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 also prefer to lean towards the 1:1 user action to redux action route.
Would it make sense to update the transientReducer
to be watching for any of these "page changed" type actions (add, set, delete, duplicate, etc) and set the selectedTopLevelNodes
state to empty array? Rather than having to always dispatch this selectTopLevelNodes action when any kind of page change happens?
if (action is changePage or deletePage or addPage)
selectedTopLevelElements = []
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.
That's probably the better "redux" way, having the transient reducer update based on these actions. So that dispatching only setWorkpad
or setPage
does what you want without needing to dispatch other actions all the time.
There's a lot of other places we could clean up like that too.
Yes, agreed! Should I put the wrappers around the (already split) |
I'm not sure the best way to spit it up, and personally would not do it in this PR anyway. Was just curious if you had future plans. Sounds like yes, which is good enough for me. |
}, | ||
removePage: id => { | ||
dispatch(pageActions.removePage(id)); | ||
dispatch(selectToplevelNodes([])); |
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.
Minor: If the page being removed is not the one that's currently the interactive one, then the selections are still reset.
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.
Good catch, thanks!
1a4988c
to
49f95b4
Compare
💚 Build Succeeded |
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.
LGTM. It would be nice if you removed all the added dispatch(selectToplevelNodes([]))
and put that logic in the transient reducer, but I'm not going to block on that.
💚 Build Succeeded |
* Refactor: layout engine integration
💚 Build Succeeded |
Goals:
aeroelastic_kibana.js
that herds a set of layout stores*Elements
->*Nodes
where appropriate; old PR feedback from @w33ble )Side effects:
shouldUpdate
)Non-goals for this specific PR:
Progress:
aero.commit
function no longer has the callback function arg and the meta argintegration_utils.js
fetchAllRenderables
)mw/aeroelastic.js
andaeroelastic_kibana.js
) got removedsimplified, esp. the removal of the commit callback and the unification of the logic before next()layoutProps
function is temporarily super verbose, got to do that stuff with a few calls to already existing functions, just copy-pasted initiallyFix: deleting the last existing page that has at least one element throws (cloneNode) - related to the aboveindependent issue, see [Canvas] Deleting the last extant page of a workbook throws #34458Fix: grouping outside the Canvas page paper while holding the mouse button breaksindependent issue, see Fix: don't attempt grouping while mouse is down #34448