From ffa943627623378016bb42fc2fcc4682f9fbbdfb Mon Sep 17 00:00:00 2001 From: adfost Date: Thu, 24 Mar 2022 12:17:04 -0700 Subject: [PATCH] Delete PVCs upon tenant deletion checkbox (#1752) --- .../Common/WarningMessage/WarningMessage.tsx | 67 +++++++++++++++++++ .../Tenants/ListTenants/DeleteTenant.tsx | 25 ++++++- 2 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 portal-ui/src/screens/Console/Common/WarningMessage/WarningMessage.tsx diff --git a/portal-ui/src/screens/Console/Common/WarningMessage/WarningMessage.tsx b/portal-ui/src/screens/Console/Common/WarningMessage/WarningMessage.tsx new file mode 100644 index 000000000..68aea1db8 --- /dev/null +++ b/portal-ui/src/screens/Console/Common/WarningMessage/WarningMessage.tsx @@ -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 . + +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 ( +
+

+ {title} +

+
+ {label} +
+
+ ); +}; + +export default withStyles(styles)(WarningMessage); diff --git a/portal-ui/src/screens/Console/Tenants/ListTenants/DeleteTenant.tsx b/portal-ui/src/screens/Console/Tenants/ListTenants/DeleteTenant.tsx index 300ef93bc..55a393613 100644 --- a/portal-ui/src/screens/Console/Tenants/ListTenants/DeleteTenant.tsx +++ b/portal-ui/src/screens/Console/Tenants/ListTenants/DeleteTenant.tsx @@ -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(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={ + {deleteVolumes && ( + + + )} To continue please type {selectedTenant.name} in the box. +
+ { + setDeleteVolumes(!deleteVolumes) + }} + value={deleteVolumes} + />
}