Fix team admin and team maintainer team settings display (#2897)

This commit is contained in:
Luke Heath 2021-11-11 17:31:47 -06:00 committed by GitHub
parent 4e1122aa72
commit 0183863fb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 3 deletions

View File

@ -0,0 +1 @@
* Fix team admin and team maintainer team settings display

View File

@ -33,9 +33,20 @@ const AuthAnyAdminRoutes = ({
return null;
}
const teamId = Number(children.props.params.team_id) || null;
let allowAccess;
if (teamId && user.teams) {
const userAdminTeams = user.teams.filter(
(thisTeam) => thisTeam.role === "admin"
);
allowAccess = userAdminTeams.some((thisTeam) => thisTeam.id === teamId);
}
if (
!permissionUtils.isGlobalAdmin(user) &&
!permissionUtils.isAnyTeamAdmin(user)
(!permissionUtils.isGlobalAdmin(user) &&
!permissionUtils.isAnyTeamAdmin(user)) ||
(!permissionUtils.isGlobalAdmin(user) && !allowAccess)
) {
dispatch(push(HOME));
dispatch(renderFlash("error", "You do not have permissions for that page"));

View File

@ -61,6 +61,9 @@ export default (currentUser) => {
permissionUtils.isAnyTeamAdmin(currentUser) ||
permissionUtils.isGlobalAdmin(currentUser)
) {
const userAdminTeams = currentUser.teams.filter(
(thisTeam) => thisTeam.role === "admin"
);
const adminNavItems = [
{
icon: "settings",
@ -71,7 +74,7 @@ export default (currentUser) => {
pathname:
currentUser.global_role === "admin"
? PATHS.ADMIN_SETTINGS
: `${PATHS.ADMIN_TEAMS}/${currentUser.teams[0].id}/members`,
: `${PATHS.ADMIN_TEAMS}/${userAdminTeams[0].id}/members`,
},
},
];