elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.76k stars 8.15k forks source link

[ResponseOps][AlertsTable] Migrate API hooks to React Query #186448

Closed cnasikas closed 1 month ago

cnasikas commented 3 months ago

The alerts table uses various hooks to make API calls. Most of the hooks are using React Query to perform these API calls, The useFetchAlerts and useFetchBrowserFieldCapabilities do not. We should migrate the rest of the hook to use React Query.

### DoD
- [x] Migrate `useFetchAlerts` to React Query https://github.com/elastic/kibana/pull/186978
- [x] Migrate `useFetchBrowserFieldCapabilities` to React Query https://github.com/elastic/kibana/pull/188320
elasticmachine commented 3 months ago

Pinging @elastic/response-ops (Team:ResponseOps)

umbopepato commented 2 months ago

While doing this refactor I'm taking the occasion to try and standardize the naming and shape of TanStack Query-based hooks in the alerts area.

Naming rule

   use     +     FetchAlerts   +    Query/Mutation
    |                 |                    |
   hook          name of the      to highlight the fact
                corresponding    that it returns a query
                fetch function    or mutation object

Arguments

Return

The whole query or mutation object, to better standardize the return types across different data fetching hooks and to give the user the freedom to access loading states, refetch functions etc.