Skip to content

Show "Super Admin" rather than the raw enum value - #450

Open
jhodapp wants to merge 1 commit into
mainfrom
fix/super-admin-display-label
Open

Show "Super Admin" rather than the raw enum value#450
jhodapp wants to merge 1 commit into
mainfrom
fix/super-admin-display-label

Conversation

@jhodapp

@jhodapp jhodapp commented Aug 18, 2026

Copy link
Copy Markdown
Member

Description

The member row's Roles: line rendered SuperAdmin verbatim — the last place a raw enum value
still reached a user after #449 started showing Role.User as "Member".

Changes

  • SuperAdmin now displays as "Super Admin" on the Roles: line.
  • Replaces the inline ternary in getUserDisplayRoles with a ROLE_DISPLAY_NAMES lookup, so the
    two mappings live together and a third costs one line. Role.Admin and the relationship roles
    (Coach/Coachee) are deliberately absent and fall through unchanged.

Screenshots / Videos Showing UI Changes

Helpful to attach: a members list viewed as a global super admin, showing the Roles: line.

Testing Strategy

npm run test:run (163 files / 1746 tests), npx tsc --noEmit, npm run lint, and the chromium
Playwright suite all pass.

Two existing assertions were updated from the raw enum, and a dedicated case was added asserting
Role.SuperAdmin renders as "Super Admin" and never as "SuperAdmin". Verified the tests have teeth:
removing the mapping fails three of them.

getUserDisplayRoles is the only place a raw role value is shown to a user — everywhere else uses
the isAdminOrSuperAdmin / isSuperAdmin predicates — so this completes the sweep.

Concerns

None. Display-only; no API, permission or behaviour change.

The Roles: line rendered SuperAdmin verbatim, the last place a raw enum
reached a user after Role.User started showing as "Member".

Replaces the inline ternary with a ROLE_DISPLAY_NAMES lookup so the two
mappings sit together and a third costs one line. Role.Admin and the
relationship roles are absent and fall through unchanged.
@jhodapp jhodapp self-assigned this Aug 18, 2026
@jhodapp jhodapp added the enhancement Improves existing functionality or feature label Aug 18, 2026
@jhodapp jhodapp added this to the 1.0.0-beta3 milestone Aug 18, 2026
@jhodapp
jhodapp marked this pull request as ready for review August 18, 2026 03:08
@greptile-apps

greptile-apps Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR maps Role.SuperAdmin to the recipient-facing label “Super Admin” and consolidates role labels into a lookup.

  • Updates unit expectations and adds an explicit raw-value regression assertion.
  • Updates the manual member-role test plan to document both recipient-facing labels.

Confidence Score: 4/5

The PR appears safe to merge, with only non-blocking type-strength, test-duplication, and comment-concision concerns.

The current role values render correctly and the changed tests exercise the new label; the remaining concerns affect maintainability and compile-time protection rather than current behavior.

Files Needing Attention: src/lib/utils/user-roles.ts and src/lib/utils/tests/user-roles.test.ts

Important Files Changed

Filename Overview
src/lib/utils/user-roles.ts Correctly adds the SuperAdmin display label, but uses an unnecessarily permissive key type and overlong mapping documentation.
src/lib/utils/tests/user-roles.test.ts Assertions match the new label, though the added test substantially duplicates an existing SuperAdmin case.
docs/test-plans/member_role_change_manual_testing.md Accurately documents the Member and Super Admin recipient-facing labels.

Fix all with Greploop Fix All in Claude Code

Reviews (1): Last reviewed commit: "fix(members): show "Super Admin" rather ..." | Re-trigger Greptile

* "Member" matches the add-member dialog and the row's actions menu; rendering
* the raw "User" here taught a second name for the same role.
*/
const ROLE_DISPLAY_NAMES: Record<string, string> = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Constrain display-name map keys

Record<string, string> accepts invalid role keys without a type error, allowing a typo to silently fall through and render the raw enum value. Typing this partial mapping with DisplayRole preserves the intentional fallback while rejecting unsupported keys.

Suggested change
const ROLE_DISPLAY_NAMES: Record<string, string> = {
const ROLE_DISPLAY_NAMES: Partial<Record<DisplayRole, string>> = {

Context Used: Use refactor-platform-fe's coding standards file f... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code

Comment on lines +82 to +88
it('renders Role.SuperAdmin as "Super Admin", not the raw enum value', () => {
const user = createUser([{ role: Role.SuperAdmin, organization_id: null }]);
const roles = getUserDisplayRoles(user, organizationId, []);

expect(roles).toEqual(['Super Admin']);
expect(roles).not.toContain('SuperAdmin');
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Avoid duplicate SuperAdmin coverage

This test repeats the existing SuperAdmin setup and exact ['Super Admin'] assertion, so future label changes require maintaining two equivalent cases. Consolidate the raw-value assertion into the existing test to retain the distinct check without duplicating the behavior.

Context Used: I want you to look at existing code patterns and e... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code

Comment on lines +14 to +21
/**
* Recipient-facing names for roles whose enum value is not what we want to show
* a user. `Role.Admin` and the relationship roles already read correctly, so
* they are absent and fall through unchanged.
*
* "Member" matches the add-member dialog and the row's actions menu; rendering
* the raw "User" here taught a second name for the same role.
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Trim redundant mapping commentary

This comment restates the visible mappings and fall-through implementation across two paragraphs, increasing documentation maintenance whenever role handling changes. Keep only the non-obvious rationale, or remove the comment where the names are already self-explanatory.

Suggested change
/**
* Recipient-facing names for roles whose enum value is not what we want to show
* a user. `Role.Admin` and the relationship roles already read correctly, so
* they are absent and fall through unchanged.
*
* "Member" matches the add-member dialog and the row's actions menu; rendering
* the raw "User" here taught a second name for the same role.
*/

Context Used: Use refactor-platform-fe's coding standards file f... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improves existing functionality or feature

Projects

Status: Review

Development

Successfully merging this pull request may close these issues.

1 participant