feat(dashboard): unified role-based dashboard shell, guard, and quick actions (closes #42)#57
Merged
Obiajulu-gif merged 4 commits intoJun 21, 2026
Conversation
…ion primitives Introduce a single source of truth for dashboard roles (lib/dashboard/roles) that drives navigation, badges, quick actions, and authorization, plus: - DashboardGuard: client route guard with graceful loading and unauthorized states, layered on top of the existing edge authentication in proxy.ts - DashboardUnauthorized: shared, recoverable access-denied view - DashboardQuickActions: per-role quick action slots for dashboard headers - requireDashboardSession: server-side role guard for server components These let contributors add dashboard modules for a role without duplicating layout or authorization logic.
Replace per-role inline auth/loading/unauthorized logic with the shared primitives so all roles behave consistently: - admin layout now wraps content in DashboardGuard - driver page uses the server-side requireDashboardSession guard - investor page renders the shared DashboardUnauthorized state - shared Header surfaces per-role quick action slots No change to existing routes or redirect behavior.
Verify role config helpers and that the guard renders loading, redirects unauthenticated users, blocks the wrong role, and admits authorized roles.
Collaborator
|
@pope-h lint is failing fix it |
Contributor
Author
Please check now. Lint fail sorted |
Collaborator
|
@pope-h great work |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #42.
Builds a unified, reusable role-based dashboard shell so contributors can add new dashboard modules without duplicating layout or authorization logic. ChainMove already had a role-aware
Sidebar,Header, andDashboardShell, but route guarding, loading/unauthorized states, and quick actions were re-implemented inline in each role's layout/page with no shared role config. This PR consolidates that into one system.New reusable primitives
lib/dashboard/roles.ts— single source of truth for dashboard roles: labels, home paths, and per-role quick action slots. ExposesisDashboardRole,getDashboardRoleConfig,resolveAllowedRoles, andgetDashboardHomePath.DashboardGuard(components/dashboard/dashboard-guard.tsx) — client route guard for role-protected sections. Renders a graceful loading state, redirects unauthenticated visitors to sign in, and shows a recoverable unauthorized view for the wrong role. Layers on top of the existing edge authentication inproxy.ts(which handles authentication for/dashboard/*).DashboardUnauthorized— shared, recoverable access-denied view (offers a link back to the user's own dashboard).DashboardQuickActions— renders per-role quick action slots in dashboard headers.requireDashboardSession(lib/auth/dashboard-guard.ts) — server-side counterpart for server components/route handlers.Wired existing sections to the unified system (no behavior/route changes)
DashboardGuard(replaces bespoke inline guard).requireDashboardSession("driver").DashboardUnauthorizedstate.Headersurfaces per-role quick action slots.Acceptance criteria
DashboardGuard+ serverrequireDashboardSession, plus existing edgeproxy.ts)npm run lintandnpm run buildpassArea changed
Contributor safety checklist
.env.localor real secrets.Testing
components/dashboard/__tests__/dashboard-guard.test.tsxcovering the role config helpers and guard states (loading, redirect, wrong-role, authorized).npx tsc --noEmitintroduces no new errors from these changes (pre-existing repo type errors are unrelated and the build setstypescript.ignoreBuildErrors).Notes for maintainers
proxy.ts: edge middleware enforces authentication for/dashboard/*, whileDashboardGuard/requireDashboardSessionenforce role authorization and provide the graceful UI states.lib/dashboard/roles.tspoint at existing routes; adjust there to add/replace per-role actions in one place.