Skip to content

Convert Team route tree to react-router v6 Routes - #409

Merged
cigamit merged 4 commits into
ctrliq:mainfrom
blaipr:feature/react-router-team
Jun 15, 2026
Merged

Convert Team route tree to react-router v6 Routes#409
cigamit merged 4 commits into
ctrliq:mainfrom
blaipr:feature/react-router-team

Conversation

@blaipr

@blaipr blaipr commented Jun 14, 2026

Copy link
Copy Markdown
Contributor
SUMMARY

Continues the react-router v5 → v6 route-tree migration. Converts the Team screen's route trees from the v5 <Switch>/<Route>/<Redirect> API to v6 <Routes>/<Route> via react-router-dom-v5-compat, following the pattern used for the Application, CredentialType and NotificationTemplate route trees.

UI (no behavior change — same URLs, same panels):

  • Teams.js (list router): <Switch><Routes>; child routes use the element prop; the detail route is /teams/:id/* so the nested <Team> tree can match the rest of the path.
  • Team.js (detail router): <Switch><Routes> with relative child paths (details, edit, access, roles); the exact <Redirect> becomes an index route that <Navigate replace>s to details; the catch-all not-found route stays as path="*".
  • Tests: both suites rewritten with renderWithContexts (RTL) to assert real v6 route resolution — which panel renders per URL, the index redirect, the unknown-sub-route not-found error, and the 404 detail error.
ISSUE TYPE
  • Bug, Docs Fix or other nominal change
COMPONENT NAME
  • UI
ADDITIONAL INFORMATION
  • Part of the incremental react-router v6 migration; each screen's route tree is independent and converted on its own branch off main.
  • Tests: 10 route-resolution tests across the two converted suites; full screens/Team directory passes (10 suites / 45 tests).
  • npm --prefix awx/ui run lint clean on the changed source.

blaipr added 2 commits June 14, 2026 05:20
Migrate the Team list and detail route trees 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
Application, CredentialType and NotificationTemplate route trees.

- Teams.js: <Switch> -> <Routes>; child routes use the element prop;
  the detail route uses /teams/:id/* so the nested <Team> tree matches
  the rest of the path.
- Team.js: <Switch> -> <Routes> with relative child paths (details,
  edit, access, roles); the exact <Redirect> becomes an index route
  that <Navigate>s to details; the catch-all not-found route is kept as
  path="*".
- Rewrite both test suites with renderWithContexts (RTL) to assert real
  v6 route resolution, including the index redirect, the unknown
  sub-route not-found error, and the 404 detail error.
Under the v6 route tree, v5 router hooks in descendants no longer see the
route match: TeamList's useRouteMatch() returned match.url='/' (links to
//add, //:id) and TeamDetail's v5 useParams() returned {} (undefined id).
Build TeamList links from the literal /teams base, and read TeamDetail's
useParams from react-router-dom-v5-compat.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Continues the incremental react-router v5 → v6 migration for the Team screen by converting both the list and detail route trees to v6-style <Routes>/<Route> (via react-router-dom-v5-compat), and updating tests to assert real v6 route resolution.

Changes:

  • Converted Teams.js routing from <Switch> to <Routes>, including handing off /teams/:id/* to the nested Team route tree.
  • Converted Team.js nested routing to v6 relative child paths with an index redirect (<Navigate replace>details) and a * not-found route.
  • Rewrote Teams.test.js and Team.test.js using RTL renderWithContexts to validate route matching, redirect behavior, and not-found cases.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
awx/ui/src/screens/Team/Teams.js Migrates Teams route tree to v6 <Routes> and hands off to nested Team subtree via /teams/:id/*.
awx/ui/src/screens/Team/Team.js Migrates nested Team routes to v6 relative paths + index redirect and not-found handling.
awx/ui/src/screens/Team/TeamList/TeamList.js Removes useRouteMatch usage and updates links to explicit /teams/... URLs.
awx/ui/src/screens/Team/TeamDetail/TeamDetail.js Adjusts router hook imports to align with v5-compat usage.
awx/ui/src/screens/Team/Teams.test.js Rewrites tests to RTL and asserts v6 route resolution for Teams routes.
awx/ui/src/screens/Team/Team.test.js Rewrites tests to RTL and asserts v6 nested route resolution, redirects, and not-found behavior.

Comment thread awx/ui/src/screens/Team/Teams.js Outdated
@blaipr

blaipr commented Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Fixed the doubled /* /* in the nested-route comment in 6d47dd9a46.

@cigamit

cigamit commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

When adding a role to a Team
Error: Failed to associate role
django.request Not Found: /api/v2/teams/undefined/roles/

@cigamit cigamit added the Needs triage When a Issue needs to be researched or a PR has an issue that needs fixing before merging label Jun 15, 2026
UserAndTeamAccessAdd read the resource id from react-router v5 useParams.
On the v6-converted Team screen, TeamRolesList renders as a descendant of a
v6 route tree, so the v5 useParams returns no :id and the associate request
went to /api/v2/teams/undefined/roles/. Pass the resource id explicitly from
both consumers (team.id, user.id) so it no longer depends on the parent
screen's router version; keep the v5 route param as a fallback.

@cigamit cigamit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Role association appears to be working now

@cigamit
cigamit merged commit 12cc5ec into ctrliq:main Jun 15, 2026
@cigamit cigamit removed the Needs triage When a Issue needs to be researched or a PR has an issue that needs fixing before merging label Jun 15, 2026
@cigamit cigamit self-assigned this Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants