Skip to content

Commit 7c22e1a

Browse files
committed
#1517 fixing some grammar stuff and removing uneccessary checks
1 parent e37b4d7 commit 7c22e1a

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

src/backend/src/services/teams.services.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export default class TeamsService {
4747
* @param teamId a id of team to be updated
4848
* @param userIds a array of user Ids that replaces team's old members
4949
* @returns a updated team
50-
* @throws if the team is not found, the submitter has no priviledge, or any user from the given userIds does not exist
50+
* @throws if the team is not found, the submitter has no privilege, or any user from the given userIds does not exist
5151
*/
5252
static async setTeamMembers(submitter: User, teamId: string, userIds: number[]): Promise<Team> {
5353
// find and verify the given teamId exist
@@ -56,9 +56,14 @@ export default class TeamsService {
5656
...teamQueryArgs
5757
});
5858

59-
if (!team) throw new NotFoundException('Team', teamId);
60-
if (!isAdmin(submitter.role) && submitter.userId !== team.headId)
61-
throw new AccessDeniedException('you must be an admin or the team head to update the members!');
59+
if (!team) {
60+
throw new NotFoundException('Team', teamId);
61+
}
62+
63+
const isTeamLead = team.leads.some((lead) => lead.userId === submitter.userId);
64+
65+
if (!isAdmin(submitter.role) && submitter.userId !== team.headId && !isTeamLead)
66+
throw new AccessDeniedException('you must be an admin, the team head, or a team lead to update the members!');
6267

6368
// this throws if any of the users aren't found
6469
const users = await getUsers(userIds);
@@ -284,4 +289,4 @@ export default class TeamsService {
284289

285290
return teamTransformer(updateTeam);
286291
}
287-
}
292+
}

src/frontend/src/pages/TeamsPage/TeamMembersPageBlock.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const TeamMembersPageBlock: React.FC<TeamMembersPageBlockProps> = ({ team }) =>
4343
return <LoadingIndicator />;
4444

4545
const hasPerms = isAdmin(user.role) || user.userId === team.head.userId;
46+
const editMembersPerms = hasPerms || team.leads.map((lead) => lead.userId).includes(user.userId);
4647

4748
const memberOptions = users
4849
.filter((user) => user.userId !== team.head.userId && !team.leads.map((lead) => lead.userId).includes(user.userId))
@@ -205,7 +206,7 @@ const TeamMembersPageBlock: React.FC<TeamMembersPageBlockProps> = ({ team }) =>
205206
<DetailDisplay label="Members" content={team.members.map((member) => fullNamePipe(member)).join(', ')} />
206207
</Grid>
207208
<Grid item xs={1} mt={-1} display={'flex'} justifyContent={'flex-end'}>
208-
{hasPerms && <IconButton children={<Edit />} onClick={() => setIsEditingMembers(true)} />}
209+
{editMembersPerms && <IconButton children={<Edit />} onClick={() => setIsEditingMembers(true)} />}
209210
</Grid>
210211
</Grid>
211212
);
@@ -219,4 +220,4 @@ const TeamMembersPageBlock: React.FC<TeamMembersPageBlockProps> = ({ team }) =>
219220
);
220221
};
221222

222-
export default TeamMembersPageBlock;
223+
export default TeamMembersPageBlock;

0 commit comments

Comments
 (0)