github.com/minio/console@v1.4.1/web-app/src/screens/Console/Support/CallHomeConfirmation.tsx (about) 1 // This file is part of MinIO Console Server 2 // Copyright (c) 2023 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, { Fragment, useState } from "react"; 18 import { Button, CallHomeMenuIcon, CircleIcon, Grid, ProgressBar } from "mds"; 19 20 import api from "../../../common/api"; 21 import { ICallHomeResponse } from "./types"; 22 import { ErrorResponseHandler } from "../../../common/types"; 23 import { setErrorSnackMessage, setSnackBarMessage } from "../../../systemSlice"; 24 import { useAppDispatch } from "../../../store"; 25 import ModalWrapper from "../Common/ModalWrapper/ModalWrapper"; 26 27 interface ICallHomeConfirmation { 28 onClose: (refresh: boolean) => any; 29 open: boolean; 30 diagStatus: boolean; 31 logsStatus: boolean; 32 disable?: boolean; 33 } 34 35 const CallHomeConfirmation = ({ 36 onClose, 37 diagStatus, 38 logsStatus, 39 open, 40 disable = false, 41 }: ICallHomeConfirmation) => { 42 const dispatch = useAppDispatch(); 43 44 const [loading, setLoading] = useState<boolean>(false); 45 46 const onConfirmAction = () => { 47 setLoading(true); 48 api 49 .invoke("PUT", `/api/v1/support/callhome`, { 50 diagState: disable ? false : diagStatus, 51 logsState: disable ? false : logsStatus, 52 }) 53 .then((res: ICallHomeResponse) => { 54 dispatch(setSnackBarMessage("Configuration saved successfully")); 55 setLoading(false); 56 onClose(true); 57 }) 58 .catch((err: ErrorResponseHandler) => { 59 setLoading(false); 60 dispatch(setErrorSnackMessage(err)); 61 }); 62 }; 63 64 return ( 65 <ModalWrapper 66 modalOpen={open} 67 title={disable ? "Disable Call Home" : "Edit Call Home Configurations"} 68 onClose={() => onClose(false)} 69 titleIcon={<CallHomeMenuIcon />} 70 > 71 {disable ? ( 72 <Fragment> 73 Please Acknowledge that after doing this action, we will no longer 74 receive updated cluster information automatically, losing the 75 potential benefits that Call Home provides to your MinIO cluster. 76 <Grid item xs={12} sx={{ margin: "15px 0" }}> 77 Are you sure you want to disable SUBNET Call Home? 78 </Grid> 79 <br /> 80 {loading && ( 81 <Grid 82 item 83 xs={12} 84 sx={{ 85 marginBottom: 10, 86 }} 87 > 88 <ProgressBar /> 89 </Grid> 90 )} 91 <Grid 92 item 93 xs={12} 94 sx={{ 95 display: "flex", 96 justifyContent: "flex-end", 97 }} 98 > 99 <Button 100 id={"reset"} 101 type="button" 102 variant="regular" 103 disabled={loading} 104 onClick={() => onClose(false)} 105 label={"Cancel"} 106 sx={{ 107 marginRight: 10, 108 }} 109 /> 110 <Button 111 id={"save-lifecycle"} 112 type="submit" 113 variant={"secondary"} 114 color="primary" 115 disabled={loading} 116 label={"Yes, Disable Call Home"} 117 onClick={onConfirmAction} 118 /> 119 </Grid> 120 </Fragment> 121 ) : ( 122 <Fragment> 123 Are you sure you want to change the following configurations for 124 SUBNET Call Home: 125 <Grid 126 item 127 sx={{ 128 margin: "20px 0", 129 display: "flex", 130 flexDirection: "column", 131 gap: 15, 132 }} 133 > 134 <Grid item sx={{ display: "flex", alignItems: "center", gap: 10 }}> 135 <CircleIcon 136 style={{ fill: diagStatus ? "#4CCB92" : "#C83B51", width: 20 }} 137 /> 138 <span> 139 <strong>{diagStatus ? "Enable" : "Disable"}</strong> - Send 140 Diagnostics Information to SUBNET 141 </span> 142 </Grid> 143 <Grid item sx={{ display: "flex", alignItems: "center", gap: 10 }}> 144 <CircleIcon 145 style={{ fill: logsStatus ? "#4CCB92" : "#C83B51", width: 20 }} 146 /> 147 <span> 148 <strong>{logsStatus ? "Enable" : "Disable"}</strong> - Send Logs 149 Information to SUBNET 150 </span> 151 </Grid> 152 </Grid> 153 <Grid item xs={12} sx={{ margin: "15px 0" }}> 154 Please Acknowledge that the information provided will only be 155 available in your SUBNET Account and it will not be shared to other 156 persons or entities besides MinIO team and you. 157 </Grid> 158 {loading && ( 159 <Grid 160 item 161 xs={12} 162 sx={{ 163 marginBottom: 10, 164 }} 165 > 166 <ProgressBar /> 167 </Grid> 168 )} 169 <Grid 170 item 171 xs={12} 172 sx={{ 173 display: "flex", 174 justifyContent: "flex-end", 175 }} 176 > 177 <Button 178 id={"reset"} 179 type="button" 180 variant="regular" 181 disabled={loading} 182 onClick={() => onClose(false)} 183 label={"Cancel"} 184 sx={{ 185 marginRight: 10, 186 }} 187 /> 188 <Button 189 id={"save-lifecycle"} 190 type="submit" 191 variant={"callAction"} 192 color="primary" 193 disabled={loading} 194 label={"Yes, Save this Configuration"} 195 onClick={onConfirmAction} 196 /> 197 </Grid> 198 </Fragment> 199 )} 200 </ModalWrapper> 201 ); 202 }; 203 204 export default CallHomeConfirmation;