Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add confirmation pop-ups for deletion of team roles and groups #1231

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const DeleteObjectWithFrictionModal = (props) => {
const handleChange = (event) => {
setConfirmValue(event.target.value);
};

return (
<Dialog maxWidth="sm" fullWidth onClose={onClose} open={open} {...other}>
<Box sx={{ p: 3 }}>
Expand Down
46 changes: 39 additions & 7 deletions frontend/src/modules/Environments/components/EnvironmentTeams.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { HiUserRemove } from 'react-icons/hi';
import { VscChecklist } from 'react-icons/vsc';
import {
Defaults,
DeleteObjectWithFrictionModal,
Label,
Pager,
RefreshTableMenu,
Expand Down Expand Up @@ -65,6 +66,16 @@ function TeamRow({ team, environment, fetchItems }) {
const [accessingConsole, setAccessingConsole] = useState(false);
const [loadingCreds, setLoadingCreds] = useState(false);
const [isTeamEditModalOpen, setIsTeamEditModalOpen] = useState(false);
const [isDeleteTeamModalOpen, setIsDeleteTeamModalOpen] = useState(false);

const handleDeleteTeamModalOpen = () => {
setIsDeleteTeamModalOpen(true);
};

const handleDeleteTeamModalClose = () => {
setIsDeleteTeamModalOpen(false);
};

const handleTeamEditModalClose = () => {
setIsTeamEditModalOpen(false);
};
Expand Down Expand Up @@ -215,7 +226,7 @@ function TeamRow({ team, environment, fetchItems }) {
</>
)}
{team.groupUri !== environment.SamlGroupName && (
<LoadingButton onClick={() => removeGroup(team.groupUri)}>
<LoadingButton onClick={() => handleDeleteTeamModalOpen()}>
<HiUserRemove
size={25}
color={
Expand All @@ -227,6 +238,14 @@ function TeamRow({ team, environment, fetchItems }) {
</LoadingButton>
)}
</Box>
<DeleteObjectWithFrictionModal
objectName={team.groupUri}
onApply={handleDeleteTeamModalClose}
onClose={handleDeleteTeamModalClose}
open={isDeleteTeamModalOpen}
isAWSResource={false}
deleteFunction={() => removeGroup(team.groupUri)}
/>
</TableCell>
</TableRow>
);
Expand All @@ -252,6 +271,14 @@ export const EnvironmentTeams = ({ environment }) => {
const [inputValueRoles, setInputValueRoles] = useState('');
const [isTeamInviteModalOpen, setIsTeamInviteModalOpen] = useState(false);
const [isAddRoleModalOpen, setIsAddRoleModalOpen] = useState(false);
const [isDeleteRoleModalOpenId, setIsDeleteRoleModalOpen] = useState(0);
const handleDeleteRoleModalOpen = (id) => {
setIsDeleteRoleModalOpen(id);
};
const handleDeleteRoleModalClosed = (id) => {
setIsDeleteRoleModalOpen(0);
};

const handleTeamInviteModalOpen = () => {
setIsTeamInviteModalOpen(true);
};
Expand Down Expand Up @@ -424,10 +451,6 @@ export const EnvironmentTeams = ({ environment }) => {
setRowModesModel({ ...rowModesModel, [id]: { mode: GridRowModes.View } });
};

const handleDeleteClick = (id) => () => {
removeConsumptionRole(id);
};

const handleCancelClick = (id) => () => {
setRowModesModel({
...rowModesModel,
Expand Down Expand Up @@ -711,7 +734,8 @@ export const EnvironmentTeams = ({ environment }) => {
flex: 0.5,
type: 'actions',
cellClassName: 'actions',
getActions: ({ id }) => {
getActions: ({ id, ...props }) => {
const name = props.row.consumptionRoleName;
const isInEditMode =
rowModesModel[id]?.mode === GridRowModes.Edit;

Expand Down Expand Up @@ -745,8 +769,16 @@ export const EnvironmentTeams = ({ environment }) => {
<GridActionsCellItem
icon={<DeleteIcon />}
label="Delete"
onClick={handleDeleteClick(id)}
onClick={() => handleDeleteRoleModalOpen(id)}
color="inherit"
/>,
<DeleteObjectWithFrictionModal
objectName={name}
onApply={() => handleDeleteRoleModalClosed(id)}
onClose={() => handleDeleteRoleModalClosed(id)}
open={isDeleteRoleModalOpenId === id}
isAWSResource={false}
deleteFunction={() => removeConsumptionRole(id)}
/>
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { HiUserRemove } from 'react-icons/hi';
import { VscChecklist } from 'react-icons/vsc';
import {
Defaults,
DeleteObjectWithFrictionModal,
Label,
Pager,
RefreshTableMenu,
Expand All @@ -49,6 +50,16 @@ function TeamRow({ team, organization, fetchItems }) {
const theme = useTheme();
const { enqueueSnackbar } = useSnackbar();
const [isPermissionModalOpen, setIsPermissionsModalOpen] = useState(false);
const [isDeleteGroupModalOpen, setIsDeleteGroupModalOpenId] = useState(false);

const handleDeleteGroupModalClosed = () => {
setIsDeleteGroupModalOpenId(false);
};

const handleDeleteGroupModalOpen = () => {
setIsDeleteGroupModalOpenId(true);
};

const handlePermissionsModalClose = () => {
setIsPermissionsModalOpen(false);
};
Expand Down Expand Up @@ -125,7 +136,7 @@ function TeamRow({ team, organization, fetchItems }) {
<TableCell>
<Box>
{team.groupUri !== organization.SamlGroupName && (
<LoadingButton onClick={() => removeGroup(team.groupUri)}>
<LoadingButton onClick={() => handleDeleteGroupModalOpen()}>
<HiUserRemove
size={25}
color={
Expand All @@ -136,6 +147,16 @@ function TeamRow({ team, organization, fetchItems }) {
/>
</LoadingButton>
)}
{team.groupUri !== organization.SamlGroupName && (
<DeleteObjectWithFrictionModal
objectName={team.groupUri}
onApply={() => handleDeleteGroupModalClosed()}
onClose={() => handleDeleteGroupModalClosed()}
open={isDeleteGroupModalOpen}
isAWSResource={false}
deleteFunction={() => removeGroup(team.groupUri)}
/>
)}
</Box>
</TableCell>
</TableRow>
Expand Down
Loading