@@ -7,11 +7,15 @@ import {
77 Tag ,
88 Elevation ,
99 Popover ,
10+ // PopoverInteractionKind,
1011 Position ,
11- Intent
12+ Intent ,
13+ PopoverInteractionKind
1214} from '@blueprintjs/core'
1315import { Providers } from '@/data/Providers'
1416import GenerateTokenForm from '@/pages/configure/connections/GenerateTokenForm'
17+ import FormValidationErrors from '@/components/messages/FormValidationErrors'
18+ import InputValidationError from '@/components/validation/InputValidationError'
1519
1620import '@/styles/integration.scss'
1721import '@/styles/connections.scss'
@@ -20,6 +24,7 @@ export default function ConnectionForm (props) {
2024 const {
2125 isLocked = false ,
2226 isValid = true ,
27+ validationErrors = [ ] ,
2328 activeProvider,
2429 name,
2530 endpointUrl,
@@ -83,6 +88,14 @@ export default function ConnectionForm (props) {
8388 setShowTokenCreator ( isOpen )
8489 }
8590
91+ const fieldHasError = ( fieldId ) => {
92+ return validationErrors . some ( e => e . includes ( fieldId ) )
93+ }
94+
95+ const getFieldError = ( fieldId ) => {
96+ return validationErrors . find ( e => e . includes ( fieldId ) )
97+ }
98+
8699 useEffect ( ( ) => {
87100 if ( ! allowedAuthTypes . includes ( authType ) ) {
88101 console . log ( 'INVALID AUTH TYPE!' )
@@ -158,10 +171,10 @@ export default function ConnectionForm (props) {
158171 label = ''
159172 inline = { true }
160173 labelFor = 'connection-name'
161- className = 'formGroup'
174+ className = 'formGroup-inline '
162175 contentClassName = 'formGroupContent'
163176 >
164- < Label style = { { display : 'inline' } } >
177+ < Label style = { { display : 'inline' , marginRight : 0 } } >
165178 { labels
166179 ? labels . name
167180 : (
@@ -176,9 +189,15 @@ export default function ConnectionForm (props) {
176189 placeholder = { placeholders ? placeholders . name : 'Enter Instance Name' }
177190 value = { name }
178191 onChange = { ( e ) => onNameChange ( e . target . value ) }
179- className = ' input connection-name-input'
192+ className = { ` input connection-name-input ${ fieldHasError ( 'Connection Source' ) ? 'invalid-field' : '' } ` }
180193 leftIcon = { [ Providers . GITHUB , Providers . GITLAB , Providers . JENKINS ] . includes ( activeProvider . id ) ? 'lock' : null }
181- fill
194+ inline = { true }
195+ rightElement = { (
196+ < InputValidationError
197+ error = { getFieldError ( 'Connection Source' ) }
198+ />
199+ ) }
200+ // fill
182201 />
183202 </ FormGroup >
184203 </ div >
@@ -206,8 +225,13 @@ export default function ConnectionForm (props) {
206225 placeholder = { placeholders ? placeholders . endpoint : 'Enter Endpoint URL' }
207226 value = { endpointUrl }
208227 onChange = { ( e ) => onEndpointChange ( e . target . value ) }
209- className = ' input'
228+ className = { ` input endpoint-url-input ${ fieldHasError ( 'Endpoint' ) ? 'invalid-field' : '' } ` }
210229 fill
230+ rightElement = { (
231+ < InputValidationError
232+ error = { getFieldError ( 'Endpoint' ) }
233+ />
234+ ) }
211235 />
212236 { /* <a href='#' style={{ margin: '5px 0 5px 5px' }}><Icon icon='info-sign' size='16' /></a> */ }
213237 </ FormGroup >
@@ -237,9 +261,14 @@ export default function ConnectionForm (props) {
237261 placeholder = { placeholders ? placeholders . token : 'Enter Auth Token eg. EJrLG8DNeXADQcGOaaaX4B47' }
238262 value = { token }
239263 onChange = { ( e ) => onTokenChange ( e . target . value ) }
240- className = ' input'
264+ className = { ` input auth-input ${ fieldHasError ( 'Auth' ) ? 'invalid-field' : '' } ` }
241265 fill
242266 required
267+ rightElement = { (
268+ < InputValidationError
269+ error = { getFieldError ( 'Auth' ) }
270+ />
271+ ) }
243272 />
244273 {
245274 activeProvider . id === Providers . JIRA &&
@@ -305,8 +334,13 @@ export default function ConnectionForm (props) {
305334 placeholder = 'Enter Username'
306335 defaultValue = { username }
307336 onChange = { ( e ) => onUsernameChange ( e . target . value ) }
308- className = 'input'
309- style = { { maxWidth : '300px' } }
337+ className = { `input username-input ${ fieldHasError ( 'Username' ) ? 'invalid-field' : '' } ` }
338+ // style={{ maxWidth: '300px' }}
339+ rightElement = { (
340+ < InputValidationError
341+ error = { getFieldError ( 'Username' ) }
342+ />
343+ ) }
310344 />
311345 </ FormGroup >
312346 </ div >
@@ -334,8 +368,13 @@ export default function ConnectionForm (props) {
334368 placeholder = 'Enter Password'
335369 defaultValue = { password }
336370 onChange = { ( e ) => onPasswordChange ( e . target . value ) }
337- className = 'input'
338- style = { { maxWidth : '300px' } }
371+ className = { `input password-input ${ fieldHasError ( 'Password' ) ? 'invalid-field' : '' } ` }
372+ // style={{ maxWidth: '300px' }}
373+ rightElement = { (
374+ < InputValidationError
375+ error = { getFieldError ( 'Password' ) }
376+ />
377+ ) }
339378 />
340379 </ FormGroup >
341380 </ div >
@@ -363,7 +402,12 @@ export default function ConnectionForm (props) {
363402 defaultValue = { proxy }
364403 onChange = { ( e ) => onProxyChange ( e . target . value ) }
365404 disabled = { isTesting || isSaving || isLocked }
366- className = 'input'
405+ className = { `input input-proxy ${ fieldHasError ( 'Proxy' ) ? 'invalid-field' : '' } ` }
406+ rightElement = { (
407+ < InputValidationError
408+ error = { getFieldError ( 'Proxy' ) }
409+ />
410+ ) }
367411 />
368412 </ FormGroup >
369413 </ div >
@@ -383,6 +427,14 @@ export default function ConnectionForm (props) {
383427 />
384428 </ div >
385429 < div style = { { display : 'flex' } } >
430+ < div style = { { justifyContent : 'center' , padding : '8px' } } >
431+ { validationErrors . length > 0 && (
432+ < Popover interactionKind = { PopoverInteractionKind . HOVER_TARGET_ONLY } >
433+ < Icon icon = 'warning-sign' size = { 16 } color = { Colors . RED5 } style = { { outline : 'none' } } />
434+ < div style = { { padding : '5px' } } > < FormValidationErrors errors = { validationErrors } /> </ div >
435+ </ Popover >
436+ ) }
437+ </ div >
386438 < Button className = 'btn-cancel' icon = 'remove' text = 'Cancel' onClick = { onCancel } disabled = { isSaving || isTesting } />
387439 < Button
388440 className = 'btn-save'
0 commit comments