@@ -53,6 +53,7 @@ import {
53
53
RegistryIcon ,
54
54
ComponentSizeType ,
55
55
PasswordField ,
56
+ OtherRegistryAuthenticationType ,
56
57
} from '@devtron-labs/devtron-fe-common-lib'
57
58
import Tippy from '@tippyjs/react'
58
59
import { useHistory , useParams , useRouteMatch } from 'react-router-dom'
@@ -100,6 +101,7 @@ import { VALIDATION_STATUS, ValidateForm } from '../common/ValidateForm/Validate
100
101
const RegistryHelmPushCheckbox = importComponentFromFELibrary ( 'RegistryHelmPushCheckbox' )
101
102
const RemoteConnectionRadio = importComponentFromFELibrary ( 'RemoteConnectionRadio' )
102
103
const getRemoteConnectionConfig = importComponentFromFELibrary ( 'getRemoteConnectionConfig' , noop , 'function' )
104
+ const AuthenticationTypeRadio = importComponentFromFELibrary ( 'AuthenticationTypeRadio' , null , 'function' )
103
105
104
106
enum CERTTYPE {
105
107
SECURE = 'secure' ,
@@ -259,6 +261,7 @@ const CollapsedList = ({
259
261
repositoryList = [ ] ,
260
262
disabledFields = [ ] ,
261
263
ociRegistryConfig,
264
+ credentialsType,
262
265
...rest
263
266
} ) => {
264
267
const [ collapsed , toggleCollapse ] = useState ( true )
@@ -338,6 +341,7 @@ const CollapsedList = ({
338
341
isPublic,
339
342
disabledFields,
340
343
ociRegistryConfig,
344
+ credentialsType,
341
345
} }
342
346
/>
343
347
) }
@@ -377,6 +381,7 @@ const DockerForm = ({
377
381
: {
378
382
CONTAINER : OCIRegistryConfigConstants . PULL_PUSH ,
379
383
} ,
384
+ credentialsType : authCredentialsType ,
380
385
...rest
381
386
} ) => {
382
387
const re = PATTERNS . APP_NAME
@@ -539,6 +544,9 @@ const DockerForm = ({
539
544
const [ registryStorageType , setRegistryStorageType ] = useState < string > (
540
545
isPublic ? RegistryStorageType . OCI_PUBLIC : RegistryStorageType . OCI_PRIVATE ,
541
546
)
547
+ const [ authenticationType , setAuthenticationType ] = useState < OtherRegistryAuthenticationType > (
548
+ id ? authCredentialsType : OtherRegistryAuthenticationType . USERNAME_PASSWORD ,
549
+ )
542
550
543
551
const InitialValueOfIsContainerStore : boolean =
544
552
ociRegistryConfig ?. CONTAINER === OCIRegistryConfigConstants . PULL_PUSH
@@ -712,6 +720,11 @@ const DockerForm = ({
712
720
}
713
721
}
714
722
723
+ const handleChangeOtherRegistryAuthType = ( e ) => {
724
+ const updatedAuthType = e . target . value as OtherRegistryAuthenticationType
725
+ setAuthenticationType ( updatedAuthType )
726
+ }
727
+
715
728
function fetchAWSRegion ( ) : string {
716
729
const pattern =
717
730
registryStorageType === RegistryStorageType . OCI_PUBLIC
@@ -839,6 +852,9 @@ const DockerForm = ({
839
852
customState . remoteConnectionConfig . connectionMethod . value ,
840
853
sshConnectionType ,
841
854
) ,
855
+ ...( AuthenticationTypeRadio && selectedDockerRegistryType . value === RegistryType . OTHER
856
+ ? { credentialsType : authenticationType }
857
+ : { } ) ,
842
858
}
843
859
}
844
860
@@ -1003,6 +1019,7 @@ const DockerForm = ({
1003
1019
let error = false
1004
1020
if (
1005
1021
registryStorageType === RegistryStorageType . OCI_PRIVATE &&
1022
+ authenticationType === OtherRegistryAuthenticationType . USERNAME_PASSWORD &&
1006
1023
( ! customState . username . value || ! ( customState . password . value || id ) )
1007
1024
) {
1008
1025
setCustomState ( ( st ) => ( {
@@ -1605,13 +1622,25 @@ const DockerForm = ({
1605
1622
</ >
1606
1623
)
1607
1624
}
1625
+
1626
+ const isUserNamePasswordRequired =
1627
+ selectedDockerRegistryType . value === RegistryType . OTHER
1628
+ ? authenticationType === OtherRegistryAuthenticationType . USERNAME_PASSWORD
1629
+ : true
1630
+
1608
1631
return (
1609
1632
< >
1633
+ { AuthenticationTypeRadio && selectedDockerRegistryType . value === RegistryType . OTHER && (
1634
+ < AuthenticationTypeRadio
1635
+ authenticationType = { authenticationType }
1636
+ handleChangeOtherRegistryAuthType = { handleChangeOtherRegistryAuthType }
1637
+ />
1638
+ ) }
1610
1639
< div className = { `${ isGCROrGCP ? '' : 'form__row--two-third' } ` } >
1611
1640
< div className = "form__row" >
1612
1641
< CustomInput
1613
1642
name = "username"
1614
- required
1643
+ required = { isUserNamePasswordRequired }
1615
1644
value = { customState . username . value || selectedDockerRegistryType . id . defaultValue }
1616
1645
error = { customState . username . error }
1617
1646
onChange = { customHandleChange }
@@ -1632,7 +1661,7 @@ const DockerForm = ({
1632
1661
< PasswordField
1633
1662
shouldShowDefaultPlaceholderOnBlur = { ! ! id }
1634
1663
name = "password"
1635
- required
1664
+ required = { isUserNamePasswordRequired }
1636
1665
value = { customState . password . value }
1637
1666
error = { customState . password . error }
1638
1667
onChange = { customHandleChange }
0 commit comments