[Visualize] Remove legacy appState in visualize#57330
[Visualize] Remove legacy appState in visualize#57330sulemanof merged 15 commits intoelastic:masterfrom
Conversation
|
Pinging @elastic/kibana-app (Team:KibanaApp) |
|
@Bargs I would kindly ask you to test the |
src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js
Outdated
Show resolved
Hide resolved
src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/lib/visualize_app_state.ts
Show resolved
Hide resolved
src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js
Outdated
Show resolved
Hide resolved
| stateMonitor = stateMonitorFactory.create($state, stateDefaults); | ||
| stateMonitor.ignoreProps(['vis.listeners']).onChange(status => { | ||
| $appStatus.dirty = status.dirty || !savedVis.id; | ||
| }); |
There was a problem hiding this comment.
Since you've removed the stateMonitor (which is good), I might be wrong but $appStatus.dirty is just initialized and no longer changed?
There was a problem hiding this comment.
Hey, yeah!
I left one initializing reference to it intentionally!
I would highlight the thing about the $appStatus, because I didn't find a proper case how should it work!
So, if someone has a vision about how should this work, he can mention it here.
If it's redundant, I'll remove it!
There was a problem hiding this comment.
$appStatus.isDirty is used when you want to share a visualization, but it has not been saved before, or there were changes after saving.
When you then try to generate a report you get the following message:
"Please save your work before generating a report."
So $appStatus.isDirty should be set to true, when the visualization was not saved, or it was saved and the appState changed.
It should be set to false once the visualization was saved. And this persisted state is the state that you need to check agains for further changes that modify $appStatus.isDirty
There was a problem hiding this comment.
@kertal thanks for the deep explanation!
Applied dirty state checker due to current code
flash1293
left a comment
There was a problem hiding this comment.
This looks really good! Found two small things but overall great work!
src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js
Outdated
Show resolved
Hide resolved
src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js
Outdated
Show resolved
Hide resolved
| if (!$scope.linked) return; | ||
|
|
||
| $state.linked = false; | ||
| $scope.linked = false; |
There was a problem hiding this comment.
When testing the link/unlink saved search did not work when using browser back/forward buttons - probably because the linked state is saved outside of the state? Would it make sense to also put it in app state? Looks like it is currently part of it.
There was a problem hiding this comment.
Good catch! Updated!
|
Noticed a small bug - when pinning a filter, you have to hit the back button twice to get back to the old non-pinned status - it seems like it's writing two history entries for this case. Maybe that's because it is half angular / half utils state management - also fine with fixing it when migrating global state, but we should create an issue in this case to make sure not to forget it. |
…p_state # Conflicts: # src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js
Good catch @flash1293 ! |
|
@sulemanof about the linked saved search: It seems like this doesn't work completely - it is putting the link back in place, but it's not updating the search source behind the scenes. The filters are just gone. Example (saved search filtering by category "Womens clothing"): after unlinking saved search (correct behavior) after pressing back button (changed results, seems like the filters aren't put back in place): Not sure whether that ever worked because it seems like the |
|
Besides the problem above everything else works as expected for me. |
…p_state # Conflicts: # src/legacy/core_plugins/kibana/public/visualize/legacy_imports.ts
|
Hey @flash1293 |
|
@sulemanof Sounds good to me, thanks for creating the issue. |
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
Dosant
left a comment
There was a problem hiding this comment.
Code looks good to me,
Tested some advanced cases like switching between hashed / expanded url format, navigating between vis / dashboard and using recently viewed items - didn't notice any issues.
|
|
||
| export function useVisualizeAppState({ useHash, stateDefaults }: Arguments) { | ||
| const history = createHashHistory(); | ||
| const kbnUrlStateStorage = createKbnUrlStateStorage({ |
There was a problem hiding this comment.
Just for info: to fix pinned/unpinned filter, it will be important that global state syncing uses the same kbnUrlStateStorage as app state syncing.
flash1293
left a comment
There was a problem hiding this comment.
Tested and works as expected, LGTM 👍
kertal
left a comment
There was a problem hiding this comment.
Code LGTM, "dirty" state is handled correctly, great work! tested locally in Chrome
* master: (136 commits) [Visualize] Remove legacy appState in visualize (elastic#57330) Use static time for tsvb rollup test (elastic#57701) [SIEM] Fix ResizeObserver polyfill (elastic#58046) [SIEM][Detection Engine] Fixes return codes where some were rule_id instead of id skip flaky suite (elastic#56816) skip flaky suite (elastic#58059) skip flaky suite (elastic#45348) migrates notification server routes to NP (elastic#57906) Moved all of the show/hide toggles outside of ordered lists. (elastic#57163) [APM] NP Migration - Moves plugin server files out of legacy (elastic#57532) [Maps][Telemetry] Migrate Maps telemetry to NP (elastic#55055) Embeddable add panel examples (elastic#57319) Fix useRequest to support query change (elastic#57723) Allow custom paths in plugin generator (elastic#57766) [SIEM][Case] Merge header components (elastic#57816) [ML] New Platform server shim: update job audit messages routes (elastic#57925) [kbn/optimizer] emit success event from reducer when all bundles cached (elastic#57945) [APM] Don’t include UI filters when fetching a specific transaction (elastic#57934) Upgrade yargs (elastic#57720) skip flaky suite (elastic#57762) (elastic#57997) (elastic#57998) ... # Conflicts: # src/plugins/advanced_settings/public/management_app/components/field/__snapshots__/field.test.tsx.snap # src/plugins/advanced_settings/public/management_app/components/field/field.tsx # x-pack/plugins/translations/translations/ja-JP.json # x-pack/plugins/translations/translations/zh-CN.json



Summary
Remove legacy appState in visualize and use new platform utilities for state management
Resolves #56492
AppStatein visualize;AppState.makeStatefulmethod with a localmakeStatefulutility. This is used to create an instnace ofPersistedStatefor theuiStateobject, and seems is was used only in visualize (it's also used in discover now, but will be removed), so could be safely removed with the AppState class;createStateContainerutility for app state management;createKbnUrlStateStorageutility for url state management;syncStateto bound theappStateand theurlstate updates;Also resolves #55084
Manipulating with history back/forward :
Checklist
Delete any items that are not applicable to this PR.
For maintainers