Skip to content

Commit

Permalink
disable deletion of default-users from the users table
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveDarsa committed Sep 5, 2023
1 parent 6b5737b commit 60a5e3b
Showing 1 changed file with 50 additions and 45 deletions.
95 changes: 50 additions & 45 deletions src/components/Organizations/Users/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,52 +116,57 @@ const Users = ({ users = [], organization, organizationId, organizationName, ref
<EyeOutlined className="edit" />
</a>
</Link>
<DeleteOutlined
className="delete"
onClick={() => {
setSelectedUser(user?.id);
setDeleteUserModalOpen(true);
}}
/>
<Modal isOpen={deleteUserModalOpen && selectedUser === user?.id} onRequestClose={closeUserModal}>
<RemoveModalHeader>Remove user?</RemoveModalHeader>
<RemoveModalParagraph>
This action will remove this user from all groups, you might not be able to reverse this.
</RemoveModalParagraph>

<Footer>
<Mutation mutation={DELETE_USER}>
{(removeUserFromOrganizationGroups, { error, data }) => {
if (error) {
return <div>{error.message}</div>;
}
if (data) {
refetch().then(() => {
return setDeleteUserModalOpen(false);
});
}
return (
<Button
variant="primary"
action={() => {
removeUserFromOrganizationGroups({
variables: {
email: user?.email,
organization: organization.id,
},
});
}}
>
Continue
</Button>
);

{!user.email.startsWith('default-user') ? (
<>
<DeleteOutlined
className="delete"
onClick={() => {
setSelectedUser(user?.id);
setDeleteUserModalOpen(true);
}}
</Mutation>
<Button variant="ghost" action={closeUserModal}>
Cancel
</Button>
</Footer>
</Modal>
/>
<Modal isOpen={deleteUserModalOpen && selectedUser === user?.id} onRequestClose={closeUserModal}>
<RemoveModalHeader>Remove user?</RemoveModalHeader>
<RemoveModalParagraph>
This action will remove this user from all groups, you might not be able to reverse this.
</RemoveModalParagraph>

<Footer>
<Mutation mutation={DELETE_USER}>
{(removeUserFromOrganizationGroups, { error, data }) => {
if (error) {
return <div>{error.message}</div>;
}
if (data) {
refetch().then(() => {
return setDeleteUserModalOpen(false);
});
}
return (
<Button
variant="primary"
action={() => {
removeUserFromOrganizationGroups({
variables: {
email: user?.email,
organization: organization.id,
},
});
}}
>
Continue
</Button>
);
}}
</Mutation>
<Button variant="ghost" action={closeUserModal}>
Cancel
</Button>
</Footer>
</Modal>
</>
) : null}
</TableActions>
);
},
Expand Down

0 comments on commit 60a5e3b

Please sign in to comment.