Skip to content

Comments

[Discover] Migrate context AppState / GlobalState to use new app state helpers #57078

Merged
kertal merged 26 commits intoelastic:masterfrom
kertal:kertal-pr-2020-02-07-context-new-app-state
Feb 18, 2020
Merged

[Discover] Migrate context AppState / GlobalState to use new app state helpers #57078
kertal merged 26 commits intoelastic:masterfrom
kertal:kertal-pr-2020-02-07-context-new-app-state

Conversation

@kertal
Copy link
Member

@kertal kertal commented Feb 7, 2020

Summary

Remove legacy AppState & GlobalState from Discover's Context application, replace with our shiny new state syncing utils #56479

Bildschirmfoto 2020-02-14 um 14 00 35

Testing

Check if changed settings in the URL are propagated to UI and vice versa, and whether reloading of data takes place.

Checklist

Delete any items that are not applicable to this PR.

@elasticmachine

This comment has been minimized.

@kertal
Copy link
Member Author

kertal commented Feb 10, 2020

Retest

@kertal
Copy link
Member Author

kertal commented Feb 10, 2020

@elasticmachine merge upstream

@kertal kertal added the Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// label Feb 12, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@kertal kertal added the release_note:skip Skip the PR/issue when compiling release notes label Feb 12, 2020
@kertal kertal marked this pull request as ready for review February 12, 2020 07:28
@kertal kertal requested a review from a team February 12, 2020 07:28
@kertal
Copy link
Member Author

kertal commented Feb 12, 2020

Jenkins, test this ... last test ran into a timeout

@kertal kertal changed the title [Discover] Migrate context to new app state helpers [Discover] Migrate context AppState / GlobalState to user new app state helpers Feb 14, 2020
@kertal kertal changed the title [Discover] Migrate context AppState / GlobalState to user new app state helpers [Discover] Migrate context AppState / GlobalState to use new app state helpers Feb 14, 2020
@kertal
Copy link
Member Author

kertal commented Feb 14, 2020

@elasticmachine merge upstream

@Dosant
Copy link
Contributor

Dosant commented Feb 14, 2020

ACK. will review and test later today

@flash1293
Copy link
Contributor

Not sure what this is caused by, but setting a range filter pill ("is between") with just the end defined will result in two pills in this PR and the history doesn't work correctly afterwards:
Screenshot 2020-02-14 at 13 55 43
Screenshot 2020-02-14 at 13 57 12

On master this works fine for me.

Same with pinning a filter, then hitting the back button (won't unpin it)

@kertal
Copy link
Member Author

kertal commented Feb 14, 2020

Not sure what this is caused by, but setting a range filter pill ("is between") with just the end defined will result in two pills in this PR and the history doesn't work correctly afterwards:
Screenshot 2020-02-14 at 13 55 43
Screenshot 2020-02-14 at 13 57 12

On master this works fine for me.

Same with pinning a filter, then hitting the back button (won't unpin it)

@flash1293 excellent catch!
first issue seems an issue with having a NaN as value in the filters
i've got an idea what's the cause of the second issue, maybe 2 updates of the state after each other, first global, then local, but didn't test so far ... currently on it

@kertal
Copy link
Member Author

kertal commented Feb 14, 2020

FYI @flash1293 @Dosant I managed to fix the problem @flash1293 reported, but I need to further investigate the app's behavior. Seems a missing reloadOnSearch: false in the legacy $routeProvider's route, triggered a reload of the ContextAppRouteController every time the URL changed. Adding it breaks other functionality. So there are some further adaptions necessary before the review can be finished.

Copy link
Contributor

@Dosant Dosant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it makes sense in scope of this to remove this.filters from src/legacy/core_plugins/kibana/public/discover/np_ready/angular/context.js and allow filterManager to handle everything, just like @lizozom did in discover #56160.
It should remove plenty of code

@kertal
Copy link
Member Author

kertal commented Feb 17, 2020

@flash1293 @Dosant @sulemanof Context was built around reloadOnSearch: true, each change of the url triggered a reload of the controller. That was the cause for troubles. A change to reloadOnSearch: false would lead to a bigger refactoring.

What I did is improve the code, remove state subscriptions (since: change of state => change of url => controller reload => reinitialize state), and add more tests. It's nice to write unit tests concerning state <-> url syncing. Hope this is fine now.

@kertal kertal requested a review from Dosant February 17, 2020 12:40
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Contributor

@Dosant Dosant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM. Nice work!

I noticed an issue, similar to one I had in dashboard - #56284
Looks like 'state:storeInSessionStorage' doesn’t take effect for without full page reload.

It is likely caused by kbnStateStorage is created once when angular is initialised and then when you get back to Context App, it is not recreated with new 'state:storeInSessionStorage' value.

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and works fine for me. Great work 🎉

@kertal kertal merged commit 23306d8 into elastic:master Feb 18, 2020
kertal added a commit to kertal/kibana that referenced this pull request Feb 18, 2020
…e helpers (elastic#57078)

* Remove globalState, migrate to the new helpers

* Remove appState, migrate to the new helpers

* Add tests
@kertal
Copy link
Member Author

kertal commented Feb 18, 2020

@Dosant when I change state:storeInSessionStorage to true, navigate back to content, the initial URL is still unhashed, but all follow up URL modifications are hashed, so I didn't need to reload. Is this the behavior you've noticed? thx!

kertal added a commit that referenced this pull request Feb 18, 2020
…e helpers (#57078) (#57840)

* Remove globalState, migrate to the new helpers

* Remove appState, migrate to the new helpers

* Add tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature:NP Migration release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// v7.7.0 v8.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants