-
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
Query Filter \ Filter Manager: de-angularize and move to data plugin #37311
Query Filter \ Filter Manager: de-angularize and move to data plugin #37311
Conversation
💚 Build Succeeded |
…ependency on rootScope
…plugin/filter-manager-1
💔 Build Failed |
…plugin/filter-manager-1
💔 Build Failed |
…plugin/filter-manager-1
…is now just a wrapper.
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
retest |
…plugin/filter-manager-1
retest |
This comment has been minimized.
This comment has been minimized.
💔 Build Failed |
retest |
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 good! I pulled down and tested quite a bit, using input controls with pinned filters by default and not pinned filters, a combination of unpinned and pinned filters created by visualizations and also by filtering on maps and saved searches (found an existing bug - #39802).
All seems to be working as expected! All my comments are minor.
...acy/core_plugins/data/public/filter/filter_bar/filter_editor/lib/filter_editor_utils.test.ts
Outdated
Show resolved
Hide resolved
src/legacy/core_plugins/data/public/filter/filter_manager/filter_manager.test.ts
Outdated
Show resolved
Hide resolved
this.globalState = globalState; | ||
this.filterManager = filterManager; | ||
|
||
this.watchFilterState(); |
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.
What do you think about requiring users to directly call watchFilterState
? Just thinking that it might be clearer to keep the side affects out of the constructor? I had a similar comment on a recent PR of mine, in DashboardStateManager, that the constructor has side affects. It did read a little funny in the test file that you need to instantiate the class, but then do nothing with it.
src/legacy/core_plugins/data/public/filter/filter_manager/filter_manager.ts
Outdated
Show resolved
Hide resolved
src/legacy/core_plugins/data/public/filter/filter_manager/filter_manager.ts
Outdated
Show resolved
Hide resolved
src/legacy/core_plugins/data/public/filter/filter_manager/filter_manager.ts
Outdated
Show resolved
Hide resolved
} | ||
); | ||
|
||
this.filters = newFilters; |
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.
Maybe move inside the if statement since if they aren't updated, no reason to set them?
src/legacy/core_plugins/data/public/filter/filter_manager/filter_manager.ts
Outdated
Show resolved
Hide resolved
src/legacy/core_plugins/data/public/filter/filter_manager/filter_manager.ts
Show resolved
Hide resolved
src/legacy/core_plugins/data/public/filter/filter_manager/filter_state_manager.ts
Outdated
Show resolved
Hide resolved
…er_state_manager.ts Co-Authored-By: Stacey Gammon <[email protected]>
…er_manager.ts Co-Authored-By: Stacey Gammon <[email protected]>
💔 Build Failed |
💔 Build Failed |
retest |
💚 Build Succeeded |
…plugin/filter-manager-1
…:lizozom/kibana into newplatform/data-plugin/filter-manager-1
💚 Build Succeeded |
💚 Build Succeeded |
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.
Here's my official LGTM! ... though I did not pull down and test the latest minor changes.
…lastic#37311) * Embeddable and Visualize to use type definitions from kbn-es-query package * moved state watching to new filter manager and removed query filter dependency on rootScope * Deleted unused pinFilter * Extracted merge fitlers function * Changed mappedFilters name * Move state management to new filter management as well. query filter is now just a wrapper. * Code works correctly with new setup of query filter * improved typing * Moved mapping into new filter manager * removed promise dependency from query filter * Extracted filter state manager from query filter * Moved addFiltersAndChangeTimeFilter logic into new filter manager * Fixed addFiltersAndChangeTimeFilter implementation * Moved all logic to new filter manager - query filter is just a wrapper now! * Connected query_filter observable management to new filter manager as well * Usage example in discover * filter state management tests + fire less events from filter state manager * Tests for filter manager and filter state manager * Moved new filter manager to data plugin * Got rid of FilterManagerProvider and turned it into a getFilterGenerator function that works with the new FilterManager. Need to merge this code with FilterManager. * Added tests that make sure that filter manager listens to filter state manager * fix typo * Fixed action add filter test * Fixed increasePredecessorCount test * Fixed increaseSuccessorCount test * Fixed setPredecessorCount test * Fixed setQueryParameters test * Fixed setSuccessorCount test * Fixed doc table filter actions test * Fixed filter generator tests * rename argument * Moved push filters into vis filters (only place where its used) * Filter type fix, test fix * Removed irrelevant filter tests (for deleted methods) Added state to filters * Fixed most of get filters errors by sleeping (TODO!) * Added destroy methods Improved merge logic Improved remove filter tests to use add filter (to avoid having for filter state manager to catch up) * Fixed discover functional tests Added default empty filter state in filter generator Some more browser test adjustments * Allow filter $state to be empty * Fixed types * Code review with @splager - subscribeWithScope - query filter to return angular promises - remove unneeded Promise.resolve * Separate class\type defenitions from plugin instance setup in shim plugin definition This helps avoiding circular dependency issues that were obsereved in filter-manager branch (due to code starting to use the data plugin). * typescript fun * Fixed merge * updated some get filter tests to work with add filter, and therefore moved them to add_filters.js * Remove shouldFetch and add comment explaning the observable. * Minor code style fixes * Code review fixes and changes * Moved Karma tests to jest * Fixed merge * Fixed some type errors * Improved watchFilterState logic * Removed addFiltersAndChangeTimeFilter test for now, as I'm having TS difficulties * filters can also be null * Further watch state fine tuning * Get data instance inside provider to avoid circular deps * mock chrome * Removed change to range filter * Deleted unnecessary injects * dedup setFilters as well * deleted unused subscription * Added tests for setFilters de-dupe * Update src/legacy/core_plugins/data/public/filter/filter_manager/filter_state_manager.ts Co-Authored-By: Stacey Gammon <[email protected]> * Update src/legacy/core_plugins/data/public/filter/filter_manager/filter_manager.ts Co-Authored-By: Stacey Gammon <[email protected]> * Code review minor fixes
…37311) (#40012) * Embeddable and Visualize to use type definitions from kbn-es-query package * moved state watching to new filter manager and removed query filter dependency on rootScope * Deleted unused pinFilter * Extracted merge fitlers function * Changed mappedFilters name * Move state management to new filter management as well. query filter is now just a wrapper. * Code works correctly with new setup of query filter * improved typing * Moved mapping into new filter manager * removed promise dependency from query filter * Extracted filter state manager from query filter * Moved addFiltersAndChangeTimeFilter logic into new filter manager * Fixed addFiltersAndChangeTimeFilter implementation * Moved all logic to new filter manager - query filter is just a wrapper now! * Connected query_filter observable management to new filter manager as well * Usage example in discover * filter state management tests + fire less events from filter state manager * Tests for filter manager and filter state manager * Moved new filter manager to data plugin * Got rid of FilterManagerProvider and turned it into a getFilterGenerator function that works with the new FilterManager. Need to merge this code with FilterManager. * Added tests that make sure that filter manager listens to filter state manager * fix typo * Fixed action add filter test * Fixed increasePredecessorCount test * Fixed increaseSuccessorCount test * Fixed setPredecessorCount test * Fixed setQueryParameters test * Fixed setSuccessorCount test * Fixed doc table filter actions test * Fixed filter generator tests * rename argument * Moved push filters into vis filters (only place where its used) * Filter type fix, test fix * Removed irrelevant filter tests (for deleted methods) Added state to filters * Fixed most of get filters errors by sleeping (TODO!) * Added destroy methods Improved merge logic Improved remove filter tests to use add filter (to avoid having for filter state manager to catch up) * Fixed discover functional tests Added default empty filter state in filter generator Some more browser test adjustments * Allow filter $state to be empty * Fixed types * Code review with @splager - subscribeWithScope - query filter to return angular promises - remove unneeded Promise.resolve * Separate class\type defenitions from plugin instance setup in shim plugin definition This helps avoiding circular dependency issues that were obsereved in filter-manager branch (due to code starting to use the data plugin). * typescript fun * Fixed merge * updated some get filter tests to work with add filter, and therefore moved them to add_filters.js * Remove shouldFetch and add comment explaning the observable. * Minor code style fixes * Code review fixes and changes * Moved Karma tests to jest * Fixed merge * Fixed some type errors * Improved watchFilterState logic * Removed addFiltersAndChangeTimeFilter test for now, as I'm having TS difficulties * filters can also be null * Further watch state fine tuning * Get data instance inside provider to avoid circular deps * mock chrome * Removed change to range filter * Deleted unnecessary injects * dedup setFilters as well * deleted unused subscription * Added tests for setFilters de-dupe * Update src/legacy/core_plugins/data/public/filter/filter_manager/filter_state_manager.ts Co-Authored-By: Stacey Gammon <[email protected]> * Update src/legacy/core_plugins/data/public/filter/filter_manager/filter_manager.ts Co-Authored-By: Stacey Gammon <[email protected]> * Code review minor fixes
Important: Much of the code was merged accidentally by another PR
Summary
This PR a full rewrite of
query_filter
into thedata/filter/filter_manager
new platform service.This was done in such a way that the API is fully backwards compatible.
Previously, initializing queryFilter was done this way:
While this is still supported, you can also use the FilterManager instance directly:
This PR also includes a very simple de-angularization of
FilterManagerProvider
.It is now used in the following manner:
But it should be merged with
FilterManager
.Notes and comments
Private
caching to instantiate a single instance ofFilterManager
per app.es-query
Filter
type definition changed, and$state
is now optional. This is due to the fact that some places create filters without state.FilterManager
however, makes sure that all filters have state.globalState
,getAppState
and indexPatterns are still angular injected dependencies.FilterStateManager
is just a convenience wrapper around app+global states, and might be removed when a new state manager is introduced. It uses setTimeout instead of rootScope to watch state variables. It can be changed, but everything works this way as well.FilterManager
, there was a very old optimization that didn't re-fetch the data, when specific filter updates occurred:I went over this with @spalger and this optimization seems irrelevant. I removed it and for now we just fire fetch and update events at the same time (to avoid changing subscribers).
query_filter
there several methods that were not being used by anything, but were there for completeness (liketoggleAll
anddisableAll
for example). I chose not to implement them for the time being, but they may be implemented again if needed.ui/errors
due to a new error that started to happen once I started loading the filter mappers from .ts files. If any one has suggestions about this error, I'd love to hear!FilterManager
andFilterStateManager
was added, and olderquery_filter
tests were updated.Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.[ ] This was checked for cross-browser compatibility, including a check against IE11[ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support