-
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
Introduce redux into dashboard #14518
Introduce redux into dashboard #14518
Conversation
embeddables, | ||
}); | ||
|
||
export const getPanels = state => state.panels; |
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.
Management is doing this too, putting selectors in reducer files. Is that the plan going forward? Any reason you don't separate the two?
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 actually think we should split them out because I ran into a circular reference error, but didn't want to make that decision in this PR.
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.
Alright. We split it out in Canvas, but I think Cloud might not. It would probably be good to get consensus on the organization, but not something we need in this PR.
Tests are failing due to #14503 but otherwise seem to be passing. |
… loaded - we don't want a panel id from a different dashboard in the state tree on a fresh open.
discover was not returning a promise
…d loading results
…still use selectors
e49e710
to
1c4dbd5
Compare
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
Merging since tests passed and the original PR had two LGTMS and nothing was changed here, just the commits copied over. |
* Initial check in of introducing redux in dashboard * Use redux-actions and redux-thunks to reduce boilerplate * Make sure all panels are minimized from the start when a dashboard is loaded - we don't want a panel id from a different dashboard in the state tree on a fresh open. * Remove unused file * use classnames dependency instead of manual logic * First pass on selectors, handleActions, and more segmented reducers. * Fix bugs with selectors and reducers and add tests that would have caught them. * Fix issue plus tests discover was not returning a promise * Make expanding a panel purely a css modification which avoids all re-renders * Found another bug with initial state not being set correctly on a hard refresh * Remove check for change handlers now that the event handler bug is fixed * rename dashboardState => dashboard for reducers and redux state tree * Remove unnecessary top level describe in jest tests * Navigate back to landing page at the end of the newly added test suite * Fix lint errors * Stabilize flaky tests by waiting until saved object search is finished loading results * Don't leak subscriptions to the store. * use selectors to grab dashboard panel off state. * Remove use of getState in dispatcher to avoid circular reference and still use selectors * use spread over object.assign * No need to pass second param in when the input is simply returned as-is.
* Initial check in of introducing redux in dashboard * Use redux-actions and redux-thunks to reduce boilerplate * Make sure all panels are minimized from the start when a dashboard is loaded - we don't want a panel id from a different dashboard in the state tree on a fresh open. * Remove unused file * use classnames dependency instead of manual logic * First pass on selectors, handleActions, and more segmented reducers. * Fix bugs with selectors and reducers and add tests that would have caught them. * Fix issue plus tests discover was not returning a promise * Make expanding a panel purely a css modification which avoids all re-renders * Found another bug with initial state not being set correctly on a hard refresh * Remove check for change handlers now that the event handler bug is fixed * rename dashboardState => dashboard for reducers and redux state tree * Remove unnecessary top level describe in jest tests * Navigate back to landing page at the end of the newly added test suite * Fix lint errors * Stabilize flaky tests by waiting until saved object search is finished loading results * Don't leak subscriptions to the store. * use selectors to grab dashboard panel off state. * Remove use of getState in dispatcher to avoid circular reference and still use selectors * use spread over object.assign * No need to pass second param in when the input is simply returned as-is.
I pulled all the commits out of #14199 and into this new PR. Somewhere along the way I must have had a bad merge and updates on master were not getting pushed to my PR, so that the final change was showing unrelated flot/visualization updates.
Only way I could think of resolving this was to start fresh and copy the commits over.
From original PR description:
Introduces Redux state management for the react portion of dashboard, the "dashboard viewport". The top portion of dashboard - nav panels, filter bar, query, etc, are still all in angular. Eventually the goal is to replace all of those portions with react as well, and expand the state stored in redux.
Because there is still a large portion stored in angular, and dashboard currently uses AppState to manage that, as well as handle url changes, the DashboardStateManager handles keeping the redux store and the angular AppState in sync.
Unfortunately this does diminish the benefit of redux’s “single source of truth”. I think this can be handled once more of dashboard is in react, and with the introduction of react routing to handle URL changes. I decided for a first step, this was already a large PR, so did not want to take it any further.
I think this gives us a good way forward and provides benefits of clear state management, at least from the viewport downward.
Here is a diagram of how the new redux/angular state management interacts. It's still messy but at least the interaction is explainable.