-
Notifications
You must be signed in to change notification settings - Fork 281
Update to use React Router data router APIs #3465
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
Update to use React Router data router APIs #3465
Conversation
This is required to use the `handle` route prop which will be used to replace custom routes such as `NamespacedRoute`, `ReadWriteRoute`, and allow for more centralised processing of most API requests via React Query's default query function.
This is a step towards using React Query's default query function which will allow us to remove many of the custom API functions, hooks, etc. While this introduces a slight increase in the amount of code, this is temporary and will ultimately allow for a significant reduction in the amount of boilerplace code required across the application. It will allow for removal of most of the custom hooks for loading resources (both lists and single items) as well as removal of much of the custom websocket handling code.
Switch from custom `NamespacedRoute` wrapper container to the natively supported `handle` route prop. This `handle` prop will be used further with the React Query default query function to reduce the amount of boilerplate code required for each route / resource, particularly at the API layer.
briangleeson
left a comment
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.
Thanks for the walkthrough. Couple of nits but otherwise looks good overall
Implement and use React Query's default query function to reduce the amount of API boilerplate required per resource kind. Also switch to the new model of calling useQuery with a single object containing `queryKey` etc. since that's the only approach supported in the next major version of React Query.
848ce14 to
5307d30
Compare
briangleeson
left a comment
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
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: briangleeson The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Changes
Related to #2452
There will be be at least one additional PR to refactor some of the remaining resource list / resource details containers and move the configuration of the resource GVK to the routes instead of using custom API hooks.
This is all part of a greater effort to reduce boilerplate, which reduces the maintenance overhead for each additional resource type added, and in turn reduces the barrier to entry for contributors as the code is much simplified and easier to modify. It will also provide greater consistency across resources in terms of layout, functionality, etc. Some resources such as *Runs are likely to remain quite different due to the additional content associated with them, but will be able to leverage the simplified config to reduce the amount of custom code required for each of their views.
/kind misc
Submitter Checklist
As the author of this PR, please check off the items in this checklist:
functionality, content, code)
/kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tepRelease Notes