-
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
Stateful search bar default behaviors #56160
Stateful search bar default behaviors #56160
Conversation
Pinging @elastic/kibana-app-arch (Team:AppArch) |
…ata/stateful-search-bar-2
…ata/stateful-search-bar-2
@kertal committed a fix for this literally 30 seconds ago |
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.
lgtm
@lizozom this fixed the context display problem, guess the hopefully last problem here is the one you're currently working on: can't add filters in context view |
Improve useSavedQuery hook in terface
…ata/stateful-search-bar-2
…izozom/kibana into newplatform/data/stateful-search-bar-2
@kertal I think I managed to stabilize this, but lets wait until CI is green :) |
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, context now works as expected! Thx a lot for cleaning up ancient discover/context code!
@elasticmachine merge upstream |
* Clean up discover * Clean up visualize * Clean up dashboard * use-default-behaviors * ts * Discover interval changing * timerange for interval definition in editor * ts * Revert most of changes to dashboard app because of changes in elastic#55443 * Fix spaces * Revert editor to scope PR! * typo * keep savedQuery state in create search bar * update saved query to save it with the state * revert all dashboard changes * saved queries * @kertal code review * fix applying filters from histogram * @Dosant code review * Merge changes from elastic#56643 to handle saved query errors Fix bug where saved query clean does not reset query * change string path * if * Extract useFilterManager and useTimefilter * Split useSavedQuery and restore capability of changing saved query in URL * Added some tests * context view * Remove useMemo * spaces * Support filter intial values Improve useSavedQuery hook in terface Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
* Clean up discover * Clean up visualize * Clean up dashboard * use-default-behaviors * ts * Discover interval changing * timerange for interval definition in editor * ts * Revert most of changes to dashboard app because of changes in #55443 * Fix spaces * Revert editor to scope PR! * typo * keep savedQuery state in create search bar * update saved query to save it with the state * revert all dashboard changes * saved queries * @kertal code review * fix applying filters from histogram * @Dosant code review * Merge changes from #56643 to handle saved query errors Fix bug where saved query clean does not reset query * change string path * if * Extract useFilterManager and useTimefilter * Split useSavedQuery and restore capability of changing saved query in URL * Added some tests * context view * Remove useMemo * spaces * Support filter intial values Improve useSavedQuery hook in terface Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
💔 Build FailedHistory
To update your PR or re-run it, just comment with: |
Summary
The goal of the stateful version of
SearchBar
\TopNavMenu
is to be an easy way to consume the services offered byplugins.data.query
where developers should be able to provide minimal configuration and get a fully workingSearchBar
.I used the
discover
application as a sample app integration with the stateful component. (These changes were tested on visualize \ dashboard, but to keep this PR as small as possible, I left them out).The React equivalent of the API used by discover is:
It is important to note that the SearchBar API is still undergoing changes so there might be still some inconsistencies to scope this PR
Current state (on master)
These features have default behaviors on master
These features don't have a default implementation
Hence when configuring a new
SearchBar
(orTopNav
) a developer had to provide an implementation for behaviors that don't have default behaviors.Moreover, most application haven't fully utilized this capability because it was partial and undocumented.
Default Behaviors
This PR adds all missing default behaviors and utilizes them to clean up
discover
. In order not to refactor all places usingSearchBar
\TopNavMenu
, I made it opt-in using the flaguseDefaultBehavior
.Filters
data.query.filterManager
via state.FilterBar
, their state is automatically stored intodata.query.filterManager
.data.query.filterManager
posts updates via an observable, you cannot pass in an additional callback into the statefulSearchBar
.defaultFiltersUpdated
Timefilter \ Autorefresh settings
data.query.timefilter
via state.Timepicker
, their state is automatically stored intodata.query.timefilter
.timefilter
posts updates via an observable, which is the preferred way to track changes. This is the only way to get notified of autorefresh changes, however, passing in a customonQuerySubmit
callback is still supported.defaultOnQuerySubmit
anddefaultOnRefreshChange
Query String settings
SearchBar
.Timepicker
, its state is automatically stored into the stateful SearchBar (will be moved to query string manager when available).onQuerySubmit
and should be tracked by application state, since there's no API to retrieve them fromdata
plugin.defaultOnQuerySubmit
.Saved Queries
defaultOnClearSavedQuery
,defaultOnSavedQueryUpdated
,defaultOnQuerySaved
.Next steps
onQuerySubmit
as the only mean of getting updates on query changes.SearchBar
Dev Docs
The goal of the stateful version of SearchBar \ TopNavMenu is to be an easy way to consume the services offered by plugins.data.query where developers should be able to provide minimal configuration and get a fully working SearchBar.
Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.For maintainers