Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Infrastructure UI] Adopt new saved views API (#155827)
## 📓 Summary Part of #152617 Closes #106650 Closes #154725 This PR replace the existing client React logic for handling saved views on the `infra` plugin with a new state management implementation that interacts with the newly created API. It brings the following changes: - Implement `useInventoryViews` and `useMetricsExplorerViews` custom hooks. - Adopt `@tanstack/react-query` for the above hooks implementation as it was already used across the plugin and simplifies the server state management. Extract the provider for the react query cache. - Update server services to fix an issue while updating views, which was preventing the unset of properties from the view. - Update Saved Views components to integrate the new hooks. - The `Load views` option has been removed accordingly to the decision made with the UX team, since it wasn't adding any value that wasn't already present in the `Manage views` option. Even if we are duplicating similar logic to handle the Inventory and Metrics Explorer views, we decided to keep them separated to easily control their behaviour and avoid coupled logic that can be painful to split in future. ## 🐞 Bug fixes This implementation also fixed some existing bugs in production: - As reported in [this comment](#155174 (review)), when the current view is deleted, the selector doesn't fallback on another view and keeps showing the same view title. It has been fixed and the selected view fallbacks to the default view. - When refreshing the page after a view was selected, the view was not correctly recovered and shown. The implemented changes fix this behaviour. - The "include time" option for creating/updating a saved view was not working and never removed the time property if disabled. - Minor visual adjustments such as action button type and alignment. ## 👨💻 Review hints The best way to verify all the interactions and loadings work correctly as a user expects, running the branch locally with an oblt cluster is recommended. In both the inventory and metrics explorer pages, the user should be able to: - Access and manage the saved views, select and load a view, delete a view, and set a view as default. - Save a new view. - Update the currently used view, except for the static **Default view**. - Show an error when trying to create/update a view with a name already held by another view. - Restore the view with the following priority order - Use from the URL the stored view id to restore the view - Use the default view id stored in the source configuration as a user preference - Use the static **Default view** ## 👣 Following steps - [ ] #155117 --------- Co-authored-by: Marco Antonio Ghiani <marcoantonio.ghiani@elastic.co> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: jennypavlova <jennypavlova94@gmail.com>
- Loading branch information