Truncate access review roles with badge list
Long role strings in the access review table broke row layout when drivers joined many roles into one comma-separated value. Expose roles as a string array in GraphQL by splitting the stored role at the API layer, and render the first three roles as badges with a "+X more" popover for the rest. Closes ENG-459. Signed-off-by: Ludovic Vielle <ludovic@probo.com>
This commit is contained in:
@@ -292,7 +292,7 @@ func posthogAccountRecord(member posthogMember) AccountRecord {
|
||||
record := AccountRecord{
|
||||
Email: member.User.Email,
|
||||
FullName: posthogFullName(member.User),
|
||||
Role: posthogRole(member.Level, member.User.RoleAtOrganization),
|
||||
Roles: posthogRoles(member.Level, member.User.RoleAtOrganization),
|
||||
IsAdmin: posthogIsAdmin(member.Level),
|
||||
ExternalID: member.User.UUID,
|
||||
MFAStatus: posthogMFAStatus(member.Is2FAEnabled),
|
||||
@@ -319,18 +319,18 @@ func posthogFullName(user posthogMemberUser) string {
|
||||
return strings.TrimSpace(strings.Join([]string{user.FirstName, user.LastName}, " "))
|
||||
}
|
||||
|
||||
func posthogRole(level int, fallback string) string {
|
||||
func posthogRoles(level int, fallback string) []string {
|
||||
switch {
|
||||
case level >= posthogMembershipLevelOwner:
|
||||
return "Owner"
|
||||
return []string{"Owner"}
|
||||
case level >= posthogMembershipLevelAdmin:
|
||||
return "Admin"
|
||||
return []string{"Admin"}
|
||||
case level >= posthogMembershipLevelMember:
|
||||
return "Member"
|
||||
return []string{"Member"}
|
||||
case fallback != "":
|
||||
return fallback
|
||||
return []string{fallback}
|
||||
default:
|
||||
return "Member"
|
||||
return []string{"Member"}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user