Skip to content

Commit d196c95

Browse files
committed
fix: Isse in build context
1 parent 6d5ecfa commit d196c95

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

src/components/ciConfig/BuildContext.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@
1717
// Disabling for ReactSelect
1818
/* eslint-disable jsx-a11y/label-has-associated-control */
1919
import { FunctionComponent, useEffect, useState } from 'react'
20-
import { CustomInput, OptionType, InfoIconTippy, SelectPicker } from '@devtron-labs/devtron-fe-common-lib'
20+
import {
21+
CustomInput,
22+
OptionType,
23+
InfoIconTippy,
24+
SelectPicker,
25+
ComponentSizeType,
26+
} from '@devtron-labs/devtron-fe-common-lib'
2127
import { renderOptionIcon } from './CIBuildpackBuildOptions'
2228
import { BuildContextProps } from './types'
2329
import { ReactComponent as Dropdown } from '../../assets/icons/ic-chevron-down.svg'
@@ -178,6 +184,7 @@ const BuildContext: FunctionComponent<BuildContextProps> = ({
178184
options={sourceConfig.material}
179185
value={getSelectedBuildContextGitMaterial()}
180186
onChange={handleBuildContextPathChange}
187+
size={ComponentSizeType.large}
181188
/>
182189

183190
{repositoryError && <label className="form__error">{repositoryError}</label>}
@@ -199,6 +206,7 @@ const BuildContext: FunctionComponent<BuildContextProps> = ({
199206
getOptionValue={(option) => `${option.value}`}
200207
value={getCheckoutPathValue(useRootBuildContextFlag)}
201208
onChange={handleBuildContextCheckoutPathChange}
209+
size={ComponentSizeType.large}
202210
/>
203211

204212
<CustomInput

src/components/ciConfig/CIConfig.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
import React, { useState, useEffect } from 'react'
1818
import { showError, Progressing } from '@devtron-labs/devtron-fe-common-lib'
1919
import { useParams } from 'react-router-dom'
20-
import { sortObjectArrayAlphabetically } from '../common'
20+
import { getGitProviderIcon, sortObjectArrayAlphabetically } from '../common'
2121
import { getDockerRegistryMinAuth } from './service'
2222
import { getSourceConfig, getCIConfig } from '../../services/service'
2323
import { ComponentStates } from '../../Pages/Shared/EnvironmentOverride/EnvironmentOverrides.types'
24-
import { CIConfigProps } from './types'
24+
import { CIConfigProps, MaterialOptionType } from './types'
2525
import './CIConfig.scss'
2626
import CIConfigForm from './CIConfigForm'
2727

@@ -53,6 +53,7 @@ export default function CIConfig({
5353
}
5454
}, [])
5555

56+
5657
async function initialise() {
5758
try {
5859
setLoading(true)
@@ -66,7 +67,18 @@ export default function CIConfig({
6667
sourceConfig &&
6768
Array.isArray(sourceConfig.material) &&
6869
sortObjectArrayAlphabetically(sourceConfig.material, 'name')
69-
setSourceConfig(sourceConfig)
70+
const _sourceConfig = { ...sourceConfig }
71+
const sourceConfigMaterial = sourceConfig.material?.map((material: MaterialOptionType) => {
72+
console.log(material)
73+
return {
74+
...material,
75+
label: material?.name,
76+
value: material?.id,
77+
startIcon: getGitProviderIcon(material.url),
78+
}
79+
})
80+
_sourceConfig.material = sourceConfigMaterial
81+
setSourceConfig(_sourceConfig)
7082
setCIConfig(ciConfig)
7183

7284
if (setParentState) {

src/components/ciConfig/CICreateDockerfileOption.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import CreateDockerFileLanguageOptions from './CreateDockerFileLanguageOptions'
2121
import BuildContext from './BuildContext'
2222
import { RootBuildContext } from './ciConfigConstant'
2323
import { CICreateDockerfileOptionProps, FrameworkOptionType, LanguageOptionType, TemplateDataType } from './types'
24-
import { getGitProviderIcon } from '@Components/common'
2524
import { getSelectStartIcon } from './utils'
2625

2726
export default function CICreateDockerfileOption({

src/components/common/helpers/utils.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export const swap = (array: any[], indexA: number, indexB: number) => {
7575

7676
export const getGitProviderIcon = (gitUrl: string): JSX.Element => {
7777
let IconComponent: React.ElementType = Git // Using React.ElementType for any JSX component
78-
78+
if(!gitUrl) return null
7979
if (gitUrl.includes('gitlab')) {
8080
IconComponent = GitLab
8181
} else if (gitUrl.includes('github')) {

0 commit comments

Comments
 (0)