Fix #4436: UI: Team & Role assignment in User Profile page throws an error (#4439)

This commit is contained in:
Vivek Ratnavel Subramanian 2022-04-24 02:54:41 -07:00 committed by GitHub
parent ad22292bc3
commit a93584de12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 4 deletions

View File

@ -161,19 +161,31 @@ const Users = ({
(role) => role.value !== toLower(TERM_ADMIN)
);
// get the admin role and send it as boolean value `iaAdmin=Boolean(isAdmin)
// get the admin role and send it as boolean value `isAdmin=Boolean(isAdmin)
const isAdmin = selectedRoles.find(
(role) => role.value === toLower(TERM_ADMIN)
);
updateUserDetails({
roles: updatedRoles.map((role) => role.value),
roles: updatedRoles.map((item) => {
const roleId = item.value;
const role = roles.find((r) => r.id === roleId);
return { id: roleId, type: 'role', name: role?.name || '' };
}),
isAdmin: Boolean(isAdmin),
});
setIsRolesEdit(false);
};
const handleTeamsChange = () => {
updateUserDetails({ teams: selectedTeams.map((team) => team.value) });
updateUserDetails({
teams: selectedTeams.map((item) => {
const teamId = item.value;
const team = teams.find((t) => t.id === teamId);
return { id: teamId, type: 'team', name: team?.name || '' };
}),
});
setIsTeamsEdit(false);
};

View File

@ -20,8 +20,16 @@ export interface Option {
label: string;
value: string;
}
export interface PatchObject {
id: string;
name: string;
type: string;
}
export type UserDetails = Record<string, string | Array<string> | boolean>;
export type UserDetails = Record<
string,
string | Array<string> | boolean | Array<PatchObject>
>;
export interface Props {
userData: User;