Roles: only observers, only maintainers (#929)

* User roles render for only team observers and only team maintainers
This commit is contained in:
RachelElysia 2021-06-02 15:55:52 -04:00 committed by GitHub
parent 0f09c2e837
commit 0867c717cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -146,13 +146,26 @@ const generateTeam = (teams: ITeam[], globalRole: string | null): string => {
const generateRole = (teams: ITeam[], globalRole: string | null): string => {
if (globalRole === null) {
const listOfRoles: any = teams.map((team) => team.role);
if (teams.length === 0) {
// no global role and no teams
return "Unassigned";
} else if (teams.length === 1) {
// no global role and only one team
return stringUtils.capitalize(teams[0].role ?? "");
} else if (
listOfRoles.every((role: string): boolean => role === "maintainer")
) {
// only team maintainers
return stringUtils.capitalize(teams[0].role ?? "");
} else if (
listOfRoles.every((role: string): boolean => role === "observer")
) {
// only team observers
return stringUtils.capitalize(teams[0].role ?? "");
}
return "Various"; // no global role and multiple teams
}