Skip to content

🐛 Fixed broken admin views for Contributor and Author staff users - #29653

Merged
9larsons merged 3 commits into
mainfrom
slars/ghost-settings-access-routing-d99e46
Jul 28, 2026
Merged

9larsons merged 3 commits into
mainfrom
slars/ghost-settings-access-routing-d99e46

Conversation

@9larsons

Copy link
Copy Markdown
Contributor

Deep-linking to a route your role can't use left Contributors and Authors on a route that rendered nothing. For settings/* that was worse than a blank page: the settings surface portals a position: absolute; inset: 0; z-index: 20 div into document.body for the whole lifetime of the route match, while its contents are conditional on role. Route matched, nothing rendered — a transparent full-viewport layer sat over an admin shell that looked completely normal and swallowed every click.

ref #26607

Route access layer

Routes now declare the access their role needs, and a single guard enforces it:

{
    path: "/tags",
    handle: { requiresAccess: canManageTags } satisfies AccessRouteHandle,
    lazy: lazyComponent(() => import("./tags/tags")),
}

RouteAccessGuard collects handle.requiresAccess from every match and redirects when any rule fails. A route with no rule is unguarded, so the current user is only awaited where a rule exists. Rules mirror the sidebar's existing visibility gating exactly — tags, comments, members, automations, settings — so nothing that was reachable from the nav becomes unreachable.

The redirect is a cross-app navigation. The home route is Ember-owned and picks the landing view per role (admin → analytics, contributor → posts, else site); a plain React Navigate to="/" never reaches Ember's router, so the user parks on / instead of landing where a hard nav would take them.

Settings can't be a plain role check: Authors and Contributors legitimately live at settings/staff/:slug, which is where /my-profile sends them. The rule allows settings access, or that user's own profile path and its tabs; everything else redirects.

This replaces the one-off guard that only covered the members route.

Profile page layout

Roles without settings access open their profile full-bleed rather than as a modal, but only the form was width-constrained — the header spread edge to edge and Close/Save sat in the far corner of the viewport. Header, form and footer now share one column, and the cover-image band no longer reserves 30vmin of empty space above the avatar when there's no cover image.

SettingsModal gained an optional footerClassName for the width cap. It's unset for every other caller, so the modal layout is untouched.

Not included

/analytics and /posts/analytics/:postId are left ungated. Gating analytics on hasAdminAccess would match the sidebar, but it would also redirect Editors arriving by an existing link, and there's no predicate for post-level analytics — Authors arguably should see their own. That's a product call worth making separately.

Testing

  • New acceptance specs cover the deep-link cases: Contributor at /settings/design, Author at another user's profile, Contributor at /tags, Editor at /members all hand off to home; a Contributor stays on their own profile; an authorized user stays put.
  • Unit tests cover rule combination, the loading and load-failure branches, and the own-profile path matrix.
  • Manually verified as Contributor, Author and Editor.
  • Full local run: lint clean across admin, admin-x-settings and shade; tsc -b clean; 1077 unit tests, 381 admin acceptance tests, 235 shade tests pass.

9larsons added 2 commits July 28, 2026 12:49
ref #26607

- a deep link to a route the role can't use (settings, tags, members, comments,
  automations) left staff users on a route that rendered nothing; for settings
  that meant a transparent full-screen overlay swallowing every click on the
  admin shell behind it
- added a route-level access guard: routes declare the access their role needs
  via handle.requiresAccess, denied users are sent to their default view
- the redirect is a cross-app navigation so Ember's home route resolves the
  role-specific landing page instead of parking on /
- Authors and Contributors still reach their own profile at settings/staff/:slug,
  which is where /my-profile sends them
- replaces the one-off guard that only covered the members route
no ref

- Authors and Contributors open their own profile as a full-bleed page rather
  than a modal, but only the form was width-constrained, so the header spread
  edge to edge and the Close/Save buttons sat in the far corner of the viewport
- header, form and footer now share one column
- the cover-image band no longer reserves 30vmin of empty space above the
  avatar when the user has no cover image
- SettingsModal takes an optional footerClassName for the width cap; it is
  unset for every other caller, so the modal layout is unchanged
@nx-cloud

nx-cloud Bot commented Jul 28, 2026 •

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit 50c4ad6

Command Status Duration Result
nx run @tryghost/admin:test:acceptance ✅ Succeeded 6m 44s View ↗
nx run-many -t test:unit -p @tryghost/admin-x-s... ✅ Succeeded 2m 23s View ↗
nx run ghost-monorepo:lint:boundaries ✅ Succeeded 21s View ↗
nx run @tryghost/admin:build ✅ Succeeded 18s View ↗
nx run-many -t lint -p @tryghost/admin-x-settin... ✅ Succeeded 1m 5s View ↗
nx run @tryghost/activitypub:test:acceptance ✅ Succeeded 42s View ↗
nx run-many --target=build --projects=tag:publi... ✅ Succeeded <1s View ↗
nx run ghost-admin:test ✅ Succeeded 2s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-07-28 19:04:12 UTC

@coderabbitai

coderabbitai Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: db5742d0-456b-456c-9779-aae1cd2dfc26

📥 Commits

Reviewing files that changed from the base of the PR and between 1f414b3 and 50c4ad6.

📒 Files selected for processing (3)
  • apps/admin-x-settings/src/components/providers/routing/staff-profile-paths.tsx
  • apps/admin-x-settings/src/components/providers/settings-router.tsx
  • apps/admin/src/settings/settings-access.ts

Walkthrough

Admin routing now applies RouteAccessGuard with route-specific access predicates for settings, members, tags, comments, and automations. Settings access supports broad settings roles and users’ own staff profiles, with unit and acceptance coverage. Staff-profile modal paths are generated from supported tabs. The standalone user detail modal now uses dedicated presentation parameters and classes, supported by customizable footer styling.

Possibly related PRs

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main change by describing the broken Contributor/Author admin views that this PR fixes.
Description check ✅ Passed The description accurately explains the deep-linking bug and the route-access and layout fixes in this change set.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch slars/ghost-settings-access-routing-d99e46

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.44%. Comparing base (76b97ad) to head (1f414b3).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #29653      +/-   ##
==========================================
- Coverage   75.44%   75.44%   -0.01%     
==========================================
  Files        1606     1606              
  Lines      141107   141103       -4     
  Branches    17455    17454       -1     
==========================================
- Hits       106465   106461       -4     
  Misses      33598    33598              
  Partials     1044     1044              
Flag Coverage Δ
admin-tests 55.66% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

no ref

- the access rule for settings/* whitelisted the profile tab paths, duplicating
  the modal path table the settings router owns; adding a tab there would have
  rendered it for admins and redirected everyone else
- both now derive from one list, so a new tab is a single edit
- the list lives in a leaf module with no imports, keeping it out of the lazy
  settings chunk the admin shell loads it ahead of
@9larsons
9larsons enabled auto-merge (squash) July 28, 2026 19:08
@9larsons
9larsons merged commit 3d2b48a into main Jul 28, 2026
45 checks passed
@9larsons
9larsons deleted the slars/ghost-settings-access-routing-d99e46 branch July 28, 2026 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants