-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Summary
Continuation of PR #26 (Review Assignment Toggle). Currently, each super admin can only toggle their own review assignment on/off. This feature updates the existing endpoints so any super admin can see all super admins and toggle their review assignment status.
Why
Right now, if a super admin forgets to disable themselves or is unavailable, another super admin has no way to turn off their reviews — they'd need direct database access. This view gives super admins visibility into who is receiving reviews and the ability to manage each other's toggles.
Approach
Replace the existing endpoints in-place (project is early-stage, no backwards compatibility needed). No new routes required.
Backend
1. Store — Add two new methods
GetByRole(ctx, role) ([]User, error)onUsersStore— SimpleSELECT ... FROM users WHERE role = $1. Needed so the GET handler can return email info for all super admins alongside toggle states.GetAllReviewAssignmentToggles(ctx) ([]ReviewAssignmentEntry, error)onSettingsStore— Reads and returns the full JSON array from the settings table. Same query pattern as existingGetReviewAssignmentTogglebut returns all entries instead of filtering to one.
2. Store interface + mock — Wire up the new methods
Add both methods to Storage interfaces in storage.go and corresponding mocks in mock_store.go.
3. Replace GET /v1/superadmin/settings/review-assignment-toggle
Currently returns { "enabled": bool } for the calling user only. Replace to:
- Call
GetByRole(ctx, RoleSuperAdmin)to get all super admins - Call
GetAllReviewAssignmentToggles(ctx)to get the full toggle array - Join them — super admins in the users table but missing from the toggle array default to
enabled: true - Return:
{
"admins": [
{ "id": "uuid-1", "email": "alice@example.com", "enabled": true },
{ "id": "uuid-2", "email": "bob@example.com", "enabled": false }
]
}4. Replace POST /v1/superadmin/settings/review-assignment-toggle
Currently accepts { "enabled": bool } and uses the caller's user ID from context. Replace to accept:
{ "user_id": "target-super-admin-id", "enabled": true }Pass the provided user_id to the existing SetReviewAssignmentToggle(ctx, userID, enabled) store method (which already supports any ID — the restriction to "self only" was only in the handler).
Frontend
5. Update ReviewsPerAppTab.tsx
Replace the single self-toggle <Switch> card with a list of all super admins:
- Fetch the updated GET response on mount
- Render each super admin as a row with their email and a
<Switch> - Toggling any switch calls the updated POST with that admin's
user_id - Visually distinguish the current user (e.g., "(you)" label)
- Show loading/toast states as before
What stays the same
- Settings table schema and JSONB storage format — no migration needed
SetReviewAssignmentTogglestore method — already accepts arbitrarysuperAdminID- User creation logic that auto-adds new super admins with
enabled: true - Route paths stay at
GET/POST /v1/superadmin/settings/review-assignment-toggle - Legacy format fallback parsing in the store
Relates to PR #26