-
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
[Lens] Move editorFrame state to redux #100858
[Lens] Move editorFrame state to redux #100858
Conversation
Pinging @elastic/kibana-app (Team:KibanaApp) |
608bdbd
to
3b0304e
Compare
94dc761
to
6b22cc5
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.
nitpick: why this isolated scope?
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.
@dej611 this code is not ready to be reviewed yet -> I marked it this way to remember about refactoring it. I'll let you know on Monday (hopefully) when it's ready!
225115a
to
44e03d1
Compare
889015b
to
9fe53a5
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.
I'm not quite done reviewing this, but I did some testing today and wasn't able to break anything!
@@ -177,14 +208,6 @@ describe('Lens App', () => { | |||
expect(services.data.query.filterManager.getFilters).not.toHaveBeenCalled(); | |||
}); | |||
|
|||
it('displays errors from the frame in a toast', async () => { |
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.
It looks like you haven't copied this unit test into the mounter- the onError
callback was specifically called when initializeDatasources
threw errors.
/** | ||
* A map of all available palettes (keys being the ids). | ||
*/ | ||
availablePalettes: PaletteRegistry; |
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.
Was this availablePalettes
deleted fully? I'm not seeing a replacement 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.
That's because they are never used. They are being loaded again in the particular visualizations that need them, for example here:
https://github.com/elastic/kibana/blob/master/x-pack/plugins/lens/public/datatable_visualization/index.ts#L38
// This is a safeguard that prevents us from accidentally updating the | ||
// wrong visualization. This occurs in some cases due to the uncoordinated | ||
// way we manage state across plugins. | ||
if (state.visualization.activeId !== payload.visualizationId) { |
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 theory both of these safeguards will be fixed by this PR!
}); | ||
|
||
it('should render render icon if there is no preview expression', () => { |
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.
Looks like this is just changing the test order?
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.
Yes, reverting!
9fe53a5
to
c26a6f8
Compare
c26a6f8
to
366d41a
Compare
c84c5dc
to
cd75cab
Compare
bb8fcfa
to
4be257c
Compare
Still reviewing but I think I found a bug in the current PR: when creating a percentage chart, on dropping a field on the main chart area, only the very first time, it creates a new layer where the field is added in the On Perhaps this is a possible side effect of the removal of the |
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 tested and went through the code - looks pretty good to me already. We can sync offline but I want to align about the next steps to make sure we are going into the right direction.
if ( | ||
!initialInput || | ||
(attributeService.inputIsRefType(initialInput) && | ||
initialInput.savedObjectId === persistedDoc?.savedObjectId) | ||
) { | ||
return; | ||
return initializeDatasources( |
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.
It's fine for now, but I would like to move all of these things into the middleware at some point
}) | ||
); | ||
if (initialContext) { | ||
const selectedSuggestion = getVisualizeFieldSuggestions({ |
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.
The whole block up to line 384 could be moved into the reduced because it's completely pure. The only thing we would need to make sure is making datasource and visualization map known to the reducer. But this will probably happen in a separate step, right?
import { uiActionsPluginMock } from '../../../../../../src/plugins/ui_actions/public/mocks'; | ||
import { chartPluginMock } from '../../../../../../src/plugins/charts/public/mocks'; | ||
import { expressionsPluginMock } from '../../../../../../src/plugins/expressions/public/mocks'; | ||
import { mockDataPlugin, mountWithProvider } from '../../mocks'; | ||
import { setState, setToggleFullscreen } from '../../state_management'; | ||
import { FrameLayout } from './frame_layout'; | ||
|
||
function generateSuggestion(state = {}): DatasourceSuggestion { | ||
return { |
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.
Can't comment there but in line 71 there's still an onError
prop - seems to be a leftover
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.
Code LGTM 👍
…_state_refactoring
@elasticmachine merge upstream |
…_state_refactoring
…dyra/kibana into lens/editor_frame_state_refactoring
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
Co-authored-by: Joe Reuter <johannes.reuter@elastic.co> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: dej611 <dej611@gmail.com>
💚 Backport successful
This backport PR will be merged automatically after passing CI. |
Co-authored-by: Joe Reuter <johannes.reuter@elastic.co> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: dej611 <dej611@gmail.com> Co-authored-by: Marta Bondyra <marta.bondyra@gmail.com> Co-authored-by: Joe Reuter <johannes.reuter@elastic.co> Co-authored-by: dej611 <dej611@gmail.com>
Summary
Second part of #89690
Most important changes
useEffect
s with linear codeonChange
of two properties from the store:lastKnownDoc
andindexPatternsForTopNav
a. Removing indexPatternsForTopNav from the global state and instead getting it in the lens_top_nav directly
b. Removing lastKnownDoc and instead calculating it from the global state in the app - could be improved further and be kept as a selector instead of keeping it in the local app state
framePublicAPI
- remove methodsaddLayer
andremoveLayer
and dispatch the store actions directly in chart_switcherDoubts:
lensSlice
To do in the future:
lens/updateAllStates
TODO before merging: