feat(rbac): implement dynamic permission gates, role matrix ui, and centralize constants
Overview
Integrated Dynamic RBAC on the client side, replacing hardcoded role logic with granular permission evaluation, protecting client routes with Claymorphism fallback screens, and providing a dedicated Roles & Permissions Management interface.
Key Changes
-
Dynamic Permission Hook (
usePermission):- Removed hardcoded
ADMINrole bypass; permissions are evaluated 100% dynamically fromuser.permissions. - Added support for
PermissionNametype-safety.
- Removed hardcoded
-
Route & UI Protection:
- Created
<AccessDenied />: 403 Forbidden claymorphism fallback page with navigation back to Home. - Wrapped all private feature routes in
src/components/layout.tsxwith<PermissionGate permission={PERMISSIONS.*} fallback={<AccessDenied />}>. - Fixed
<DocumentTitle />position inside<ZMPRouter>for valid router context and updated route title mappings.
- Created
-
Role & Permission Management UI (
/roles,/admin/roles):- Claymorphism-styled Roles tab, Permission Matrix grouped by resource/action with centered checkmarks, and Audit Logs tab.
- Automatic session & permission refresh on permission matrix update without requiring re-login.
-
Centralized Constants (
src/common/constants/):- Synchronized
PERMISSIONSandSYSTEM_ROLESconstants. - Refactored
layout.tsx,HomePage,ProfilePage,RolesPage, andusePermissionto usePERMISSIONS.*.
- Synchronized