@@ -14,12 +14,12 @@ import {
1414} from '@mui/material' ;
1515import styles from './new.module.css' ;
1616import { useState } from 'react' ;
17- import { createCluster } from '../../lib/api' ;
1817import HelpIcon from '@mui/icons-material/Help' ;
1918import { LoadingButton } from '@mui/lab' ;
2019import CancelIcon from '@mui/icons-material/Cancel' ;
2120import CheckCircleIcon from '@mui/icons-material/CheckCircle' ;
2221import { useNavigate } from 'react-router-dom' ;
22+ import { createCluster } from '../../lib/api' ;
2323
2424export default function NewCluster ( ) {
2525 const [ successMessage , setSuccessMessage ] = useState ( false ) ;
@@ -39,6 +39,8 @@ export default function NewCluster() {
3939 const [ idc , setIDC ] = useState ( [ ] ) ;
4040 const [ loadingButton , setLoadingButton ] = useState ( false ) ;
4141 const cidrsOptions = [ '10.0.0.0/8' , '172.16.0.0/12' , '192.168.0.0/16' ] ;
42+ const [ idcHelperText , setIDCHelperText ] = useState ( 'Fill in the characters, the length is 0-100.' ) ;
43+ const [ cidrsHelperText , setCIDRsHelperText ] = useState ( 'Fill in the characters, the length is 0-1000.' ) ;
4244 const navigate = useNavigate ( ) ;
4345
4446 const informationForm = [
@@ -136,6 +138,7 @@ export default function NewCluster() {
136138 } ,
137139
138140 onInputChange : ( e : any ) => {
141+ setIDCHelperText ( 'Fill in the characters, the length is 0-100.' ) ;
139142 changeValidate ( e . target . value , scopesForm [ 1 ] ) ;
140143 } ,
141144
@@ -151,7 +154,7 @@ export default function NewCluster() {
151154 name : 'idc' ,
152155 placeholder : 'Please enter IDC' ,
153156 error : idcError ,
154- helperText : idcError ? 'Fill in the characters, the length is 0-100.' : '' ,
157+ helperText : idcError ? idcHelperText : '' ,
155158
156159 onKeyDown : ( e : any ) => {
157160 if ( e . keyCode === 13 ) {
@@ -182,6 +185,7 @@ export default function NewCluster() {
182185 } ,
183186
184187 onInputChange : ( e : any ) => {
188+ setIDCHelperText ( 'Fill in the characters, the length is 0-1000.' ) ;
185189 changeValidate ( e . target . value , scopesForm [ 2 ] ) ;
186190 } ,
187191
@@ -197,7 +201,7 @@ export default function NewCluster() {
197201 name : 'cidrs' ,
198202 placeholder : 'Please enter CIDRs' ,
199203 error : cidrsError ,
200- helperText : cidrsError ? 'Fill in the characters, the length is 0-1000.' : '' ,
204+ helperText : cidrsError ? cidrsHelperText : '' ,
201205
202206 onKeyDown : ( e : any ) => {
203207 if ( e . keyCode === 13 ) {
@@ -412,6 +416,24 @@ export default function NewCluster() {
412416 const numberOfConcurrentDownloadPieces = event . currentTarget . elements . numberOfConcurrentDownloadPieces . value ;
413417 const candidateParentLimit = event . currentTarget . elements . candidateParentLimit . value ;
414418 const filterParentLimit = event . currentTarget . elements . filterParentLimit . value ;
419+ const idcText = event . currentTarget . elements . idc . value ;
420+ const cidrsText = event . currentTarget . elements . cidrs . value ;
421+
422+ if ( idcText ) {
423+ setIDCHelperText ( 'Please press ENTER to end the IDC creation' ) ;
424+ setIDCError ( true ) ;
425+ } else {
426+ setIDCError ( false ) ;
427+ setIDCHelperText ( 'Fill in the characters, the length is 0-100.' ) ;
428+ }
429+
430+ if ( cidrsText ) {
431+ setCIDRsHelperText ( 'Please press ENTER to end the CIDRs creation' ) ;
432+ setCIDRsError ( true ) ;
433+ } else {
434+ setCIDRsError ( false ) ;
435+ setCIDRsHelperText ( 'Fill in the characters, the length is 0-100.' ) ;
436+ }
415437
416438 informationForm . forEach ( ( item ) => {
417439 const value = data . get ( item . formProps . name ) ;
@@ -438,7 +460,9 @@ export default function NewCluster() {
438460 const canSubmit = Boolean (
439461 ! informationForm . filter ( ( item ) => item . syncError ) . length &&
440462 ! scopesForm . filter ( ( item ) => item . syncError ) . length &&
441- ! configForm . filter ( ( item ) => item . syncError ) . length ,
463+ ! configForm . filter ( ( item ) => item . syncError ) . length &&
464+ Boolean ( ! idcText ) &&
465+ Boolean ( ! cidrsText ) ,
442466 ) ;
443467
444468 const formData = {
0 commit comments