mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 08:55:24 +00:00
Fix team admin and team maintainer team settings display (#2897)
This commit is contained in:
parent
4e1122aa72
commit
0183863fb8
1
changes/fix-2881-team-admin-maintainer
Normal file
1
changes/fix-2881-team-admin-maintainer
Normal file
@ -0,0 +1 @@
|
||||
* Fix team admin and team maintainer team settings display
|
@ -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"));
|
||||
|
@ -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`,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user