github.com/minio/console@v1.4.1/web-app/src/screens/Console/Common/CredentialsPrompt/CredentialItem.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, CopyIcon, InputLabel, ReadBox, Box } from "mds"; 19 import CopyToClipboard from "react-copy-to-clipboard"; 20 import { setModalSnackMessage } from "../../../../systemSlice"; 21 import { useAppDispatch } from "../../../../store"; 22 23 interface ICredentialsItem { 24 label?: string; 25 value?: string; 26 } 27 28 const CredentialItem = ({ label = "", value = "" }: ICredentialsItem) => { 29 const dispatch = useAppDispatch(); 30 31 return ( 32 <Box sx={{ marginTop: 12 }}> 33 <InputLabel>{label}</InputLabel> 34 <ReadBox 35 actionButton={ 36 <CopyToClipboard text={value}> 37 <Button 38 id={"copy-path"} 39 variant="regular" 40 onClick={() => { 41 dispatch(setModalSnackMessage(`${label} copied to clipboard`)); 42 }} 43 style={{ 44 marginRight: "5px", 45 width: "28px", 46 height: "28px", 47 padding: "0px", 48 }} 49 icon={<CopyIcon />} 50 /> 51 </CopyToClipboard> 52 } 53 > 54 {value} 55 </ReadBox> 56 </Box> 57 ); 58 }; 59 60 export default CredentialItem;