Skip to content

Commit 7b9428f

Browse files
committed
fix: state resetting to default in cipipeline
1 parent 1ca6918 commit 7b9428f

File tree

5 files changed

+10
-20
lines changed

5 files changed

+10
-20
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) {
@@ -265,7 +264,6 @@ export function Build({
265264
{isSecurityModuleInstalled && renderScanner()}
266265
<AdvancedConfigOptions
267266
ciPipeline={ciPipeline}
268-
setDockerConfigOverridden={setDockerConfigOverridden}
269267
/>
270268
</>
271269
)}

src/components/CIPipelineN/CIPipeline.tsx

Lines changed: 10 additions & 11 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(
@@ -367,7 +366,7 @@ export default function CIPipeline({
367366
}
368367
setPresetPlugins(_presetPlugin)
369368
setSharedPlugins(_sharedPlugin)
370-
getMandatoryPluginData(_formData, [..._presetPlugin, ..._sharedPlugin])
369+
getMandatoryPluginData(_formData, [..._presetPlugin, ..._sharedPlugin], true)
371370
})
372371
.catch((error: ServerErrors) => {
373372
showError(error)
@@ -383,7 +382,11 @@ 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+
referPrevState: boolean = false,
389+
): void => {
387390
if (!isJobCard && processPluginData && prepareFormData && pluginList.length) {
388391
let branchName = ''
389392
if (_formData?.materials?.length) {
@@ -398,7 +401,9 @@ export default function CIPipeline({
398401
processPluginData(_formData, pluginList, appId, ciPipelineId, branchName)
399402
.then((response: MandatoryPluginDataType) => {
400403
setMandatoryPluginData(response)
401-
if (_formData) {
404+
if (referPrevState) {
405+
setFormData((prevForm) => prepareFormData({ ...prevForm }, response?.pluginData ?? []))
406+
} else {
402407
setFormData(prepareFormData(_formData, response?.pluginData ?? []))
403408
}
404409
})
@@ -533,11 +538,6 @@ export default function CIPipeline({
533538

534539
const msg = ciPipeline.id ? 'Pipeline Updated' : 'Pipeline Created'
535540

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-
}
541541
//here we check for the case where the pipeline is multigit and user selects pullrequest or tag creation(webhook)
542542
//in that case we only send the webhook data not the other one.
543543
let _materials = formData.materials
@@ -813,7 +813,6 @@ export default function CIPipeline({
813813
isAdvanced={isAdvanced}
814814
ciPipeline={ciPipeline}
815815
isSecurityModuleInstalled={isSecurityModuleInstalled}
816-
setDockerConfigOverridden={setDockerConfigOverridden}
817816
isJobView={isJobCard}
818817
getPluginData={getPluginData}
819818
/>

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)