Convert Host route tree to react-router v6 Routes - #415
Merged
Conversation
Migrate the Host list and detail route trees (including the nested HostGroups subtree) from the react-router v5 <Switch>/<Route>/<Redirect> API to v6 <Routes>/<Route> via react-router-dom-v5-compat, following the pattern used for the earlier screen conversions. - Hosts.js: <Switch> -> <Routes>; child routes use the element prop; the detail route uses /hosts/:id/* so the nested <Host> tree matches the rest of the path. - Host.js: <Switch> -> <Routes> with relative child paths (details, edit, facts, groups/*, jobs); the exact <Redirect> becomes an index route that <Navigate>s to details; the catch-all not-found route is kept as path="*"; useRouteMatch is replaced with the id route param, and the data routes stay guarded on the loaded host. - HostGroups/HostGroups.js (nested subtree): its single absolute-path <Switch> route becomes an index <Route> under the groups/* parent. - Rewrite the three test suites with renderWithContexts (RTL) to assert real v6 route resolution: each tab panel, the groups subtree, the index redirect, the unknown sub-route not-found error, and the 404.
Under the v6 route tree, v5 router hooks in descendants no longer see the
route match: HostList's useRouteMatch() returned match.url='/' (links to
//add, //:id/details) and HostGroupsList read the host id via v5
useParams() which returned {}. Build HostList links from the literal
/hosts base, and read HostGroupsList's useParams from
react-router-dom-v5-compat.
Contributor
There was a problem hiding this comment.
Pull request overview
Migrates the Host screen’s routing from react-router v5 (<Switch>, <Redirect>) to react-router v6-style <Routes>/<Route> using react-router-dom-v5-compat, including the nested HostGroups subtree, and updates the associated tests to assert real v6 route resolution.
Changes:
- Converted
Hosts(list) andHost(detail) route trees to<Routes>withelementprops and an index redirect via<Navigate replace>. - Updated HostGroups subtree routing to an index route under the
groupsparent. - Rewrote the Host/Hosts/HostGroups test suites to use RTL
renderWithContextsand validate v6 route matching.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| awx/ui/src/screens/Host/Hosts.js | Converts Host list-level routing to v6 <Routes> and delegates detail subtree via /hosts/:id/*. |
| awx/ui/src/screens/Host/Host.js | Converts Host detail routing to v6-style nested routes with an index redirect and relative child paths. |
| awx/ui/src/screens/Host/HostGroups/HostGroups.js | Converts HostGroups subtree to v6 <Routes> with an index route. |
| awx/ui/src/screens/Host/HostList/HostList.js | Removes useRouteMatch usage and switches list navigation URLs to absolute host routes. |
| awx/ui/src/screens/Host/HostGroups/HostGroupsList.js | Adjusts router hook imports to align with v5-compat usage for params. |
| awx/ui/src/screens/Host/Hosts.test.js | Rewrites routing assertions using RTL to validate which v6 route branch resolves for a URL. |
| awx/ui/src/screens/Host/Host.test.js | Rewrites detail routing tests with RTL, including index redirect and not-found behaviors. |
| awx/ui/src/screens/Host/HostGroups/HostGroups.test.js | Rewrites subtree routing test with RTL under the same parent route shape as the app. |
The nested <Routes> only defined an index route, so an unknown sub-path under groups/ (e.g. /hosts/:id/groups/something) rendered a blank panel in v6. Add a path="*" route that renders a not-found ContentError.
Contributor
Author
|
Thanks for the review. Addressed in |
cigamit
approved these changes
Jun 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SUMMARY
Continues the react-router v5 → v6 route-tree migration. Converts the Host screen's route trees — list, detail, and the nested
HostGroupssubtree — from the v5<Switch>/<Route>/<Redirect>API to v6<Routes>/<Route>viareact-router-dom-v5-compat, following the pattern used for the earlier screen conversions.UI (no behavior change — same URLs, same panels):
Hosts.js(list router):<Switch>→<Routes>; child routes use theelementprop; the detail route is/hosts/:id/*so the nested<Host>tree can match the rest of the path.Host.js(detail router):<Switch>→<Routes>with relative child paths (details,edit,facts,groups/*,jobs); theexact<Redirect>becomes an index route that<Navigate replace>s todetails; the catch-all not-found route stays aspath="*";useRouteMatchis replaced with theidroute param, and the data routes stay guarded on the loadedhost.HostGroups/HostGroups.js(nested subtree): its single absolute-path<Switch>route becomes an index<Route>under thegroups/*parent.renderWithContexts(RTL) to assert real v6 route resolution — each tab panel, the groups subtree, the index redirect, the unknown-sub-route not-found error, and the 404 detail error.ISSUE TYPE
COMPONENT NAME
ADDITIONAL INFORMATION
main.HostGroups) together so the relativegroups/*delegation resolves under the v6 parent.screens/Hostdirectory passes (13 suites / 60 tests).npm --prefix awx/ui run lintclean on the changed source.