feat(web): allow promoting pending members to owner - #1694
Conversation
Role changes were rejected unless the member was active, both in the membership service and in the members table action menu. Pending members (added but never signed in) can now be promoted or demoted; suspended members still cannot. The last-owner guards count only active owners, so they now apply only when the target itself is an active owner. Otherwise demoting or removing a pending owner while you are the sole active owner would be refused. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Essentials Run ID: 📒 Files selected for processing (6)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review. WalkthroughPending members can now be promoted or demoted when they are not suspended. Last-owner checks apply to active owners, and the settings table explains that a pending member receives owner access after signing in. ChangesMember role management
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Feature Merge Risk: ⚪ Minimal · up to No identified issue prevents merging the pending-member role changes after normal checks. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Summary
Owners can now promote a pending member (added to the organization but never signed in) to owner from the members table, and demote a pending owner back to member. Previously both the membership service and the action menu required the member to be active. Suspended members still cannot have their role changed.
Changes
membership.service.ts:setMemberRolerejects only suspended members. The last-owner guards insetMemberRoleandremoveMembernow apply only when the target is an active owner. Pending owners are excluded fromcountActiveOwners, so without this a pending owner could not be demoted or removed while the actor was the sole active owner.membersTableActions.tsx: promote and demote render for pending rows. The last-active-owner lock requires the row to be active, so it no longer disables demote or suspend on a pending owner. The promote confirmation for a pending member notes that access starts when they sign in.errors.ts/errorCodes.ts:memberNotActiveErrorrenamed tomemberSuspendedErrorwith codeMEMBER_SUSPENDED, since suspension is now the only condition it describes. The old code had no other references.Semantics
A pending owner does not count toward the active-owner floor. You still cannot demote or leave as the only active owner even if a pending owner exists, matching how the table already computes
activeOwnerCount.Testing
🤖 Generated with Claude Code
Note
Medium Risk
Changes org ownership and last-owner invariants in membership service and UI; incorrect guards could lock admins out or allow unsafe demotions, though behavior is covered by updated unit tests.
Overview
Owners can promote or demote pending members (provisioned but never signed in) from the members table, instead of requiring an active membership first. Suspended members still cannot change role until reactivated.
The membership service now blocks role changes only for suspended users (
MEMBER_SUSPENDED, replacingMEMBER_NOT_ACTIVE). Last-owner protection insetMemberRoleandremoveMemberapplies only when the target is an active owner (isActiveOwner), so pending owners can be demoted or removed without falsely treating them as the sole owner.The members table shows Promote to owner / Demote to member for any non-suspended row (including pending), adjusts the promote confirmation copy for pending users, and keeps the “last active owner” lock tied to active owners only.
Reviewed by Cursor Bugbot for commit ad45763. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit