Skip to content

[US-14.4 / OBT-249] Manage a user's role and status from the user detail page - #35

Open
levigtri wants to merge 3 commits into
mainfrom
levigft/obt-249-us-144-manage-a-users-role-and-status-from-the-user-detail
Open

[US-14.4 / OBT-249] Manage a user's role and status from the user detail page#35
levigtri wants to merge 3 commits into
mainfrom
levigft/obt-249-us-144-manage-a-users-role-and-status-from-the-user-detail

Conversation

@levigtri

Copy link
Copy Markdown
Member

[US-14.4 / OBT-249] Manage a user's role and status from the user detail page

Summary

Lets a platform admin set a user's role (Member / Manager / Platform Admin) directly from the user detail page, replacing the old boolean "Platform Admin — Make Admin/Remove Admin" toggle with a role badge plus a role selector wired to the new PUT /api/users/{user_id}/role endpoint (US-14.2). The activate/deactivate status flow stays as-is via usersAPI.update.

Changes

  1. src/types/user.ts — added UserRole type ("member" | "manager" | "platform_admin"), optional role field on UserListResponse (identical snippets to US-14.3 for a clean merge), and new UserRoleUpdate interface (role, optional project_ids).
  2. src/types/index.ts — barrel now exports UserRole and UserRoleUpdate from ./user.
  3. src/components/ui/badge.tsx — added manager (bg-azul/25 text-verde border-azul/60) and member (bg-areia/30 text-verde border-areia) badge variants (identical to US-14.3).
  4. src/services/api.ts — added usersAPI.updateRole(userId, data)PUT /users/{userId}/role, returning the updated UserListResponse.
  5. src/components/pages/UserDetailPage.tsxUserInfoCard now shows a "Role:" row with the current role badge (Shield/UserCog/User icons, admin/manager/member variants; role derived as user.role ?? (is_platform_admin ? "platform_admin" : "member")) and a Select with the three role options:
    • Platform Admin → calls updateRole({ role: "platform_admin" }) directly.
    • Manager → opens a "Select projects this user will manage" dialog with a checkbox list fed by projectsAPI.list(); confirm is disabled until at least one project is selected; confirms with updateRole({ role: "manager", project_ids }).
    • Member → opens a ConfirmDialog explaining that all projects the user manages will be demoted, then calls updateRole({ role: "member" }).
    • The selector is disabled for the admin's own account (useAuth user id === page userId) with an InfoTooltip "You cannot change your own role".
    • Success → sonner toast + refetch of the user; error → toast with the API detail message when available.
    • Deactivate/Activate and Delete User flows are untouched.

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Bug fix
  • Breaking change
  • Refactor / chore

Testing

  1. npm run typecheck, npm run lint (0 errors; pre-existing warning in ProjectsPage.tsx only) and npm run build all pass.
  2. Promote to manager: as a platform admin, open a member's detail page, pick "Manager" in the Role select → project selection dialog opens; confirm button stays disabled with 0 projects selected; select one or more projects and confirm → success toast and role badge switches to Manager.
  3. Demote to member: pick "Member" for a manager/admin → confirmation dialog explains managed projects will be demoted; confirm → success toast and Member badge.
  4. Promote to platform admin: pick "Platform Admin" → immediate call, success toast and Admin badge.
  5. Own account: open your own user detail page → the role selector is disabled and the InfoTooltip reads "You cannot change your own role".
  6. Status: Deactivate/Activate still toggles is_active via the existing flow with the same badges and toasts.
  7. Errors: API 400/403/404 responses surface their detail message in an error toast and the role stays unchanged.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@levigtri, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 42 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: QUIET

Plan: Pro Plus

Run ID: 593ba61f-e240-44b4-84d9-4c0eac4b579c

📥 Commits

Reviewing files that changed from the base of the PR and between 130fc4a and 2bdb4b8.

📒 Files selected for processing (5)
  • src/components/pages/UserDetailPage.tsx
  • src/components/ui/badge.tsx
  • src/services/api.ts
  • src/types/index.ts
  • src/types/user.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch levigft/obt-249-us-144-manage-a-users-role-and-status-from-the-user-detail

Comment @coderabbitai help to get the list of available commands.

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