github.com/minio/console@v1.4.1/web-app/src/screens/Console/Configurations/ConfigurationPanels/ExportConfigButton.tsx (about) 1 // This file is part of MinIO Console Server 2 // Copyright (c) 2021 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 { Button, UploadIcon } from "mds"; 19 import useApi from "../../Common/Hooks/useApi"; 20 import { performDownload } from "../../../../common/utils"; 21 import { DateTime } from "luxon"; 22 import { setErrorSnackMessage } from "../../../../systemSlice"; 23 import { useDispatch } from "react-redux"; 24 import TooltipWrapper from "../../Common/TooltipWrapper/TooltipWrapper"; 25 26 const ExportConfigButton = () => { 27 const dispatch = useDispatch(); 28 const [isReqLoading, invokeApi] = useApi( 29 (res: any) => { 30 //base64 encoded information so decode before downloading. 31 performDownload( 32 new Blob([window.atob(res.value)]), 33 `minio-server-config-${DateTime.now().toFormat( 34 "LL-dd-yyyy-HH-mm-ss", 35 )}.conf`, 36 ); 37 }, 38 (err) => { 39 dispatch(setErrorSnackMessage(err)); 40 }, 41 ); 42 43 return ( 44 <TooltipWrapper tooltip="Warning! The resulting file will contain server configuration information in plain text"> 45 <Button 46 id={"export-config"} 47 onClick={() => { 48 invokeApi("GET", `api/v1/configs/export`); 49 }} 50 icon={<UploadIcon />} 51 label={"Export"} 52 variant={"regular"} 53 disabled={isReqLoading} 54 /> 55 </TooltipWrapper> 56 ); 57 }; 58 59 export default ExportConfigButton;