Role Assignment Panel
Component Detail
Description
Modal or slide-over panel for assigning or changing a user's role within the organisation (peer mentor, coordinator, org_admin). Enforces role hierarchy rules so org_admin can only assign roles within their scope. Shows current role, available roles, and confirmation step before saving.
role-assignment-panel
Summaries
The Role Assignment Panel enforces the governance rules that keep the peer mentoring programme operating safely and compliantly. By ensuring administrators can only assign roles within their own permission scope — and by requiring a confirmation step before any role change is persisted — it acts as a key safeguard against accidental or unauthorised privilege escalation. This is particularly important in a multi-tier organisation where an admin at a regional level should not be able to grant organisation-wide administrator rights. Reducing the risk of improper role assignments protects the organisation from safeguarding and data governance incidents, and demonstrates a commitment to robust internal controls that is increasingly expected by funders and regulatory bodies.
Medium-complexity component with a single service dependency (User Management Service), making it relatively self-contained and testable in isolation. The primary delivery risk is the role hierarchy enforcement logic: getAvailableRoles() must correctly filter available roles based on the calling admin's own role scope, which requires a clear specification from the product owner before implementation begins. The confirmation step (confirmAssignment()) adds a UX flow that must be tested for cancellation, network failure during save, and concurrent edit scenarios. As a dependency of User Account Management Screen, this panel must be delivered and unit-tested before the parent screen integration work starts.
Accessibility testing for the modal/slide-over pattern on both mobile and web is required.
RoleAssignmentPanel is a Flutter modal widget (BottomSheet or Dialog depending on platform breakpoint) that communicates with UserManagementService to persist role changes. The show(userId, currentRole) factory method should accept userId and currentRole and internally fetch available roles via getAvailableRoles(), which delegates to UserManagementService with the calling admin's scope token. Role hierarchy enforcement must happen server-side; the panel enforces it client-side as a UX guard only — never trust client-side role filtering as a security boundary. The two-step flow (select → confirm → save) should be modelled as a local state enum (RoleAssignmentState: selecting, confirming, saving, error).
confirmAssignment() calls the service and emits a result event to the parent via a callback or via router return value. dismiss() should check for unsaved changes before closing to prevent accidental dismissal mid-flow.
Responsibilities
- Display current role and available role options scoped to admin privileges
- Confirm role change with user and persist via service
- Validate that target role is within admin's permission scope
Interfaces
show(userId, currentRole)
onRoleSelected(Role role)
confirmAssignment()
dismiss()
getAvailableRoles()