Skip to content

Commit ffa9436

Browse files
authored
Delete PVCs upon tenant deletion checkbox (#1752)
1 parent f6d92d5 commit ffa9436

File tree

2 files changed

+91
-1
lines changed

2 files changed

+91
-1
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// This file is part of MinIO Console Server
2+
// Copyright (c) 2022 MinIO, Inc.
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
import React from "react";
18+
import { Theme } from "@mui/material/styles";
19+
import createStyles from "@mui/styles/createStyles";
20+
import withStyles from "@mui/styles/withStyles";
21+
22+
interface IWarningMessage {
23+
classes: any;
24+
label: any;
25+
title: any;
26+
}
27+
28+
const styles = (theme: Theme) =>
29+
createStyles({
30+
headerContainer: {
31+
backgroundColor: "#e78794",
32+
borderRadius: 3,
33+
marginBottom: 20,
34+
padding: 1,
35+
paddingBottom: 15,
36+
},
37+
labelHeadline: {
38+
color: "#000000",
39+
fontSize: 14,
40+
marginLeft: 20,
41+
},
42+
labelText: {
43+
color: "#000000",
44+
fontSize: 14,
45+
marginLeft: 20,
46+
marginRight: 40,
47+
},
48+
});
49+
50+
const WarningMessage = ({
51+
classes,
52+
label,
53+
title,
54+
}: IWarningMessage) => {
55+
return (
56+
<div className={classes.headerContainer}>
57+
<h4 className={classes.labelHeadline}>
58+
{title}
59+
</h4>
60+
<div className={classes.labelText}>
61+
{label}
62+
</div>
63+
</div>
64+
);
65+
};
66+
67+
export default withStyles(styles)(WarningMessage);

portal-ui/src/screens/Console/Tenants/ListTenants/DeleteTenant.tsx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import Grid from "@mui/material/Grid";
2525
import useApi from "../../Common/Hooks/useApi";
2626
import ConfirmDialog from "../../Common/ModalWrapper/ConfirmDialog";
2727
import { ConfirmDeleteIcon } from "../../../../icons";
28+
import WarningMessage from "../../Common/WarningMessage/WarningMessage";
29+
import FormSwitchWrapper from "../../Common/FormComponents/FormSwitchWrapper/FormSwitchWrapper";
2830

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

50+
const [deleteVolumes, setDeleteVolumes] = useState<boolean>(false);
51+
4852
const [deleteLoading, invokeDeleteApi] = useApi(onDelSuccess, onDelError);
4953

5054
const onConfirmDelete = () => {
@@ -57,7 +61,8 @@ const DeleteTenant = ({
5761
}
5862
invokeDeleteApi(
5963
"DELETE",
60-
`/api/v1/namespaces/${selectedTenant.namespace}/tenants/${selectedTenant.name}`
64+
`/api/v1/namespaces/${selectedTenant.namespace}/tenants/${selectedTenant.name}`,
65+
{delete_pvcs: deleteVolumes}
6166
);
6267
};
6368

@@ -75,6 +80,13 @@ const DeleteTenant = ({
7580
}}
7681
confirmationContent={
7782
<DialogContentText>
83+
{deleteVolumes && (<Grid item xs={12}>
84+
<WarningMessage
85+
title={"WARNING"}
86+
label={"Delete Volumes: Data will be permanently deleted. Please proceed with caution."}
87+
/>
88+
</Grid>
89+
)}
7890
To continue please type <b>{selectedTenant.name}</b> in the box.
7991
<Grid item xs={12}>
8092
<InputBoxWrapper
@@ -86,6 +98,17 @@ const DeleteTenant = ({
8698
label=""
8799
value={retypeTenant}
88100
/>
101+
<br/>
102+
<FormSwitchWrapper
103+
checked={deleteVolumes}
104+
id={`delete-volumes`}
105+
label={"Delete Volumes"}
106+
name={`delete-volumes`}
107+
onChange={() => {
108+
setDeleteVolumes(!deleteVolumes)
109+
}}
110+
value={deleteVolumes}
111+
/>
89112
</Grid>
90113
</DialogContentText>
91114
}

0 commit comments

Comments
 (0)