Repository navigation
Moved settings onto the admin router - #29780
Conversation
- settings was the last consumer of the deprecated admin-x-framework RoutingProvider: a second hash-string router layered onto the URL react-router already owns, showing modals through NiceModal against a 37-path table - the settings route table now lives in the shell's data router as a settingsRouteChildren fragment with route-level lazy per dialog; the shell element renders the settings providers and chrome, dialogs mount through its Outlet - routed dialogs are the same screen components with the NiceModal wrapper stripped: params come from the router, closing navigates back to the owning section through the SettingsModal onClose seam; imperative confirmations (ConfirmationModal, LimitModal, editor prompts) stay on NiceModal for now - useSettingsNavigation now normalizes every legacy link shape to absolute /settings paths over useNavigate; same-path re-navigation re-scrolls without pushing a history entry, matching the old provider's contract - useQueryParams reads useSearchParams instead of listening for hashchange events, which router pushes never fire - deleted the framework RoutingProvider, its ./routing export, and the settings modal registry; ExternalLink/InternalLink moved to framework-provider - accepted behavior deltas: the browser back button now closes an open dialog (previously it survived popstate), the locksite redirect replaces instead of pushing, and two design/theme limit denials now navigate to the theme section instead of stranding the URL - new coverage: three history-semantics acceptance specs and SettingsModal onClose branch tests
WalkthroughThe PR replaces the legacy settings routing provider with nested framework routes. Settings navigation now uses router hooks, URL search parameters, typed internal and external links, and route-based modal rendering. Settings modals no longer rely on NiceModal wrappers or routing props for lifecycle control. Modal closure uses Possibly related PRs
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx run-many -t test:unit -p @tryghost/admin-x-f... |
✅ Succeeded | 3m 24s | View ↗ |
nx run @tryghost/admin:test:acceptance |
✅ Succeeded | 6m 11s | View ↗ |
nx run @tryghost/admin:build |
✅ Succeeded | 2m 5s | View ↗ |
nx run @tryghost/activitypub:test:acceptance |
✅ Succeeded | 48s | View ↗ |
nx run ghost-monorepo:lint:boundaries |
✅ Succeeded | 23s | View ↗ |
nx run ghost-admin:test |
✅ Succeeded | 2m 59s | View ↗ |
nx run-many --target=build --projects=tag:publi... |
✅ Succeeded | <1s | View ↗ |
nx run-many -t lint -p @tryghost/admin-x-framew... |
✅ Succeeded | 2m 9s | View ↗ |
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗
☁️ Nx Cloud last updated this comment at 2026-08-05 15:39:37 UTC
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #29780 +/- ##
=======================================
Coverage 75.59% 75.59%
=======================================
Files 1613 1613
Lines 142639 142639
Branches 17644 17644
=======================================
Hits 107823 107823
Misses 33738 33738
Partials 1078 1078
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ref #29780 Preserved legacy navigation data and made the new history coverage deterministic.
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
apps/shade/test/unit/components/patterns/settings-modal.test.tsx (1)
75-92: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse the shared
renderhelper for the NiceModal wrapper.This test requires
NiceModal.Provider. Use the shared testrenderhelper instead of mounting the provider with the direct Testing Libraryrenderimport.As per coding guidelines, use the shared
renderhelper when a wrapper is needed.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/shade/test/unit/components/patterns/settings-modal.test.tsx` around lines 75 - 92, Update the NiceModal test around the BridgeModal case to use the shared test render helper with NiceModal.Provider as its wrapper, replacing the direct Testing Library render call while preserving the existing modal-close assertions.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@apps/admin/src/settings/app/components/settings/membership/tiers/tier-detail-modal.tsx`:
- Around line 414-427: Move the tier lookup from the conditional block to before
the useEffect in TierDetailModal, so the effect evaluates the current tiers on
every render. Update the effect dependencies to include tiers, and continue
calling fetchNextPage while tierId is set, tier is missing, and isEnd is false.
In `@apps/admin/src/settings/app/hooks/use-query-params.ts`:
- Around line 1-7: Update DesignAndThemeModal to use the router search-parameter
API for reading and clearing the ref query parameter instead of parsing
window.location.href or window.location.hash. Replace the existing theme-install
query handling while preserving the current ref-driven behavior and ensuring
router URLs with ?ref=... are cleared after use.
---
Nitpick comments:
In `@apps/shade/test/unit/components/patterns/settings-modal.test.tsx`:
- Around line 75-92: Update the NiceModal test around the BridgeModal case to
use the shared test render helper with NiceModal.Provider as its wrapper,
replacing the direct Testing Library render call while preserving the existing
modal-close assertions.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 3b3520a9-706a-4f31-9892-2e6e5b70407b
📒 Files selected for processing (54)
apps/admin-x-framework/package.jsonapps/admin-x-framework/src/api/actions.tsapps/admin-x-framework/src/providers/framework-provider.tsxapps/admin-x-framework/src/providers/routing-provider.tsxapps/admin-x-framework/src/routing.tsapps/admin/src/routes.tsxapps/admin/src/settings/advanced/advanced.acceptance.test.tsxapps/admin/src/settings/app/app.tsxapps/admin/src/settings/app/components/exit-settings-button.tsxapps/admin/src/settings/app/components/providers/routing/modals.tsxapps/admin/src/settings/app/components/providers/settings-router.tsxapps/admin/src/settings/app/components/settings/advanced/history-modal.tsxapps/admin/src/settings/app/components/settings/advanced/integrations/add-integration-modal.tsxapps/admin/src/settings/app/components/settings/advanced/integrations/content-api-modal.tsxapps/admin/src/settings/app/components/settings/advanced/integrations/custom-integration-modal.tsxapps/admin/src/settings/app/components/settings/advanced/integrations/first-promoter-modal.tsxapps/admin/src/settings/app/components/settings/advanced/integrations/pintura-modal.tsxapps/admin/src/settings/app/components/settings/advanced/integrations/slack-modal.tsxapps/admin/src/settings/app/components/settings/advanced/integrations/transistor-modal.tsxapps/admin/src/settings/app/components/settings/advanced/integrations/unsplash-modal.tsxapps/admin/src/settings/app/components/settings/advanced/integrations/zapier-modal.tsxapps/admin/src/settings/app/components/settings/email/newsletters/add-newsletter-modal.tsxapps/admin/src/settings/app/components/settings/email/newsletters/newsletter-detail-modal.tsxapps/admin/src/settings/app/components/settings/general/about.tsxapps/admin/src/settings/app/components/settings/general/invite-user-modal.tsxapps/admin/src/settings/app/components/settings/general/user-detail-modal.tsxapps/admin/src/settings/app/components/settings/growth/embed-signup/embed-signup-form-modal.tsxapps/admin/src/settings/app/components/settings/growth/explore/testimonials-modal.tsxapps/admin/src/settings/app/components/settings/growth/offers/add-offer-modal.tsxapps/admin/src/settings/app/components/settings/growth/offers/edit-offer-modal.tsxapps/admin/src/settings/app/components/settings/growth/offers/edit-retention-offer-modal.tsxapps/admin/src/settings/app/components/settings/growth/offers/offer-success.tsxapps/admin/src/settings/app/components/settings/growth/offers/offers-container-modal.tsxapps/admin/src/settings/app/components/settings/growth/offers/offers-index.tsxapps/admin/src/settings/app/components/settings/growth/recommendations/add-recommendation-modal-confirm.tsxapps/admin/src/settings/app/components/settings/growth/recommendations/add-recommendation-modal.tsxapps/admin/src/settings/app/components/settings/growth/recommendations/edit-recommendation-modal.tsxapps/admin/src/settings/app/components/settings/growth/recommendations/recommendation-list.tsxapps/admin/src/settings/app/components/settings/membership/portal/portal-modal.tsxapps/admin/src/settings/app/components/settings/membership/stripe/stripe-connect-modal.tsxapps/admin/src/settings/app/components/settings/membership/tiers/tier-detail-modal.tsxapps/admin/src/settings/app/components/settings/site/announcement-bar-modal.tsxapps/admin/src/settings/app/components/settings/site/design-and-theme-modal.tsxapps/admin/src/settings/app/components/settings/site/design-modal.tsxapps/admin/src/settings/app/components/settings/site/navigation-modal.tsxapps/admin/src/settings/app/components/settings/site/theme-modal.tsxapps/admin/src/settings/app/components/settings/site/theme/theme-code-editor-modal.tsxapps/admin/src/settings/app/hooks/use-query-params.tsapps/admin/src/settings/app/hooks/use-settings-navigation.tsapps/admin/src/settings/app/main-content.tsxapps/admin/src/settings/growth/recommendations.acceptance.test.tsxapps/admin/src/settings/navigation-history.acceptance.test.tsxapps/admin/src/settings/routes.tsxapps/shade/test/unit/components/patterns/settings-modal.test.tsx
💤 Files with no reviewable changes (5)
- apps/admin-x-framework/src/routing.ts
- apps/admin/src/settings/app/components/providers/settings-router.tsx
- apps/admin-x-framework/src/providers/routing-provider.tsx
- apps/admin/src/settings/app/components/providers/routing/modals.tsx
- apps/admin-x-framework/package.json
| const TierDetailModal: React.FC = () => { | ||
| const {tierId} = useParams(); | ||
| const {data: {tiers, isEnd} = {}, fetchNextPage} = useBrowseTiers(); | ||
|
|
||
| let tier: Tier | undefined; | ||
|
|
||
| useEffect(() => { | ||
| if (params?.id && !tier && !isEnd) { | ||
| if (tierId && !tier && !isEnd) { | ||
| fetchNextPage(); | ||
| } | ||
| }, [fetchNextPage, isEnd, params?.id, tier]); | ||
| }, [fetchNextPage, isEnd, tierId, tier]); | ||
|
|
||
| if (params?.id) { | ||
| tier = tiers?.find(({id}) => id === params?.id); | ||
| if (tierId) { | ||
| tier = tiers?.find(({id}) => id === tierId); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Continue pagination until the route tier is found.
Line 420 evaluates tier before Lines 426-427 assign it. If a loaded page does not contain tierId, the dependency value remains undefined. Later page data can then leave the effect unchanged, so the component stops fetching and returns null for a tier on a later page.
Derive tier before the effect. Re-run the effect when tiers changes.
Proposed fix
const TierDetailModal: React.FC = () => {
const {tierId} = useParams();
const {data: {tiers, isEnd} = {}, fetchNextPage} = useBrowseTiers();
-
- let tier: Tier | undefined;
+ const tier = tierId ? tiers?.find(({id}) => id === tierId) : undefined;
useEffect(() => {
if (tierId && !tier && !isEnd) {
- fetchNextPage();
+ void fetchNextPage();
}
- }, [fetchNextPage, isEnd, tierId, tier]);
-
- if (tierId) {
- tier = tiers?.find(({id}) => id === tierId);
+ }, [fetchNextPage, isEnd, tier, tierId, tiers]);
+ if (tierId) {
if (!tier) {
return null;
}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@apps/admin/src/settings/app/components/settings/membership/tiers/tier-detail-modal.tsx`
around lines 414 - 427, Move the tier lookup from the conditional block to
before the useEffect in TierDetailModal, so the effect evaluates the current
tiers on every render. Update the effect dependencies to include tiers, and
continue calling fetchNextPage while tierId is set, tier is missing, and isEnd
is false.
| import {useSearchParams} from '@tryghost/admin-x-framework'; | ||
|
|
||
| const useQueryParams = () => { | ||
| const [params, setParams] = useState(new URLSearchParams()); | ||
|
|
||
| useEffect(() => { | ||
| const updateParams = () => { | ||
| const hash = window.location.hash; | ||
| const queryString = hash.split('?')[1]; | ||
|
|
||
| if (queryString) { | ||
| setParams(new URLSearchParams(queryString)); | ||
| } else { | ||
| setParams(new URLSearchParams()); | ||
| } | ||
| }; | ||
|
|
||
| // Initialize | ||
| updateParams(); | ||
|
|
||
| // Listen for hash changes | ||
| window.addEventListener('hashchange', updateParams); | ||
|
|
||
| // Cleanup | ||
| return () => { | ||
| window.removeEventListener('hashchange', updateParams); | ||
| }; | ||
| }, []); | ||
| const [searchParams] = useSearchParams(); | ||
|
|
||
| const getParam = (key: string) => { | ||
| return params.get(key); | ||
| return searchParams.get(key); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Migrate the remaining theme-install query handling.
This hook now reads location.search. DesignAndThemeModal still gets ref from window.location.href.split('#') and clears parameters with window.location.hash.split('?'). Router URLs with ?ref=... will return no ref and will not clear the query parameter.
Update that modal to read and clear router search parameters. The affected code is in apps/admin/src/settings/app/components/settings/site/design-and-theme-modal.tsx.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@apps/admin/src/settings/app/hooks/use-query-params.ts` around lines 1 - 7,
Update DesignAndThemeModal to use the router search-parameter API for reading
and clearing the ref query parameter instead of parsing window.location.href or
window.location.hash. Replace the existing theme-install query handling while
preserving the current ref-driven behavior and ensuring router URLs with
?ref=... are cleared after use.
no ref First slice of the settings NiceModal burn-down (follows the router swap #29780 and un-portal #29789). `ConfirmationModal` and `LimitModal` were NiceModal-shown from **54 call sites across 27 files** — the bulk of settings' remaining NiceModal usage. They now go through a settings-local `ConfirmationProvider`:

Settings was the last consumer of the deprecated
admin-x-frameworkRoutingProvider— a second hash-string router layered onto the URL react-router already owns, showing modals through NiceModal against a 37-path string table, with exit implemented as rawwindow.location.hashwrites. This PR makes settings routing native. Follows #29762 (navigation seam) and #29763 (modal-chrome close seam), which shrank this diff to the swap itself.What changed
apps/admin/src/settings/routes.tsxis asettingsRouteChildrenfragment mounted under the shell'ssettingsroute node (same pattern asanalyticsRouteChildren). Every legacy modal path is a data route with route-level lazy — each dialog is its own chunk, loaded when its route matches (replaces the old 1s-preload + loading backdrop; the router defers navigation while a chunk loads).locksiteandtheme/edit/*guards are<Navigate replace>routes;offers/success/:offerIdis promoted to a real route;recommendations/editredirects to the section (see below).app.tsxrenders the settings providers + chrome +Outlet;RoutingProvider,SettingsRouter, the modal registry, and the duplicate NiceModal provider are gone.useParams/useSearchParams, closing navigates back to the owning section through theSettingsModal/PreviewModalContentonCloseseam. Flat sibling routes share one component identity, so switching staff tabs or history filters updates params in place without remounting (the legacy reshow behavior, preserved). Imperative modals stay on NiceModal (ConfirmationModal, LimitModal, editor prompts, code/webhook/yaml dialogs) — their removal is follow-up burn-down.recommendations/add, as before); the edit dialog opens from the list with the loaded record and no route change (as before) — now as a controlled dialog instead of an imperative NiceModal show.useSettingsNavigationnormalizes every legacy link shape to absolute/settings/...overuseNavigate; same-path re-navigation re-scrolls the section without pushing a history entry (the legacy provider's contract, now pinned by a spec);{isExternal}goes throughexternalNavigate;{replace}maps to router replace.useQueryParamsreadsuseSearchParamsinstead of listening forhashchange— router pushes never fire that event (caught by the staff-invitations spec during integration).routing-provider.tsx,routing.ts, and the./routingexport are deleted;ExternalLink/InternalLinkmoved toframework-provider.Accepted behavior deltas
useBlockerfor dirty dialogs).locksiteredirect replaces instead of pushing (no more back-button trap)./settings/themeinstead of closing the modal while leaving the URL stranded.Verification
SettingsModalonClosebranch tests)tsc -b, full lint, dependency-cruiser boundaries cleanManual check matrix (pre-merge)
staff/<slug>/email-notifications(from a staff email),theme/edit/%2Fedition,newsletters/?verifyEmail=<token>,design/edit?ref=setup,theme/install?source=github&ref=TryGhost/Taste,staff?tab=invited/settings/migrationfrom the migrate flow; ⌘K staff result