Skip to content

Convert the Setting screen route trees to react-router v6 Routes - #420

Merged
cigamit merged 5 commits into
ctrliq:mainfrom
blaipr:feature/react-router-setting-auth
Jun 15, 2026
Merged

Convert the Setting screen route trees to react-router v6 Routes#420
cigamit merged 5 commits into
ctrliq:mainfrom
blaipr:feature/react-router-setting-auth

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 entire Setting screen - all 16 route trees - 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):

  • Single-form sub-screens (TACACS, RADIUS, OIDC, SAML, GoogleOAuth2, Jobs, UI, Troubleshooting, MiscSystem, MiscAuthentication, Logging, Subscription): <Switch><Routes>; details/edit use the element prop; the base <Redirect> becomes a <Route path={baseURL}> that <Navigate>s to details; not-found kept as {baseURL}/*. MiscSystem/MiscAuthentication/Logging keep their superuser-gated edit route (the fallback inner <Redirect> becomes <Navigate>); Subscription folds its useRouteMatch base-redirect into a <Route path={baseURL}>.
  • Category-based sub-screens (LDAP, AzureAD, GitHub): the useRouteMatch base/category redirects become a <Route path={baseURL}> Navigate plus a small CategoryRedirect helper (useParams) on the /:category route; detail/edit routes use the element prop.
  • Settings.js dispatcher: <Switch><Routes>; each sub-screen route gets a trailing /* so its own nested <Routes> resolves; the non-superuser <Redirect to="/"> and the open-license subscription <Redirect> become <Navigate>.
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. This PR covers the whole Setting screen.
  • The sub-screens keep their absolute baseURL paths. Under the now-v6 Settings.js dispatcher they nest as /settings/<name>/* → the sub-screen's own <Routes>; v6 permits those absolute child paths because they extend the parent /settings/<name> path.
  • The existing enzyme tests mount sub-screens at absolute /settings/<name>/... URLs, which v6 <Routes> resolve unchanged - so the only test change is Settings.test.js asserting the non-superuser redirect via the history location instead of finding a <Redirect> component.
  • Tests: full screens/Setting directory passes (61 suites / 344 tests). npm --prefix awx/ui run lint clean on the changed source.

blaipr added 3 commits June 14, 2026 16:57
Migrate the single-form authentication Setting sub-screens (TACACS,
RADIUS, OIDC, SAML, GoogleOAuth2) from the react-router v5 <Switch> API
to v6 <Routes> via react-router-dom-v5-compat. These follow an identical
detail/edit toggle pattern under a fixed baseURL.

- <Switch> -> <Routes>; details/edit routes use the element prop.
- The exact base <Redirect> becomes a <Route path={baseURL}> that
  <Navigate>s to {baseURL}/details.
- The catch-all not-found route is kept as {baseURL}/*.
- Routes keep their absolute baseURL paths, so they resolve correctly
  whether or not the Settings.js dispatcher has been migrated yet.

The existing enzyme tests mount each sub-screen at an absolute
/settings/<name>/(details|edit|foo) URL, which v6 <Routes> resolve
unchanged, so no test changes are needed.
Migrate the remaining single-form system Setting sub-screens (Jobs, UI,
Troubleshooting, MiscSystem, MiscAuthentication, Logging, Subscription)
to v6 <Routes>, same pattern as the auth sub-screens.

- <Switch> -> <Routes>; details/edit use the element prop; the base
  <Redirect> becomes a <Route path={baseURL}> that <Navigate>s to
  details; not-found kept as {baseURL}/*.
- MiscSystem/MiscAuthentication/Logging gate their edit route on
  me?.is_superuser; the fallback inner <Redirect> becomes <Navigate>.
- Subscription folded its useRouteMatch base-redirect into a
  <Route path={baseURL}> Navigate, dropping useRouteMatch.
- Routes keep absolute baseURL paths, so they resolve under the still-v5
  Settings.js dispatcher; existing enzyme tests pass unchanged.
Finish the Setting screen migration to react-router v6 <Routes>.

- LDAP, AzureAD, GitHub: category-based screens. Their useRouteMatch
  base/category redirects become a <Route path={baseURL}> Navigate to the
  default category plus a small CategoryRedirect helper (useParams) on
  the /:category route; detail/edit routes use the element prop.
- Settings.js: <Switch> -> <Routes>; each sub-screen route gets a
  trailing /* so its own nested <Routes> resolves; the non-superuser
  <Redirect to="/"> and the open-license subscription <Redirect>
  become <Navigate>. v6 allows the sub-screens' absolute child paths
  because they extend the parent /settings/<name> path.
- Settings.test.js: assert the non-superuser case redirects to / via the
  history location instead of finding a <Redirect> component.
@blaipr blaipr changed the title Convert simple auth Setting route trees to react-router v6 Routes Convert the Setting screen route trees to react-router v6 Routes Jun 14, 2026
@cigamit
cigamit requested a review from Copilot June 14, 2026 19:46

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 UI’s incremental react-router migration by converting the full Settings screen routing from react-router v5 (<Switch>/<Redirect>) to v6-style (<Routes>/<Navigate>) using react-router-dom-v5-compat, while preserving existing URLs and screen structure.

Changes:

  • Migrated Settings dispatcher routing (Settings.js) to v6-style <Routes> and added /* to sub-screen routes to enable nested route matching.
  • Migrated individual Settings sub-screens’ route trees (details/edit/not-found + base redirects) from v5 to v6-style routing.
  • Updated the Settings screen test to assert redirect behavior via history.location rather than presence of a <Redirect> component.

Reviewed changes

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

Show a summary per file
File Description
awx/ui/src/screens/Setting/Settings.js Converts Settings dispatcher to <Routes> and updates redirects to <Navigate>.
awx/ui/src/screens/Setting/Settings.test.js Updates redirect assertion to check history location (v6-style).
awx/ui/src/screens/Setting/UI/UI.js Converts UI settings route tree to <Routes> + <Navigate> base redirect.
awx/ui/src/screens/Setting/Troubleshooting/Troubleshooting.js Converts Troubleshooting route tree to <Routes> + <Navigate>.
awx/ui/src/screens/Setting/TACACS/TACACS.js Converts TACACS route tree to <Routes> + <Navigate>.
awx/ui/src/screens/Setting/Subscription/Subscription.js Converts Subscription route tree to <Routes> + <Navigate> and removes useRouteMatch redirect logic.
awx/ui/src/screens/Setting/SAML/SAML.js Converts SAML route tree to <Routes> + <Navigate>.
awx/ui/src/screens/Setting/RADIUS/RADIUS.js Converts RADIUS route tree to <Routes> + <Navigate>.
awx/ui/src/screens/Setting/OIDC/OIDC.js Converts OIDC route tree to <Routes> + <Navigate>.
awx/ui/src/screens/Setting/MiscSystem/MiscSystem.js Converts MiscSystem route tree and preserves superuser-gated edit navigation via <Navigate>.
awx/ui/src/screens/Setting/MiscAuthentication/MiscAuthentication.js Converts MiscAuthentication route tree and preserves superuser-gated edit navigation via <Navigate>.
awx/ui/src/screens/Setting/Logging/Logging.js Converts Logging route tree and preserves superuser-gated edit navigation via <Navigate>.
awx/ui/src/screens/Setting/LDAP/LDAP.js Converts LDAP category-based routing to <Routes> and introduces CategoryRedirect using useParams.
awx/ui/src/screens/Setting/Jobs/Jobs.js Converts Jobs route tree to <Routes> + <Navigate>.
awx/ui/src/screens/Setting/GoogleOAuth2/GoogleOAuth2.js Converts Google OAuth2 route tree to <Routes> + <Navigate>.
awx/ui/src/screens/Setting/GitHub/GitHub.js Converts GitHub category-based routing to <Routes> and introduces CategoryRedirect using useParams.
awx/ui/src/screens/Setting/AzureAD/AzureAD.js Converts AzureAD category-based routing to <Routes> and introduces CategoryRedirect using useParams.

Comment thread awx/ui/src/screens/Setting/Settings.test.js
The test asserts a redirect via history after a <Navigate>, not a v5
<Redirect> component; rename it so the name matches the assertion.
@blaipr

blaipr commented Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Renamed the redirect test in b3ec2c3fd4: it asserts a redirect via history after a <Navigate>, not a v5 <Redirect> component, so the name now matches the assertion.

@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
@cigamit

cigamit commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

There seems to be an issue with this one. For some reason all settings pages are no longer displaying the actual settings. Verified not a caching issue. It is no longer making the API call to pull the setting for that page. For example, clicking on the Logging Settings no longer creates a query for /api/v2/settings/logging/

image

cigamit reported that the settings pages no longer render or fetch (e.g.
clicking Logging no longer calls /api/v2/settings/logging/). Settings.js was
converted to a v6 dispatcher (path "/settings/<category>/*"), making each
category screen's <Routes> a descendant; the category screens still used
absolute baseURL-prefixed paths, so nothing matched and the category content
(and its fetch) never rendered.

- Convert every category screen (incl. the LDAP/GitHub/Azure/etc. category
  redirects) to relative route paths; bare-baseURL redirects become index
  routes.
- Update the isolated category tests to mount each screen under its v6
  parent route (they mounted top-level, which masked the regression), and
  fix the Troubleshooting test that mounted the screen under a stale 'Jobs'
  alias.

@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.

Settings pages now properly display

@cigamit
cigamit merged commit bf141e2 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