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:
@@ -101,13 +101,13 @@ func (d *ClickUpDriver) ListAccounts(ctx context.Context) ([]AccountRecord, erro
|
||||
|
||||
records := make([]AccountRecord, 0, len(resp.Team.Members))
|
||||
for _, m := range resp.Team.Members {
|
||||
role := clickupRoleLabel(m.User.Role)
|
||||
roles := clickupRoles(m.User.Role)
|
||||
isAdmin := m.User.Role == 1 || m.User.Role == 2
|
||||
|
||||
record := AccountRecord{
|
||||
Email: m.User.Email,
|
||||
FullName: m.User.Username,
|
||||
Role: role,
|
||||
Roles: roles,
|
||||
IsAdmin: isAdmin,
|
||||
ExternalID: m.User.ID.String(),
|
||||
MFAStatus: coredata.MFAStatusUnknown,
|
||||
@@ -134,20 +134,20 @@ func (d *ClickUpDriver) ListAccounts(ctx context.Context) ([]AccountRecord, erro
|
||||
return records, nil
|
||||
}
|
||||
|
||||
// clickupRoleLabel maps ClickUp numeric role codes to human-readable
|
||||
// clickupRoles maps ClickUp numeric role codes to human-readable
|
||||
// labels. Source: https://clickup.com/api (Team Members endpoint).
|
||||
func clickupRoleLabel(role int) string {
|
||||
func clickupRoles(role int) []string {
|
||||
switch role {
|
||||
case 1:
|
||||
return "owner"
|
||||
return []string{"owner"}
|
||||
case 2:
|
||||
return "admin"
|
||||
return []string{"admin"}
|
||||
case 3:
|
||||
return "member"
|
||||
return []string{"member"}
|
||||
case 4:
|
||||
return "guest"
|
||||
return []string{"guest"}
|
||||
default:
|
||||
return ""
|
||||
return []string{}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user