github.com/minio/console@v1.4.1/web-app/src/screens/Console/Support/ClusterRegistrationForm.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 from "react"; 18 import { Box, Button, FormLayout, Select } from "mds"; 19 import { setLoading, setSelectedSubnetOrganization } from "./registerSlice"; 20 import { useSelector } from "react-redux"; 21 import { AppState, useAppDispatch } from "../../../store"; 22 import { callRegister } from "./registerThunks"; 23 import { modalStyleUtils } from "../Common/FormComponents/common/styleLibrary"; 24 import RegisterHelpBox from "./RegisterHelpBox"; 25 26 const ClusterRegistrationForm = () => { 27 const dispatch = useAppDispatch(); 28 29 const subnetAccessToken = useSelector( 30 (state: AppState) => state.register.subnetAccessToken, 31 ); 32 const selectedSubnetOrganization = useSelector( 33 (state: AppState) => state.register.selectedSubnetOrganization, 34 ); 35 const subnetOrganizations = useSelector( 36 (state: AppState) => state.register.subnetOrganizations, 37 ); 38 const loading = useSelector((state: AppState) => state.register.loading); 39 40 return ( 41 <FormLayout 42 title={"Register MinIO cluster"} 43 containerPadding 44 withBorders={false} 45 helpBox={<RegisterHelpBox />} 46 > 47 <Select 48 id="subnet-organization" 49 name="subnet-organization" 50 onChange={(value) => 51 dispatch(setSelectedSubnetOrganization(value as string)) 52 } 53 label="Select an organization" 54 value={selectedSubnetOrganization} 55 options={subnetOrganizations.map((organization) => ({ 56 label: organization.company, 57 value: organization.accountId.toString(), 58 }))} 59 /> 60 <Box sx={modalStyleUtils.modalButtonBar}> 61 <Button 62 id={"register-cluster"} 63 onClick={() => () => { 64 if (loading) { 65 return; 66 } 67 dispatch(setLoading(true)); 68 if (subnetAccessToken && selectedSubnetOrganization) { 69 dispatch( 70 callRegister({ 71 token: subnetAccessToken, 72 account_id: selectedSubnetOrganization, 73 }), 74 ); 75 } 76 }} 77 disabled={loading || subnetAccessToken.trim().length === 0} 78 variant="callAction" 79 label={"Register"} 80 /> 81 </Box> 82 </FormLayout> 83 ); 84 }; 85 86 export default ClusterRegistrationForm;