Skip to content

Commit 3dc0ee3

Browse files
authored
Merge pull request #2661 from devtron-labs/chore/rename-credentials-key
feat: rename credentialType key to registryCredentialsType
2 parents 0fd7b03 + 01d955d commit 3dc0ee3

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

src/components/dockerRegistry/Docker.tsx

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import { KeyboardEventHandler, useEffect, useState } from 'react'
1818
import {
1919
showError,
2020
Progressing,
21-
TippyCustomized,
22-
TippyTheme,
2321
sortCallback,
2422
ErrorScreenNotAuthorized,
2523
Reload,
@@ -53,7 +51,7 @@ import {
5351
RegistryIcon,
5452
ComponentSizeType,
5553
PasswordField,
56-
OtherRegistryAuthenticationType,
54+
RegistryCredentialsType,
5755
} from '@devtron-labs/devtron-fe-common-lib'
5856
import Tippy from '@tippyjs/react'
5957
import { useHistory, useParams, useRouteMatch } from 'react-router-dom'
@@ -261,7 +259,7 @@ const CollapsedList = ({
261259
repositoryList = [],
262260
disabledFields = [],
263261
ociRegistryConfig,
264-
credentialsType,
262+
registryCredentialsType,
265263
...rest
266264
}) => {
267265
const [collapsed, toggleCollapse] = useState(true)
@@ -341,7 +339,7 @@ const CollapsedList = ({
341339
isPublic,
342340
disabledFields,
343341
ociRegistryConfig,
344-
credentialsType,
342+
registryCredentialsType,
345343
}}
346344
/>
347345
)}
@@ -381,7 +379,7 @@ const DockerForm = ({
381379
: {
382380
CONTAINER: OCIRegistryConfigConstants.PULL_PUSH,
383381
},
384-
credentialsType: authCredentialsType,
382+
registryCredentialsType,
385383
...rest
386384
}) => {
387385
const re = PATTERNS.APP_NAME
@@ -439,7 +437,7 @@ const DockerForm = ({
439437
registryUrl: { value: registryUrl, error: '' },
440438
username: { value: username, error: '' },
441439
password: {
442-
value: id && !password ? DEFAULT_SECRET_PLACEHOLDER : regPass,
440+
value: id && username && !password ? DEFAULT_SECRET_PLACEHOLDER : regPass,
443441
error: '',
444442
},
445443
repositoryList: {
@@ -544,8 +542,8 @@ const DockerForm = ({
544542
const [registryStorageType, setRegistryStorageType] = useState<string>(
545543
isPublic ? RegistryStorageType.OCI_PUBLIC : RegistryStorageType.OCI_PRIVATE,
546544
)
547-
const [authenticationType, setAuthenticationType] = useState<OtherRegistryAuthenticationType>(
548-
id && authCredentialsType ? authCredentialsType : OtherRegistryAuthenticationType.USERNAME_PASSWORD,
545+
const [authenticationType, setAuthenticationType] = useState<RegistryCredentialsType>(
546+
id && registryCredentialsType ? registryCredentialsType : RegistryCredentialsType.USERNAME_PASSWORD,
549547
)
550548

551549
const InitialValueOfIsContainerStore: boolean =
@@ -721,7 +719,7 @@ const DockerForm = ({
721719
}
722720

723721
const handleChangeOtherRegistryAuthType = (e) => {
724-
const updatedAuthType = e.target.value as OtherRegistryAuthenticationType
722+
const updatedAuthType = e.target.value as RegistryCredentialsType
725723
setAuthenticationType(updatedAuthType)
726724
}
727725

@@ -818,7 +816,7 @@ const DockerForm = ({
818816
...(registryStorageType !== RegistryStorageType.OCI_PUBLIC &&
819817
selectedDockerRegistryType.value === RegistryType.OTHER
820818
? {
821-
...(authenticationType === OtherRegistryAuthenticationType.USERNAME_PASSWORD
819+
...(authenticationType === RegistryCredentialsType.USERNAME_PASSWORD
822820
? {
823821
username: trimmedUsername,
824822
password: parsePassword(customState.password.value),
@@ -857,7 +855,7 @@ const DockerForm = ({
857855
sshConnectionType,
858856
),
859857
...(AuthenticationTypeRadio && selectedDockerRegistryType.value === RegistryType.OTHER
860-
? { credentialsType: authenticationType }
858+
? { registryCredentialsType: authenticationType }
861859
: {}),
862860
}
863861
}
@@ -1023,13 +1021,13 @@ const DockerForm = ({
10231021
let error = false
10241022
if (
10251023
registryStorageType === RegistryStorageType.OCI_PRIVATE &&
1026-
authenticationType === OtherRegistryAuthenticationType.USERNAME_PASSWORD &&
1027-
(!customState.username.value || !(customState.password.value || id))
1024+
authenticationType === RegistryCredentialsType.USERNAME_PASSWORD &&
1025+
(!customState.username.value || !(customState.password.value || (id && username)))
10281026
) {
10291027
setCustomState((st) => ({
10301028
...st,
10311029
username: { ...st.username, error: st.username.value ? '' : 'Mandatory' },
1032-
password: { ...st.password, error: id || st.password.value ? '' : 'Mandatory' },
1030+
password: { ...st.password, error: (id && username) || st.password.value ? '' : 'Mandatory' },
10331031
}))
10341032
error = true
10351033
}
@@ -1629,7 +1627,7 @@ const DockerForm = ({
16291627

16301628
const isUserNamePasswordRequired =
16311629
selectedDockerRegistryType.value === RegistryType.OTHER
1632-
? authenticationType === OtherRegistryAuthenticationType.USERNAME_PASSWORD
1630+
? authenticationType === RegistryCredentialsType.USERNAME_PASSWORD
16331631
: true
16341632

16351633
return (
@@ -1664,7 +1662,7 @@ const DockerForm = ({
16641662
selectedDockerRegistryType.value === RegistryType.QUAY ||
16651663
selectedDockerRegistryType.value === RegistryType.OTHER) && (
16661664
<PasswordField
1667-
shouldShowDefaultPlaceholderOnBlur={!!id}
1665+
shouldShowDefaultPlaceholderOnBlur={!!id && !!username}
16681666
name="password"
16691667
required
16701668
value={customState.password.value}

src/config/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
ToastManager,
2222
ROUTES as COMMON_ROUTES,
2323
EnvResourceType,
24-
OtherRegistryAuthenticationType,
24+
RegistryCredentialsType,
2525
} from '@devtron-labs/devtron-fe-common-lib'
2626
export const DEFAULT_STATUS = 'checking'
2727
export const DEFAULT_STATUS_TEXT = 'Checking Status'
@@ -544,7 +544,7 @@ export interface RegistryPayloadType {
544544
sshAuthKey: string
545545
}
546546
}
547-
credentialsType?: OtherRegistryAuthenticationType
547+
registryCredentialsType?: RegistryCredentialsType
548548
}
549549

550550
export interface RegistryPayloadWithSelectType extends RegistryPayloadType, SelectPickerOptionType {}

0 commit comments

Comments
 (0)