Skip to content

Commit 770657e

Browse files
Merge pull request #1571 from devtron-labs/fix(ci-pipeline)/config-diff-linked-redirection
fix: config diff linked redirection
2 parents a618cf3 + 1e836a6 commit 770657e

File tree

3 files changed

+35
-12
lines changed

3 files changed

+35
-12
lines changed

src/components/ciConfig/CIConfigDiffView.tsx

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@ import {
77
noop,
88
DockerConfigOverrideType,
99
Reload,
10+
WorkflowNodeType,
1011
} from '@devtron-labs/devtron-fe-common-lib'
1112
import { ReactComponent as CloseIcon } from '../../assets/icons/ic-cross.svg'
1213
import { ReactComponent as EditIcon } from '../../assets/icons/ic-pencil.svg'
1314
import { ReactComponent as DeleteIcon } from '../../assets/icons/ic-delete-interactive.svg'
1415
import { Workflow } from '../workflowEditor/Workflow'
1516
import { Link, useHistory, useLocation, useParams, useRouteMatch } from 'react-router-dom'
1617
import { URLS } from '../../config'
17-
import { CIConfigDiffViewProps, ProcessedWorkflowsType } from './types'
18-
import { WorkflowType } from '../app/details/triggerView/types'
18+
import { CIConfigDiffViewProps, GetCIPipelineModalURLType, ProcessedWorkflowsType } from './types'
19+
import { NodeAttr, WorkflowType } from '../app/details/triggerView/types'
1920
import { CIBuildConfigDiff } from './CIBuildConfigDiff'
2021
import Tippy from '@tippyjs/react'
2122
import { getInitDataWithCIPipeline, saveCIPipeline } from '../ciPipeline/ciPipeline.service'
@@ -24,6 +25,7 @@ import { ConfigOverrideWorkflowDetails } from '../../services/service.types'
2425
import { getConfigOverrideWorkflowDetails, getWorkflowList } from '../../services/service'
2526
import { WorkflowCreate } from '../app/details/triggerView/config'
2627
import { processWorkflow } from '../app/details/triggerView/workflow.service'
28+
import { getLinkedCIPipelineURL } from '../common'
2729

2830
export default function CIConfigDiffView({
2931
parentReloading,
@@ -114,7 +116,28 @@ export default function CIConfigDiffView({
114116
)
115117
}
116118

117-
const renderViewBuildPipelineRow = (_wfId: number): JSX.Element => {
119+
const getCIPipelineModalURL = ({ ciNode, workflowId }: GetCIPipelineModalURLType): string => {
120+
if (!ciNode) {
121+
toast.error('Invalid Pipeline')
122+
return
123+
}
124+
125+
if (ciNode.isLinkedCI) {
126+
return `${URLS.APP}/${appId}/${URLS.APP_CONFIG}/${URLS.APP_WORKFLOW_CONFIG}/${getLinkedCIPipelineURL(
127+
appId,
128+
workflowId,
129+
ciNode.id,
130+
)}`
131+
}
132+
133+
return `${URLS.APP}/${appId}/${URLS.APP_CONFIG}/${URLS.APP_WORKFLOW_CONFIG}/${workflowId}/${
134+
URLS.APP_CI_CONFIG
135+
}/${wfCIMap.get(workflowId)}/build`
136+
}
137+
138+
const renderViewBuildPipelineRow = (_wfId: number, nodes: NodeAttr[]): JSX.Element => {
139+
const ciNode = nodes?.find((node) => node.type == WorkflowNodeType.CI)
140+
118141
return (
119142
<div
120143
className="flex dc__position-abs dc__content-space"
@@ -124,12 +147,7 @@ export default function CIConfigDiffView({
124147
}}
125148
>
126149
<Tippy className="default-tt" arrow={false} placement="top" content="Edit override">
127-
<Link
128-
to={`${URLS.APP}/${appId}/${URLS.APP_CONFIG}/${URLS.APP_WORKFLOW_CONFIG}/${_wfId}/${
129-
URLS.APP_CI_CONFIG
130-
}/${wfCIMap.get(_wfId)}/build`}
131-
className="flex mr-16"
132-
>
150+
<Link to={getCIPipelineModalURL({ ciNode, workflowId: _wfId })} className="flex mr-16">
133151
<EditIcon className="icon-dim-24" />
134152
</Link>
135153
</Tippy>
@@ -249,7 +267,7 @@ export default function CIConfigDiffView({
249267
addWebhookCD={noop}
250268
cdWorkflowList={_configOverridenWorkflows}
251269
/>
252-
{renderViewBuildPipelineRow(+_wf.id)}
270+
{renderViewBuildPipelineRow(+_wf.id, _wf.nodes)}
253271
<CIBuildConfigDiff
254272
configOverridenWorkflows={_configOverridenWorkflows}
255273
wfId={_wf.id}

src/components/ciConfig/CIDockerFileConfig.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export default function CIDockerFileConfig({
7878
!currentOverriddenBuildContext
7979

8080
const isSameGlobalBuildContext =
81-
currentMaterial.id === currentBuildContextGitMaterial.id &&
81+
currentMaterial?.id === currentBuildContextGitMaterial?.id &&
8282
!ciConfig?.ciBuildConfig?.dockerBuildConfig?.buildContext
8383

8484
return configOverrideView && allowOverride

src/components/ciConfig/types.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from '@devtron-labs/devtron-fe-common-lib'
1212
import { ConfigOverrideWorkflowDetails } from '../../services/service.types'
1313
import { CustomNavItemsType } from '../app/details/appConfig/appConfig.type'
14-
import { CiPipeline, CiPipelineResult, Material, WorkflowType } from '../app/details/triggerView/types'
14+
import { CiPipeline, CiPipelineResult, Material, NodeAttr, WorkflowType } from '../app/details/triggerView/types'
1515
import { OptionType } from '../app/types'
1616
import { CIPipelineDataType } from '../ciPipeline/types'
1717
import { ComponentStates } from '../EnvironmentOverride/EnvironmentOverrides.type'
@@ -416,3 +416,8 @@ export interface ResetEditorChangesProps {
416416
editorData: TemplateDataType
417417
editorValue: string
418418
}
419+
420+
export interface GetCIPipelineModalURLType {
421+
ciNode: NodeAttr
422+
workflowId: number
423+
}

0 commit comments

Comments
 (0)