Component:Documentation Index
Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
Use this file to discover all available pages before exploring further.
src/platform/data-manager/components/ObjectPermissionsTab.tsxStatus: ✅ Migration Complete
Sunset Date: 2026-03-31 (for V1 constants removal)
Created: 2026-01-26
Completed: 2026-01-26
Related Specs: PF-26 (Object Permissions), PF-30 (Permissions System V2)
Overview
TheObjectPermissionsTab component currently uses V1 role patterns (hardcoded ORDERED_ROLES and ROLE_CONFIG). This migration updates it to use V2 permissions system with dynamic role fetching.
Current State (V1)
Issues:- Uses hardcoded
ORDERED_ROLESarray (only 5 core roles) - Uses hardcoded
ROLE_CONFIGobject - Doesn’t include all system roles (18 total, only shows 5)
- Doesn’t support custom roles
- Role list is static and doesn’t reflect database state
src/platform/data-manager/components/ObjectPermissionsTab.tsx- Main componentsrc/platform/data-manager/components/ObjectPermissionMatrix.tsx- Matrix displaysrc/platform/data-manager/types/permissions.ts- Type definitions with V1 constants
Target State (V2)
Goals:- Fetch all system roles dynamically (all 18 roles from
app_roleenum) - Support custom roles (when PF-26 is updated to support them)
- Use V2 permission system hooks
- Remove hardcoded role constants
- Make role list dynamic and database-driven
- Use
useAvailableRoles()hook to fetch roles - Update
ObjectPermissionsTabto use dynamic roles - Update
ObjectPermissionMatrixto work with dynamic roles - Keep PF-26 tables (
pf_object_permissions,pf_field_permissions) - these are V2 compatible
Migration Steps
Step 1: Create Role Fetching Hook ✅
File:src/platform/data-manager/hooks/useAvailableRoles.ts
Purpose: Fetch all available roles (system + custom) for object permissions configuration.
Status: ✅ Complete
Step 2: Update ObjectPermissionsTab ✅
Changes:- Replace
ORDERED_ROLESimport withuseAvailableRoles()hook - Update role initialization to use dynamic roles
- Remove dependency on hardcoded
ROLE_CONFIG - Use role labels from hook
src/platform/data-manager/components/ObjectPermissionsTab.tsx✅
Step 3: Update ObjectPermissionMatrix ✅
Changes:- Remove
ROLE_CONFIGimport - Use dynamic role labels from props (via
PermissionMatrixRow.roleLabel) - Remove sorting logic (parent component handles ordering)
src/platform/data-manager/components/ObjectPermissionMatrix.tsx✅
Step 4: Update FieldPermissionsSection ✅
Changes:- Replace
ORDERED_ROLESandROLE_CONFIGwithuseAvailableRoles()hook - Use
getRoleLabel()helper for display names - Filter roles dynamically (exclude platform_admin and org_admin)
src/platform/data-manager/components/FieldPermissionsSection.tsx✅
Step 5: Update Type Definitions ✅
Changes:- Mark
ORDERED_ROLESandROLE_CONFIGas deprecated - Add migration notes
- Keep types for backward compatibility during transition
src/platform/data-manager/types/permissions.ts✅
Step 6: Testing ⏳
Test Cases:- Verify all 18 system roles appear in matrix
- Verify role ordering is correct
- Verify permissions can be saved for all roles
- Verify custom roles appear (when supported)
- Verify backward compatibility with existing permissions
Implementation Details
Role Fetching
Role Display
Role Sorting
Database Compatibility
PF-26 Tables (Already V2 Compatible):pf_object_permissions- Usesapp_roleenum (supports all system roles)pf_field_permissions- Usesapp_roleenum (supports all system roles)
- Tables already support all system roles
- Migration is UI-only (removing hardcoded constants)
Custom Roles Support (Future)
Current Status: Custom roles are not yet supported inpf_object_permissions table.
Future Enhancement:
- Update
pf_object_permissions.rolecolumn to support bothapp_roleand custom role IDs - Or create separate
pf_object_permissions_customtable - Update
useAvailableRoles()to include custom roles when supported
Rollback Plan
If issues arise:- Revert to using
ORDERED_ROLESandROLE_CONFIGconstants - Component will continue to work (just shows fewer roles)
- No data loss (all permissions remain in database)
Testing Checklist
- All 18 system roles appear in permission matrix
- Roles are sorted correctly (by order)
- Role labels display correctly
- Permissions can be saved for all roles
- Existing permissions load correctly
- Field permissions work with all roles
- Site scope configuration works
- Component handles loading states
- Component handles error states
- No console errors or warnings
Timeline
- 2026-01-26: Migration plan created,
useAvailableRoleshook created ✅ - 2026-01-26: Updated ObjectPermissionsTab component ✅
- 2026-01-26: Updated ObjectPermissionMatrix component ✅
- 2026-01-26: Updated FieldPermissionsSection component ✅
- 2026-01-26: Updated type definitions with deprecation notices ✅
- 2026-XX-XX: Testing and validation ⏳
- 2026-03-31: Sunset date - V1 constants can be removed after this date