Skip to content

Commit c3a1298

Browse files
Merge pull request #1520 from devtron-labs/fix/ci-pipeline-override
fix: state resetting to default in cipipeline
2 parents ff5e786 + f6aa7c4 commit c3a1298

File tree

5 files changed

+6
-21
lines changed

5 files changed

+6
-21
lines changed

src/components/CIPipelineN/AdvancedConfigOptions.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { ReactComponent as Add } from '../../assets/icons/ic-add.svg'
44
import { ReactComponent as QuestionIcon } from '../v2/assets/icons/ic-question.svg'
55
import { ReactComponent as HelpIcon } from '../../assets/icons/ic-help.svg'
66
import CIConfig from '../ciConfig/CIConfig'
7-
import { deepEqual } from '../common'
87
import { ComponentStates } from '../EnvironmentOverride/EnvironmentOverrides.type'
98
import { AdvancedConfigOptionsProps, CIConfigParentState } from '../ciConfig/types'
109
import { DockerConfigOverrideKeys } from '../ciPipeline/types'
@@ -18,7 +17,6 @@ import { pipelineContext } from '../workflowEditor/workflowEditor'
1817

1918
export default function AdvancedConfigOptions({
2019
ciPipeline,
21-
setDockerConfigOverridden,
2220
}: AdvancedConfigOptionsProps) {
2321
const {
2422
formData,
@@ -151,9 +149,6 @@ export default function AdvancedConfigOptions({
151149

152150
// set updated form data
153151
setFormData(_form)
154-
155-
// Check for diff in global & current CI config and set isDockerConfigOverridden flag accordingly
156-
setDockerConfigOverridden(!deepEqual(_form.dockerConfigOverride, parentState.defaultDockerConfigs))
157152
}
158153

159154
const renderDockerArgs = () => {

src/components/CIPipelineN/Build.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export function Build({
1616
ciPipeline,
1717
pageState,
1818
isSecurityModuleInstalled,
19-
setDockerConfigOverridden,
2019
isJobView,
2120
getPluginData,
2221
}: BuildType) {
@@ -261,7 +260,6 @@ export function Build({
261260
{isSecurityModuleInstalled && renderScanner()}
262261
<AdvancedConfigOptions
263262
ciPipeline={ciPipeline}
264-
setDockerConfigOverridden={setDockerConfigOverridden}
265263
/>
266264
</>
267265
)}

src/components/CIPipelineN/CIPipeline.tsx

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
VisibleModal,
1515
Drawer,
1616
DeleteDialog,
17-
DockerConfigOverrideType,
1817
RefVariableType,
1918
VariableType,
2019
MandatoryPluginDataType,
@@ -179,7 +178,6 @@ export default function CIPipeline({
179178
},
180179
})
181180
const validationRules = new ValidationRules()
182-
const [isDockerConfigOverridden, setDockerConfigOverridden] = useState(false)
183181
const [mandatoryPluginData, setMandatoryPluginData] = useState<MandatoryPluginDataType>(null)
184182
const selectedBranchRef = useRef(null)
185183

@@ -285,6 +283,7 @@ export default function CIPipeline({
285283
setPageState(ViewType.LOADING)
286284
getSecurityModuleStatus()
287285
if (ciPipelineId) {
286+
// TODO: Would need to add loader for getAvailablePlugins to avoid state toggle
288287
getInitDataWithCIPipeline(appId, ciPipelineId, true)
289288
.then((ciResponse) => {
290289
const preBuildVariable = calculateLastStepDetail(
@@ -383,7 +382,10 @@ export default function CIPipeline({
383382
} catch (error) {}
384383
}
385384

386-
const getMandatoryPluginData = (_formData: PipelineFormType, pluginList: PluginDetailType[]): void => {
385+
const getMandatoryPluginData = (
386+
_formData: PipelineFormType,
387+
pluginList: PluginDetailType[],
388+
): void => {
387389
if (!isJobCard && processPluginData && prepareFormData && pluginList.length) {
388390
let branchName = ''
389391
if (_formData?.materials?.length) {
@@ -398,9 +400,7 @@ export default function CIPipeline({
398400
processPluginData(_formData, pluginList, appId, ciPipelineId, branchName)
399401
.then((response: MandatoryPluginDataType) => {
400402
setMandatoryPluginData(response)
401-
if (_formData) {
402-
setFormData(prepareFormData(_formData, response?.pluginData ?? []))
403-
}
403+
setFormData((prevForm) => prepareFormData({ ...prevForm }, response?.pluginData ?? []))
404404
})
405405
.catch((error: ServerErrors) => {
406406
showError(error)
@@ -533,11 +533,6 @@ export default function CIPipeline({
533533

534534
const msg = ciPipeline.id ? 'Pipeline Updated' : 'Pipeline Created'
535535

536-
// Reset allow override flag to false if config matches with global
537-
if (!ciPipeline.isDockerConfigOverridden && !isDockerConfigOverridden) {
538-
formData.isDockerConfigOverridden = false
539-
formData.dockerConfigOverride = {} as DockerConfigOverrideType
540-
}
541536
//here we check for the case where the pipeline is multigit and user selects pullrequest or tag creation(webhook)
542537
//in that case we only send the webhook data not the other one.
543538
let _materials = formData.materials
@@ -813,7 +808,6 @@ export default function CIPipeline({
813808
isAdvanced={isAdvanced}
814809
ciPipeline={ciPipeline}
815810
isSecurityModuleInstalled={isSecurityModuleInstalled}
816-
setDockerConfigOverridden={setDockerConfigOverridden}
817811
isJobView={isJobCard}
818812
getPluginData={getPluginData}
819813
/>

src/components/ciConfig/types.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ export interface CIConfigFormProps {
127127

128128
export interface AdvancedConfigOptionsProps {
129129
ciPipeline: CIPipelineDataType
130-
setDockerConfigOverridden: React.Dispatch<React.SetStateAction<boolean>>
131130
}
132131

133132
interface LanguageBuilderType {

src/components/ciPipeline/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,6 @@ export interface BuildType {
388388
ciPipeline: CIPipelineDataType
389389
pageState: string
390390
isSecurityModuleInstalled: boolean
391-
setDockerConfigOverridden: React.Dispatch<React.SetStateAction<boolean>>
392391
isJobView?: boolean
393392
getPluginData: (_formData?: PipelineFormType) => void
394393
}

0 commit comments

Comments
 (0)