-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The roles column in the user table can get extremely long in a production system. This patch collapses UI, API and capture agent roles. This fixes #351
- Loading branch information
Showing
1 changed file
with
27 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,14 +7,36 @@ const UsersRolesCell = ({ | |
row | ||
}: any) => { | ||
const getRoleString = () => { | ||
let roleString = ""; | ||
let displayRoles = []; | ||
let roleCountUI = 0; | ||
let roleCountAPI = 0; | ||
let roleCountCaptureAgent = 0; | ||
|
||
// @ts-expect-error TS(7006): Parameter 'role' implicitly has an 'any' type. | ||
Check failure on line 15 in src/components/users/partials/UsersRolesCell.tsx GitHub Actions / build
|
||
row.roles.forEach((role) => { | ||
roleString = roleString.concat(role.name + ", "); | ||
}); | ||
for (const role of row.roles) { | ||
// @ts-expect-error TS(7006): Parameter 'role' implicitly has an 'any' type. | ||
Check failure on line 17 in src/components/users/partials/UsersRolesCell.tsx GitHub Actions / build
|
||
if (role.name.startsWith('ROLE_UI')) { | ||
roleCountUI++; | ||
} else if (role.name.startsWith('ROLE_API')) { | ||
roleCountAPI++; | ||
} else if (role.name.startsWith('ROLE_CAPTURE_AGENT_')) { | ||
roleCountCaptureAgent++; | ||
} else { | ||
displayRoles.push(role.name); | ||
} | ||
} | ||
|
||
if (roleCountUI > 0) { | ||
displayRoles.push(`${roleCountUI} UI roles`); | ||
} | ||
if (roleCountAPI > 0) { | ||
displayRoles.push(`${roleCountAPI} API roles`); | ||
} | ||
if (roleCountCaptureAgent > 0) { | ||
displayRoles.push(`${roleCountUI} capture agent roles`); | ||
} | ||
|
||
return roleString; | ||
return displayRoles.join(', '); | ||
}; | ||
|
||
return <span>{getRoleString()}</span>; | ||
|