Skip to content
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

[Drilldowns] Fix missing $store in filter state syncing edge case #61261

Conversation

Dosant
Copy link
Contributor

@Dosant Dosant commented Mar 25, 2020

Summary

Part of #61230
Originally I put this fix into #60087, but as it has nothing to do with drilldowns, extracting into separate pr.

In drilldown branch during navigating to dashboard filters were generated without store value explicitly set (this could theoretically happen in other places, as the value is optional).
In url we were setting those filters into either _a or _g query param, which makes it clear if filter is unpinned or pinned.
After navigation store was add to the filter object, changing it's shape and state syncing utils run a redundant browser history update which broke back button.

This pr change makes sure that data service state syncing utilities are ignoring update of internal filter's $state value if specific type of filters (pinned or unpinned) is being synced.

Testing

It is hard to test without drilldowns branch context: #60087
Functional test will be added together with drilldown #60087 (comment)

It is possible to "mimic" the navigation which will happen in drilldown:

  1. Create a dashboard "origin"
  2. Create a dashboard "destination". Get a url to this dashboard with some filter applied. remove $store.state part from the filter object in the link.
  3. Create a Markdown vis and and render the link to destination dashboard with modified filter there. Add Markdown vis to origin dashboard.
  4. Go to original dashboard, click on a link. you should be navigated to destination dashboard with applied filter from the url.
  5. Press back button

Expected behaviour: navigated back to origin dashboard
Current in master: back didn't work

@Dosant Dosant changed the title Improve filters comparision logic for missing filter edge case [Drilldowns] Missing $store in filter state syncing edge case Mar 25, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-arch (Team:AppArch)

@Dosant Dosant added review v7.8 v7.8.0 release_note:skip Skip the PR/issue when compiling release notes Feature:Drilldowns Embeddable panel Drilldowns Feature:StateManagement and removed v7.8 labels Mar 25, 2020
@Dosant Dosant changed the title [Drilldowns] Missing $store in filter state syncing edge case [Drilldowns] Fix missing $store in filter state syncing edge case Mar 25, 2020
@Dosant Dosant added the v8.0.0 label Mar 25, 2020
@Dosant Dosant marked this pull request as ready for review March 25, 2020 16:18
@Dosant Dosant requested a review from a team as a code owner March 25, 2020 16:18
@Dosant Dosant requested a review from lizozom March 25, 2020 16:18
@lizozom
Copy link
Contributor

lizozom commented Mar 29, 2020

@elasticmachine merge upstream

@@ -91,15 +91,21 @@ export const connectToQueryState = <S extends QueryState>(
} else if (syncConfig.filters === FilterStateStore.GLOBAL_STATE) {
if (
!initialState.filters ||
!compareFilters(initialState.filters, filterManager.getGlobalFilters(), COMPARE_ALL_OPTIONS)
!compareFilters(initialState.filters, filterManager.getGlobalFilters(), {
Copy link
Contributor

@lizozom lizozom Mar 29, 2020

Choose a reason for hiding this comment

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

The fix does work as expected.

However, as far as I understand, the problem with the filters coming in from initialState.filters.
I think it would be more correct, if we updated any filter without a store value to FilterStateStore.APP_STATE.
What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since $store was recently added and is optional would be hard to find all places where filters could come with missing $store. e.g., (link generations with missing $store in filters).

Also there are old kibana versions urls which are out of our control and old saved objects where filters are missing $store.

Apps work with missing $store, which is great. But would be also nice to fix this possible edge case with url syncing.

Copy link
Contributor

@lizozom lizozom left a comment

Choose a reason for hiding this comment

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

After syncing over zoom, LGTMinitialState

@Dosant
Copy link
Contributor Author

Dosant commented Mar 31, 2020

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

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

@Dosant Dosant merged commit c0a5b23 into elastic:master Mar 31, 2020
Dosant added a commit to Dosant/kibana that referenced this pull request Mar 31, 2020
Dosant added a commit that referenced this pull request Mar 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Drilldowns Embeddable panel Drilldowns Feature:StateManagement release_note:skip Skip the PR/issue when compiling release notes review v7.8.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants