@@ -90,6 +90,7 @@ interface State {
9090 importLoading : boolean ;
9191 settingModal : { url ?: string ; uri ?: string ; show : boolean } ;
9292 repoURL : string ;
93+ isInvalid : boolean ;
9394 sortOption : SortOptionsValue ;
9495}
9596
@@ -109,11 +110,12 @@ class CodeProjectTab extends React.PureComponent<Props, State> {
109110 settingModal : { show : false } ,
110111 repoURL : '' ,
111112 sortOption : SortOptionsValue . alphabetical_asc ,
113+ isInvalid : false ,
112114 } ;
113115 }
114116
115117 public closeModal = ( ) => {
116- this . setState ( { showImportProjectModal : false , repoURL : '' } ) ;
118+ this . setState ( { showImportProjectModal : false , repoURL : '' , isInvalid : false } ) ;
117119 } ;
118120
119121 public openModal = ( ) => {
@@ -131,15 +133,22 @@ class CodeProjectTab extends React.PureComponent<Props, State> {
131133 public onChange = ( e : ChangeEvent < HTMLInputElement > ) => {
132134 this . setState ( {
133135 repoURL : e . target . value ,
136+ isInvalid : isImportRepositoryURLInvalid ( e . target . value ) ,
134137 } ) ;
135138 } ;
136139
137140 public submitImportProject = ( ) => {
138141 if ( ! isImportRepositoryURLInvalid ( this . state . repoURL ) ) {
139142 this . props . importRepo ( this . state . repoURL ) ;
143+ } else if ( ! this . state . isInvalid ) {
144+ this . setState ( { isInvalid : true } ) ;
140145 }
141146 } ;
142147
148+ public updateIsInvalid = ( ) => {
149+ this . setState ( { isInvalid : isImportRepositoryURLInvalid ( this . state . repoURL ) } ) ;
150+ } ;
151+
143152 public renderImportModal = ( ) => {
144153 return (
145154 < EuiOverlayMask >
@@ -152,19 +161,17 @@ class CodeProjectTab extends React.PureComponent<Props, State> {
152161 < h3 > Repository URL</ h3 >
153162 </ EuiTitle >
154163 < EuiForm >
155- < EuiFormRow
156- isInvalid = { isImportRepositoryURLInvalid ( this . state . repoURL ) }
157- error = "This field shouldn't be empty."
158- >
164+ < EuiFormRow isInvalid = { this . state . isInvalid } error = "This field shouldn't be empty." >
159165 < EuiFieldText
160166 value = { this . state . repoURL }
161167 onChange = { this . onChange }
168+ onBlur = { this . updateIsInvalid }
162169 placeholder = "https://github.com/elastic/elasticsearch"
163170 aria-label = "input project url"
164171 data-test-subj = "importRepositoryUrlInputBox"
165172 isLoading = { this . props . importLoading }
166173 fullWidth = { true }
167- isInvalid = { isImportRepositoryURLInvalid ( this . state . repoURL ) }
174+ isInvalid = { this . state . isInvalid }
168175 />
169176 </ EuiFormRow >
170177 </ EuiForm >
0 commit comments