Skip to content

Admin Portal M2: /admin shell, guard, dashboard (Issue #1254) - #1

Closed
Veekshitha11 wants to merge 1 commit into
feature/admin-portal-m1-platform-admin-gatefrom
feature/admin-portal-m2-admin-shell
Closed

Admin Portal M2: /admin shell, guard, dashboard (Issue #1254)#1
Veekshitha11 wants to merge 1 commit into
feature/admin-portal-m1-platform-admin-gatefrom
feature/admin-portal-m2-admin-shell

Conversation

@Veekshitha11

Copy link
Copy Markdown
Owner

Milestone 2 of the Admin Portal plan (features/admin-portal/v1/plan.md) -- the /admin route shell: AdminGuard (with explicit loading state to avoid a flash-of-sidebar race), AdminLayout sidebar, Admin Portal nav link, and the dashboard with real Total Orgs/Total Users counts. Notifications/Feature Flags cards are 'coming soon' placeholders per plan.md; Organizations sidebar link is a temporary placeholder until M3. Stacked on DalgoT4D#342 (M1) -- base branch is feature/admin-portal-m1-platform-admin-gate, not main, until M1 merges. 6/6 Jest passing, Playwright e2e spec included (requires seeded creds, skips otherwise).

…1254, M2)

Admin Portal v1, Milestone 2 (the /admin shell, guarded, empty) — frontend.
/admin renders an admin-only sidebar shell for platform admins; non-admins
never see it and are bounced. Dashboard shows real total-orgs / total-users.

- components/client-layout.tsx: new /admin pathname branch ->
  <AuthGuard><AdminGuard><AdminLayout>{children}</AdminLayout></AdminGuard></AuthGuard>.
  AdminGuard sits inside AuthGuard so children only evaluate once authenticated.
- components/admin/AdminGuard.tsx: client access gate. Reads is_platform_admin
  straight from the /currentuserv2 SWR data (shared cache key, no extra request,
  no store-hydration race). While that data resolves it shows a loading state —
  never a flash of the shell before redirecting a non-admin to '/'.
- components/admin/AdminLayout.tsx: admin sidebar. Home is live; Organizations is
  disabled ONLY until M3 (TODO(M3) in-code); Notifications + Feature Flags are
  deferred features (plan.md "Later").
- components/admin/ComingSoonBadge.tsx: one shared "coming soon" placeholder
  (badge + dim) used by BOTH the sidebar and the dashboard cards, so the two
  surfaces read as one deliberate pattern rather than two half-finished features.
- app/admin/page.tsx: dashboard. Total Orgs + Total Users are real (from
  /api/v1/admin/stats); Notifications Sent + Feature Flags ON are placeholders.
- components/main-layout.tsx: "Admin Portal" nav item gated hide:!isPlatformAdmin
  (via useUserPermissions); getNavItems exported for unit testing.
- hooks/api/useAdminPortal.ts: useAdminStats() SWR hook -> /api/v1/admin/stats.

Tests (Jest + Playwright):
- components/admin/__tests__/AdminGuard.test.tsx: loading -> no redirect/spinner;
  non-admin -> router.replace('/'); admin -> renders shell. (3)
- components/__tests__/getNavItems.test.ts: Admin Portal link hidden when not a
  platform admin, shown when one, hidden by default. (3)
- e2e/admin-portal.spec.ts: non-admin bounced from /admin (Playwright; skips
  without E2E_NONADMIN creds + a running server, per login.spec.ts convention).
- Jest: 6 passed. tsc: no new errors. prettier: clean.

Stacked on feature/admin-portal-m1-platform-admin-gate (needs M1's is_platform_admin).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant