fix(react): Removing a user having multiple role from owner tab also remove the other roles associated to that user (#2570)

* 2567 | Removing a user having multiple role from owner tab also remove the other roles associated to that user
This commit is contained in:
Lal Rishav 2021-05-18 00:43:20 +05:30 committed by GitHub
parent 4958febed5
commit a5dfa7fa62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -105,13 +105,14 @@ export const Ownership: React.FC<Props> = ({ owners, lastModifiedAt, updateOwner
setStagedOwners(newStagedOwners);
};
const onDelete = (urn: string) => {
const onDelete = (urn: string, role: OwnershipType) => {
const updatedOwners = owners
.filter((owner) => !(owner.owner.urn === urn))
.filter((owner) => !(owner.owner.urn === urn && owner.type === role))
.map((owner) => ({
owner: owner.owner.urn,
type: owner.type,
}));
updateOwnership({ owners: updatedOwners });
};
@ -291,7 +292,11 @@ export const Ownership: React.FC<Props> = ({ owners, lastModifiedAt, updateOwner
</Button>
</>
) : (
<Button type="link" style={{ color: 'red' }} onClick={() => onDelete(record.urn)}>
<Button
type="link"
style={{ color: 'red' }}
onClick={() => onDelete(record.urn, record.role)}
>
Remove
</Button>
)}