[Unified Histogram] [Discover] Unified Histogram solutions cleanup#146352
[Unified Histogram] [Discover] Unified Histogram solutions cleanup#146352davismcphee merged 23 commits intoelastic:mainfrom
Conversation
374df21 to
7e62e31
Compare
9755251 to
ff9af0b
Compare
8eb9760 to
0057c9d
Compare
…, and prevent multiple fetches
…sing trigger callbacks to Lens embeddable or disabling them
…quest was sent, resulting in it being unavailable in the inspector
7cbc16c to
bfcd21a
Compare
|
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
| [ | ||
| data, | ||
| initialFetchStatus, | ||
| inspectorAdapters.requests, | ||
| main$, | ||
| refetch$, | ||
| searchSessionManager, | ||
| searchSource, | ||
| initialFetchStatus, | ||
| }); | ||
| services.toastNotifications, | ||
| setAutoRefreshDone, | ||
| timefilter, | ||
| ] | ||
| ); |
There was a problem hiding this comment.
those deps will soon be gone, just saying ... with the whole file saved from a hook ... #148614
| * Accepts a callback and returns a function with a stable identity | ||
| * that will always call the latest version of the callback when invoked | ||
| */ | ||
| export const useStableCallback = <T extends (...args: any[]) => any>(fn: T | undefined) => { |
There was a problem hiding this comment.
maybe thats's something for react-use of @vadimkibana ?
https://github.com/streamich/react-use
There was a problem hiding this comment.
That's actually where I went looking for an implementation originally, but unfortunately had to fall back on a custom one. Definitely a useful pattern, although I wonder how useful an addition it would be if the React team intends to implement an official version in the near future -- or so they say 😄
| disableTriggers, | ||
| disabledActions, |
There was a problem hiding this comment.
to understand it correctly, we offer disableTriggers + disableActions just for alignment, but don't set custom values ... I'm interested, what's the user case to set them?
There was a problem hiding this comment.
Yeah this change was more in anticipation of future needs from other consumers. The main use case would be to disable adding/removing filters from the legend, disable time range scrubbing, etc. for cases where filters or the time range might not be modifiable. These actions also integrate with the search service by default which might not be used in some situations.
|
@elasticmachine merge upstream |
|
@jughosta Great catch! That was a really tricky one -- since I added a functional for this one now so hopefully we don't run into a similar issue in the future. Commit here: 27b8f47. |
…to update properly on time range changes
19cc297 to
27b8f47
Compare
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
Async chunks
Public APIs missing exports
Page load bundle
Unknown metric groupsAPI count
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @davismcphee |
…lastic#146352) ## Summary This PR includes a number of updates to Unified Histogram to prepare for sharing with solutions, as well as updating its usage in Discover: Unified Histogram: - Adds a `disableAutoFetching` prop, similar to Unified Field List, to disable automatic Unified Histogram refetching based on prop changes. - Accepts an `input$` observable prop that can be used to control manual refetches. - Removes `refetchId` used internally and replaces it with an observables based approach to simplify refetch logic. - Introduces a `use_stable_callback` utility hook to create callback functions with stable identities which simplifies `useCallback` logic — should be replaced with `useEvent` or whatever the React team comes up with to solve this specific issue when available: reactjs/rfcs#220. - Eliminates debouncing logic in Unified Histogram since it was hacky — manual refetching should be used instead if debouncing is needed. - Accepts `query`, `filters`, and `timeRange` props to remove dependencies on specific services. - Updates `use_request_params` to export `getTimeRange` and `updateTimeRange` functions for easier absolute time range handling. - Exposes some Lens embeddable props to allow further customizing Unified Histogram behaviour. Discover: - Exports a `fetch$` observable from `use_saved_search` to allow listening for when data fetches should be triggered. - Uses new manual refetching support in Unified Histogram to simplify refetching logic. - Passes `query`, `filters`, and `timeRange` props to Unified Histogram. ### Checklist - [ ] ~Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)~ - [ ] ~[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials~ - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] ~Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/))~ - [ ] ~Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))~ - [ ] ~If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)~ - [ ] ~This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))~ - [ ] ~This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers)~ ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>


Summary
This PR includes a number of updates to Unified Histogram to prepare for sharing with solutions, as well as updating its usage in Discover:
Unified Histogram:
disableAutoFetchingprop, similar to Unified Field List, to disable automatic Unified Histogram refetching based on prop changes.input$observable prop that can be used to control manual refetches.refetchIdused internally and replaces it with an observables based approach to simplify refetch logic.use_stable_callbackutility hook to create callback functions with stable identities which simplifiesuseCallbacklogic — should be replaced withuseEventor whatever the React team comes up with to solve this specific issue when available: RFC: useEvent reactjs/rfcs#220.query,filters, andtimeRangeprops to remove dependencies on specific services.use_request_paramsto exportgetTimeRangeandupdateTimeRangefunctions for easier absolute time range handling.Discover:
fetch$observable fromuse_saved_searchto allow listening for when data fetches should be triggered.query,filters, andtimeRangeprops to Unified Histogram.Checklist
Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n supportDocumentation was added for features that require explanation or tutorialsAny UI touched in this PR is usable by keyboard only (learn more about keyboard accessibility)Any UI touched in this PR does not create any new axe failures (run axe in browser: FF, Chrome)If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the docker listThis renders correctly on smaller devices using a responsive layout. (You can test this in your browser)This was checked for cross-browser compatibilityFor maintainers