Delete PVCs upon tenant deletion checkbox (#1752)

This commit is contained in:
adfost
2022-03-24 12:17:04 -07:00
committed by GitHub
parent f6d92d50e4
commit ffa9436276
2 changed files with 91 additions and 1 deletions

View File

@@ -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);

View File

@@ -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;
@@ -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 = () => {
@@ -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}
);
};
@@ -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
@@ -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>
}