Skip to content

Commit

Permalink
Delete PVCs upon tenant deletion checkbox (#1752)
Browse files Browse the repository at this point in the history
  • Loading branch information
adfost committed Mar 24, 2022
1 parent f6d92d5 commit ffa9436
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import React from "react";
import { Theme } from "@mui/material/styles";
import createStyles from "@mui/styles/createStyles";
import withStyles from "@mui/styles/withStyles";

interface IWarningMessage {
classes: any;
label: any;
title: any;
}

const styles = (theme: Theme) =>
createStyles({
headerContainer: {
backgroundColor: "#e78794",
borderRadius: 3,
marginBottom: 20,
padding: 1,
paddingBottom: 15,
},
labelHeadline: {
color: "#000000",
fontSize: 14,
marginLeft: 20,
},
labelText: {
color: "#000000",
fontSize: 14,
marginLeft: 20,
marginRight: 40,
},
});

const WarningMessage = ({
classes,
label,
title,
}: IWarningMessage) => {
return (
<div className={classes.headerContainer}>
<h4 className={classes.labelHeadline}>
{title}
</h4>
<div className={classes.labelText}>
{label}
</div>
</div>
);
};

export default withStyles(styles)(WarningMessage);
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import Grid from "@mui/material/Grid";
import useApi from "../../Common/Hooks/useApi";
import ConfirmDialog from "../../Common/ModalWrapper/ConfirmDialog";
import { ConfirmDeleteIcon } from "../../../../icons";
import WarningMessage from "../../Common/WarningMessage/WarningMessage";
import FormSwitchWrapper from "../../Common/FormComponents/FormSwitchWrapper/FormSwitchWrapper";

interface IDeleteTenant {
deleteOpen: boolean;
Expand All @@ -45,6 +47,8 @@ const DeleteTenant = ({
const onDelError = (err: ErrorResponseHandler) => setErrorSnackMessage(err);
const onClose = () => closeDeleteModalAndRefresh(false);

const [deleteVolumes, setDeleteVolumes] = useState<boolean>(false);

const [deleteLoading, invokeDeleteApi] = useApi(onDelSuccess, onDelError);

const onConfirmDelete = () => {
Expand All @@ -57,7 +61,8 @@ const DeleteTenant = ({
}
invokeDeleteApi(
"DELETE",
`/api/v1/namespaces/${selectedTenant.namespace}/tenants/${selectedTenant.name}`
`/api/v1/namespaces/${selectedTenant.namespace}/tenants/${selectedTenant.name}`,
{delete_pvcs: deleteVolumes}
);
};

Expand All @@ -75,6 +80,13 @@ const DeleteTenant = ({
}}
confirmationContent={
<DialogContentText>
{deleteVolumes && (<Grid item xs={12}>
<WarningMessage
title={"WARNING"}
label={"Delete Volumes: Data will be permanently deleted. Please proceed with caution."}
/>
</Grid>
)}
To continue please type <b>{selectedTenant.name}</b> in the box.
<Grid item xs={12}>
<InputBoxWrapper
Expand All @@ -86,6 +98,17 @@ const DeleteTenant = ({
label=""
value={retypeTenant}
/>
<br/>
<FormSwitchWrapper
checked={deleteVolumes}
id={`delete-volumes`}
label={"Delete Volumes"}
name={`delete-volumes`}
onChange={() => {
setDeleteVolumes(!deleteVolumes)
}}
value={deleteVolumes}
/>
</Grid>
</DialogContentText>
}
Expand Down

0 comments on commit ffa9436

Please sign in to comment.