Skip to content

Convert Job route tree to react-router v6 Routes - #417

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

Convert Job route tree to react-router v6 Routes#417
cigamit merged 2 commits into
ctrliq:mainfrom
blaipr:feature/react-router-job

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 Job screen's route trees - including the job-type disambiguation redirects - from the v5 <Switch>/<Route>/<Redirect> API to v6 <Routes>/<Route> via react-router-dom-v5-compat.

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

  • Jobs.js (list/redirect router): <Switch> -> <Routes> with explicit /jobs paths (the useRouteMatch match.path is gone); the typed detail route is /jobs/:typeSegment/:id/* so the nested <Job> tree matches details/output; the untyped /jobs/:id and /jobs/:id/(details|output) routes still funnel through <JobTypeRedirect>; the legacy /jobs/system/:id redirect becomes a dedicated /jobs/system/:id/* route that <Navigate>s to /jobs/management/:id, preserving any sub-path.
  • JobTypeRedirect.js: the standalone <Redirect from={path} to> becomes <Navigate to replace>, which drops the path / useRouteMatch dependency entirely.
  • Job.js (detail router): <Switch> -> <Routes> with relative child paths (details, output); the exact index <Redirect> becomes an index route that <Navigate>s to output; isWorkflow is derived from typeSegment instead of match.url; tab links are built from the typeSegment/id route params.
  • Tests: Jobs.test.js rewritten with renderWithContexts (RTL) to assert real v6 route resolution (list, typed detail subtree, untyped type redirects, and the system->management redirect); Job.test.js useParams mock pointed at react-router-dom-v5-compat.
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.
  • v6 route ranking keeps the static /jobs/:id/details, /jobs/:id/output and /jobs/system/... routes ahead of the all-dynamic /jobs/:typeSegment/:id/* splat, preserving the original v5 <Switch> order.
  • Tests: full screens/Job directory passes (19 suites / 157 tests). npm --prefix awx/ui run lint clean on the changed source.

Migrate the Job list and detail route trees, including the job-type
disambiguation redirects, from the react-router v5
<Switch>/<Route>/<Redirect> API to v6 <Routes>/<Route> via
react-router-dom-v5-compat.

- Jobs.js: <Switch> -> <Routes> with explicit /jobs paths (the
  useRouteMatch match.path is gone); the typed detail route uses
  /jobs/:typeSegment/:id/* so the nested <Job> tree matches
  details/output; the untyped /jobs/:id and /jobs/:id/(details|output)
  routes still funnel through <JobTypeRedirect>; the legacy
  /jobs/system/:id redirect becomes a dedicated /jobs/system/:id/* route
  that <Navigate>s to /jobs/management/:id, preserving any sub-path.
- JobTypeRedirect.js: the standalone <Redirect from={path} to> becomes
  <Navigate to replace>, dropping the path/useRouteMatch dependency.
- Job.js: <Switch> -> <Routes> with relative child paths (details,
  output); the exact index <Redirect> becomes an index route that
  <Navigate>s to output; isWorkflow is derived from typeSegment instead
  of match.url; tab links built from the typeSegment/id route params.
- Tests: Jobs.test.js rewritten with renderWithContexts (RTL) to assert
  real v6 route resolution (list, typed detail subtree, untyped type
  redirects, and the system->management redirect); Job.test.js useParams
  mock pointed at 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

Migrates the Job screen’s routing from react-router v5 (Switch/Redirect) to react-router v6-style route resolution (Routes/Route/Navigate) via react-router-dom-v5-compat, keeping existing URLs and redirect behavior while updating tests to assert v6 route matching.

Changes:

  • Converted Jobs and Job route trees to v6 <Routes> with Navigate-based redirects (including legacy /jobs/system/:id/* handling).
  • Simplified JobTypeRedirect by removing v5 from/useRouteMatch usage and using Navigate replace.
  • Rewrote Jobs.test.js to use RTL + memory history for real v6 route resolution; updated Job.test.js to mock useParams from the compat module.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
awx/ui/src/screens/Job/JobTypeRedirect.js Replaces v5 Redirect with compat Navigate and removes path dependency.
awx/ui/src/screens/Job/Jobs.js Converts the Jobs route tree to v6 Routes, adds legacy system→management redirect with splat preservation.
awx/ui/src/screens/Job/Job.js Converts Job detail subroutes to v6 Routes with index redirect to output and param-based tab URLs.
awx/ui/src/screens/Job/Jobs.test.js Moves from Enzyme to RTL and asserts route-branch selection/redirect outcomes.
awx/ui/src/screens/Job/Job.test.js Updates router mocking to align with react-router-dom-v5-compat imports.

Comment thread awx/ui/src/screens/Job/Jobs.test.js
Comment thread awx/ui/src/screens/Job/Jobs.test.js
Comment thread awx/ui/src/screens/Job/Jobs.test.js Outdated
- Make the JobTypeRedirect mock mirror the real view='output' default, and
  assert the untyped /jobs/:id route resolves to 'output' instead of a loose
  regex that also matched undefined.
- Add a test that the legacy /jobs/system/:id/* redirect preserves the
  trailing sub-path (/jobs/system/5/output -> /jobs/management/5/output).
@blaipr

blaipr commented Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Addressed in 62f6dcd7a2: the JobTypeRedirect mock now mirrors the real view=output default and the untyped /jobs/:id test asserts output instead of a loose regex; and added a test that the legacy /jobs/system/:id/* redirect preserves the trailing sub-path (.../system/5/output to .../management/5/output).

@cigamit
cigamit merged commit 5aa0e33 into ctrliq:main 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