@@ -3,7 +3,6 @@ import { useSelector } from 'react-redux'
33import { FormikProps } from 'formik'
44
55import {
6- EuiFieldNumber ,
76 EuiFieldText ,
87 EuiIcon ,
98 EuiToolTip ,
@@ -17,13 +16,11 @@ import {
1716 MAX_TIMEOUT_NUMBER ,
1817 selectOnFocus ,
1918 validateField ,
20- validatePortNumber ,
21- validateTimeoutNumber ,
2219} from 'uiSrc/utils'
2320import { DbConnectionInfo } from 'uiSrc/pages/home/interfaces'
2421import { FlexItem , Row } from 'uiSrc/components/base/layout/flex'
2522import { FormField } from 'uiSrc/components/base/forms/FormField'
26- import { PasswordInput } from 'uiSrc/components/base/inputs'
23+ import { NumericInput , PasswordInput } from 'uiSrc/components/base/inputs'
2724
2825interface IShowFields {
2926 alias : boolean
@@ -146,25 +143,22 @@ const DatabaseForm = (props: Props) => {
146143 ) }
147144 { isShowPort && (
148145 < FlexItem grow = { 2 } >
149- < FormField label = "Port*" additionalText = "Should not exceed 65535." >
150- < EuiFieldNumber
146+ < FormField
147+ label = "Port*"
148+ additionalText = { `Should not exceed ${ MAX_PORT_NUMBER } .` }
149+ >
150+ < NumericInput
151+ autoValidate
151152 name = "port"
152153 id = "port"
153154 data-testid = "port"
154- style = { { width : '100%' } }
155155 placeholder = "Enter Port"
156- value = { formik . values . port ?? '' }
157- maxLength = { 6 }
158- onChange = { ( e : ChangeEvent < HTMLInputElement > ) => {
159- formik . setFieldValue (
160- e . target . name ,
161- validatePortNumber ( e . target . value . trim ( ) ) ,
162- )
163- } }
164- onFocus = { selectOnFocus }
165- type = "text"
156+ onChange = { ( value ) => formik . setFieldValue ( 'port' , value ) }
157+ defaultValue = { 6379 }
158+ value = { Number ( formik . values . port ) }
166159 min = { 0 }
167160 max = { MAX_PORT_NUMBER }
161+ onFocus = { selectOnFocus }
168162 disabled = { isFieldDisabled ( 'port' ) }
169163 />
170164 </ FormField >
@@ -220,24 +214,17 @@ const DatabaseForm = (props: Props) => {
220214 < Row gap = "m" responsive >
221215 < FlexItem grow >
222216 < FormField label = "Timeout (s)" >
223- < EuiFieldNumber
217+ < NumericInput
218+ autoValidate
224219 name = "timeout"
225220 id = "timeout"
226221 data-testid = "timeout"
227- style = { { width : '100%' } }
228222 placeholder = "Enter Timeout (in seconds)"
229- value = { formik . values . timeout ?? '' }
230- maxLength = { 7 }
231- onChange = { ( e : ChangeEvent < HTMLInputElement > ) => {
232- formik . setFieldValue (
233- e . target . name ,
234- validateTimeoutNumber ( e . target . value . trim ( ) ) ,
235- )
236- } }
237- onFocus = { selectOnFocus }
238- type = "text"
223+ onChange = { ( value ) => formik . setFieldValue ( 'timeout' , value ) }
224+ value = { Number ( formik . values . timeout ) }
239225 min = { 1 }
240226 max = { MAX_TIMEOUT_NUMBER }
227+ onFocus = { selectOnFocus }
241228 disabled = { isFieldDisabled ( 'timeout' ) }
242229 />
243230 </ FormField >
0 commit comments