Skip to content

Commit 2915791

Browse files
Merge branch 'app_env_filter' of https://github.com/devtron-labs/dashboard into feat/modal-app-details-env-filter
2 parents ccfef8a + 5656a94 commit 2915791

File tree

11 files changed

+104
-52
lines changed

11 files changed

+104
-52
lines changed

src/components/app/details/appConfig/AppConfig.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export default function AppConfig({ appName, isJobView, filteredEnvIds }: AppCon
8989
useEffect(() => {
9090
Promise.all([
9191
getAppConfigStatus(+appId, isJobView),
92-
getWorkflowList(appId, filteredEnvIds),
92+
getWorkflowList(appId),
9393
getAppOtherEnvironmentMin(appId),
9494
typeof getConfigProtections === 'function' && !isJobView
9595
? getConfigProtections(Number(appId))

src/components/app/details/triggerView/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ export interface Tree {
417417
componentId: number
418418
parentId: number
419419
parentType: PipelineType
420+
isLast?: boolean
420421
}
421422

422423
export interface Workflow {

src/components/app/details/triggerView/workflow.service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ export function processWorkflow(
193193
cdPipeline.parentPipelineType = branch.parentType
194194
}
195195

196-
const cdNode = cdPipelineToNode(cdPipeline, dimensions, branch.parentId)
196+
const cdNode = cdPipelineToNode(cdPipeline, dimensions, branch.parentId, branch.isLast)
197197
wf.nodes.push(cdNode)
198198

199199
if (cdPipeline.userApprovalConfig?.requiredCount > 0) {
@@ -498,7 +498,7 @@ function webhookToNode(webhookDetails: WebhookDetailsType, dimensions: WorkflowD
498498
} as NodeAttr
499499
}
500500

501-
function cdPipelineToNode(cdPipeline: CdPipeline, dimensions: WorkflowDimensions, parentId: number): NodeAttr {
501+
function cdPipelineToNode(cdPipeline: CdPipeline, dimensions: WorkflowDimensions, parentId: number, isLast: boolean): NodeAttr {
502502
let trigger = cdPipeline.triggerType?.toLowerCase() ?? ''
503503
let preCD: NodeAttr | undefined = undefined,
504504
postCD: NodeAttr | undefined = undefined
@@ -575,6 +575,7 @@ function cdPipelineToNode(cdPipeline: CdPipeline, dimensions: WorkflowDimensions
575575
isVirtualEnvironment: cdPipeline.isVirtualEnvironment,
576576
deploymentAppType: cdPipeline.deploymentAppType,
577577
helmPackageName: cdPipeline?.helmPackageName || '',
578+
isLast: isLast
578579
} as NodeAttr
579580
stageIndex++
580581

src/components/cdPipeline/NewCDPipeline.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ export default function NewCDPipeline({
6464
location,
6565
appName,
6666
close,
67-
downstreamNodeSize,
6867
getWorkflows,
6968
refreshParentWorkflows,
7069
envIds,
70+
isLastNode
7171
}) {
7272
const isCdPipeline = true
7373
const urlParams = new URLSearchParams(location.search)
@@ -706,7 +706,7 @@ export default function NewCDPipeline({
706706
const request = responseCode()
707707

708708
const _form = { ...formData }
709-
709+
710710
let promise = cdPipelineId ? updateCDPipeline(request) : saveCDPipeline(request)
711711
promise
712712
.then((response) => {
@@ -897,9 +897,9 @@ export default function NewCDPipeline({
897897

898898
const renderSecondaryButton = () => {
899899
if (cdPipelineId) {
900-
let canDeletePipeline = downstreamNodeSize === 0
901-
let message =
902-
downstreamNodeSize > 0 ? 'This Pipeline cannot be deleted as it has connected CD pipeline' : ''
900+
const canDeletePipeline = isLastNode
901+
const message =
902+
!canDeletePipeline ? 'This Pipeline cannot be deleted as it has connected CD pipeline' : ''
903903
return (
904904
<ConditionalWrap
905905
condition={!canDeletePipeline}
@@ -1060,7 +1060,7 @@ export default function NewCDPipeline({
10601060
} else {
10611061
title = CREATE_DEPLOYMENT_PIPELINE;
10621062
}
1063-
1063+
10641064
return (
10651065
<div
10661066
className={`modal__body modal__body__ci_new_ui br-0 modal__body--p-0 ${

src/components/workflowEditor/Workflow.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export interface WorkflowProps
6060
isJobView?: boolean
6161
envList?: any[]
6262
filteredCIPipelines?: any[]
63+
addNewPipelineBlocked?: boolean
6364
}
6465

6566
interface WorkflowState {
@@ -253,6 +254,7 @@ export class Workflow extends Component<WorkflowProps, WorkflowState> {
253254
this.props.handleCDSelect(this.props.id, node.id, PipelineType.WEBHOOK, node.id, true)
254255
}}
255256
hideWebhookTippy={this.props.hideWebhookTippy}
257+
addNewPipelineBlocked={this.props.addNewPipelineBlocked}
256258
/>
257259
)
258260
}
@@ -328,6 +330,7 @@ export class Workflow extends Component<WorkflowProps, WorkflowState> {
328330
showPluginWarning={node.showPluginWarning}
329331
envList={this.props.envList}
330332
filteredCIPipelines={this.props.filteredCIPipelines}
333+
addNewPipelineBlocked={this.props.addNewPipelineBlocked}
331334
/>
332335
)
333336
}
@@ -362,6 +365,7 @@ export class Workflow extends Component<WorkflowProps, WorkflowState> {
362365
deploymentAppDeleteRequest={node.deploymentAppDeleteRequest}
363366
match={this.props.match}
364367
isVirtualEnvironment={node.isVirtualEnvironment}
368+
addNewPipelineBlocked={this.props.addNewPipelineBlocked}
365369
/>
366370
)
367371
}

src/components/workflowEditor/nodes/CDNode.tsx

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,17 @@ export class CDNode extends Component<CDNodeProps, CDNodeState> {
5252
}
5353

5454
onClickAddNode = (event: any) => {
55-
if (this.props.deploymentAppDeleteRequest) {
56-
toast.error(ERR_MESSAGE_ARGOCD)
57-
} else {
58-
event.stopPropagation()
59-
let { top, left } = event.target.getBoundingClientRect()
60-
top = top + 25
61-
this.props.toggleCDMenu()
62-
}
55+
if (this.props.addNewPipelineBlocked) {
56+
return
57+
}
58+
if (this.props.deploymentAppDeleteRequest) {
59+
toast.error(ERR_MESSAGE_ARGOCD)
60+
} else {
61+
event.stopPropagation()
62+
let { top, left } = event.target.getBoundingClientRect()
63+
top = top + 25
64+
this.props.toggleCDMenu()
65+
}
6366
}
6467

6568
getAppDetailsURL(): string {
@@ -128,8 +131,8 @@ export class CDNode extends Component<CDNodeProps, CDNodeState> {
128131
<div
129132
className={`workflow-node__icon-common ${
130133
this.props.isVirtualEnvironment
131-
? "workflow-node__CD-rocket-icon"
132-
: "workflow-node__CD-icon dc__flip"
134+
? 'workflow-node__CD-rocket-icon'
135+
: 'workflow-node__CD-icon dc__flip'
133136
}`}
134137
></div>
135138
</div>
@@ -141,9 +144,18 @@ export class CDNode extends Component<CDNodeProps, CDNodeState> {
141144
className="default-tt workflow-node__add-cd-btn-tippy"
142145
arrow={false}
143146
placement="top"
144-
content={<span className="add-cd-btn-tippy"> Add deployment pipeline </span>}
147+
content={
148+
<span className="add-cd-btn-tippy">
149+
{this.props.addNewPipelineBlocked
150+
? 'Not allowed with env filter'
151+
: 'Add deployment pipeline'}
152+
</span>
153+
}
145154
>
146-
<Add className="icon-dim-18 fcb-5" onClick={this.onClickAddNode} />
155+
<Add
156+
className={`icon-dim-18 fcb-5 ${this.props.addNewPipelineBlocked ? 'dc__disabled' : ''}`}
157+
onClick={this.onClickAddNode}
158+
/>
147159
</Tippy>
148160
</button>
149161
{this.state.showDeletePipelinePopup && this.renderConfirmationModal()}

src/components/workflowEditor/nodes/CINode.tsx

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,19 @@ export interface CINodeProps {
3131
showPluginWarning?: boolean
3232
envList?: any[]
3333
filteredCIPipelines?: any[]
34+
addNewPipelineBlocked?: boolean
3435
}
3536

3637
export class CINode extends Component<CINodeProps> {
38+
onClickAddNode = (event: any) => {
39+
if (this.props.addNewPipelineBlocked) {
40+
return
41+
}
42+
event.stopPropagation()
43+
let { top, left } = event.target.getBoundingClientRect()
44+
top = top + 25
45+
this.props.toggleCDMenu()
46+
}
3747
renderNodeIcon = () => {
3848
if (this.props.showPluginWarning) {
3949
return <Warning className="icon-dim-18 warning-icon-y7" />
@@ -68,7 +78,9 @@ export class CINode extends Component<CINodeProps> {
6878
const _linkedBuildText = this.props.isLinkedCI ? 'Build: Linked' : _buildText
6979
const pipeline = this.props.isJobView ? 'Job' : _linkedBuildText
7080
const currPipeline = this.props.filteredCIPipelines.find((pipeline) => +pipeline.id === +this.props.id)
71-
const env = currPipeline?.environmentId ? this.props.envList.find((env) => +env.id === +currPipeline.environmentId) : undefined
81+
const env = currPipeline?.environmentId
82+
? this.props.envList.find((env) => +env.id === +currPipeline.environmentId)
83+
: undefined
7284

7385
return (
7486
<>
@@ -103,9 +115,16 @@ export class CINode extends Component<CINodeProps> {
103115
>
104116
<div className="dc__ellipsis-left">{this.props.title}</div>
105117
</Tippy>
106-
{this.props.isJobView && <>
107-
<span className="fw-4 fs-11">Env: {env ? env.environment_name : DEFAULT_ENV}</span>
108-
<span className="fw-4 fs-11 ml-4 dc__italic-font-style">{!env && "(Default)"}</span></>}
118+
{this.props.isJobView && (
119+
<>
120+
<span className="fw-4 fs-11">
121+
Env: {env ? env.environment_name : DEFAULT_ENV}
122+
</span>
123+
<span className="fw-4 fs-11 ml-4 dc__italic-font-style">
124+
{!env && '(Default)'}
125+
</span>
126+
</>
127+
)}
109128
</div>
110129
{this.renderNodeIcon()}
111130
</div>
@@ -121,17 +140,16 @@ export class CINode extends Component<CINodeProps> {
121140
arrow={false}
122141
placement="top"
123142
content={
124-
<span style={{ display: 'block', width: '145px' }}> Add deployment pipeline </span>
143+
<span style={{ display: 'block', width: '145px' }}>
144+
{this.props.addNewPipelineBlocked
145+
? 'Not allowed with env filter'
146+
: 'Add deployment pipeline'}
147+
</span>
125148
}
126149
>
127150
<Add
128-
className="icon-dim-18 fcb-5"
129-
onClick={(event: any) => {
130-
event.stopPropagation()
131-
let { top, left } = event.target.getBoundingClientRect()
132-
top = top + 25
133-
this.props.toggleCDMenu()
134-
}}
151+
className={`icon-dim-18 fcb-5 ${this.props.addNewPipelineBlocked ? 'dc__disabled' : ''}`}
152+
onClick={this.onClickAddNode}
135153
/>
136154
</Tippy>
137155
</button>

src/components/workflowEditor/nodes/WebhookNode.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ import { ReactComponent as Add } from '../../../assets/icons/ic-add.svg'
66
import { ConditionalWrap } from '../../common'
77
import { WebhookNodeProps } from '../types'
88

9-
export function WebhookNode({ x, y, width, height, id, to, configDiffView, toggleCDMenu, hideWebhookTippy }: WebhookNodeProps) {
9+
export function WebhookNode({ x, y, width, height, id, to, configDiffView, toggleCDMenu, hideWebhookTippy, addNewPipelineBlocked }: WebhookNodeProps) {
1010
const addNewCD = (event): void => {
11-
event.stopPropagation()
12-
let { top } = event.target.getBoundingClientRect()
13-
top = top + 25
14-
toggleCDMenu()
11+
if (addNewPipelineBlocked) {
12+
return
13+
}
14+
event.stopPropagation()
15+
let { top } = event.target.getBoundingClientRect()
16+
top = top + 25
17+
toggleCDMenu()
1518
}
1619

1720
const renderWebhookCard = (): JSX.Element => {
@@ -43,10 +46,12 @@ export function WebhookNode({ x, y, width, height, id, to, configDiffView, toggl
4346
arrow={false}
4447
placement="top"
4548
content={
46-
<span style={{ display: 'block', width: '145px' }}> Add deployment pipeline </span>
49+
<span style={{ display: 'block', width: '145px' }}>
50+
{addNewPipelineBlocked ? 'Not allowed with env filter' : 'Add deployment pipeline'}
51+
</span>
4752
}
4853
>
49-
<Add className="icon-dim-18 fcb-5" onClick={addNewCD} />
54+
<Add className={`icon-dim-18 fcb-5 ${addNewPipelineBlocked ? 'dc__disabled' : ''}`} onClick={addNewCD} />
5055
</Tippy>
5156
</button>
5257
)}

src/components/workflowEditor/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export interface CDNodeProps{
9292
match: RouteComponentProps['match']
9393
description: string
9494
isVirtualEnvironment?: boolean
95+
addNewPipelineBlocked?: boolean
9596
}
9697

9798
export interface WebhookNodeProps {
@@ -104,6 +105,7 @@ export interface WebhookNodeProps {
104105
configDiffView?: boolean
105106
toggleCDMenu?: () => void
106107
hideWebhookTippy?: () => void
108+
addNewPipelineBlocked?: boolean
107109
}
108110

109111
export interface WebhookTippyType {

src/components/workflowEditor/workflowEditor.tsx

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,17 @@ class WorkflowEdit extends Component<WorkflowEditProps, WorkflowEditState> {
171171
}
172172

173173
toggleCIMenu = (event) => {
174-
const { top, left } = event.target.getBoundingClientRect()
175-
this.setState({
176-
cIMenuPosition: {
177-
top: top,
178-
left: left,
179-
},
180-
showCIMenu: !this.state.showCIMenu,
181-
})
174+
if (this.props.filteredEnvIds) {
175+
return
176+
}
177+
const { top, left } = event.target.getBoundingClientRect()
178+
this.setState({
179+
cIMenuPosition: {
180+
top: top,
181+
left: left,
182+
},
183+
showCIMenu: !this.state.showCIMenu,
184+
})
182185
}
183186

184187
deleteWorkflow = (appId?: string, workflowId?: number) => {
@@ -349,18 +352,18 @@ class WorkflowEdit extends Component<WorkflowEditProps, WorkflowEditState> {
349352
`${this.props.match.path}/${pipeline}/:ciPipelineId/cd-pipeline/:cdPipelineId`,
350353
)}
351354
render={({ location, match }: { location: any; match: any }) => {
352-
const cdNode = this.state.allDeploymentNodeMap.get(match.params.cdPipelineId)
353-
const downstreamNodeSize = cdNode?.downstreams?.length ?? 0
354355
return (
355356
<NewCDPipeline
356357
match={match}
357358
location={location}
358359
appName={this.state.appName}
359360
close={this.closePipeline}
360-
downstreamNodeSize={downstreamNodeSize}
361361
getWorkflows={this.getWorkflows}
362362
refreshParentWorkflows={this.props.getWorkflows}
363363
envIds={this.state.envIds}
364+
isLastNode={
365+
this.state.allDeploymentNodeMap.get(match.params.cdPipelineId)?.['isLast']
366+
}
364367
/>
365368
)
366369
}}
@@ -438,7 +441,7 @@ class WorkflowEdit extends Component<WorkflowEditProps, WorkflowEditState> {
438441
<>
439442
<button
440443
type="button"
441-
className="cta dc__no-decor flex mb-20"
444+
className={`cta dc__no-decor flex mb-20 ${this.props.filteredEnvIds ? 'dc__disabled' : ''}`}
442445
data-testid="new-workflow-button"
443446
onClick={this.toggleCIMenu}
444447
>
@@ -559,6 +562,7 @@ class WorkflowEdit extends Component<WorkflowEditProps, WorkflowEditState> {
559562
isJobView={this.props.isJobView}
560563
envList={this.props.envList}
561564
filteredCIPipelines={this.state.filteredCIPipelines}
565+
addNewPipelineBlocked={!!this.props.filteredEnvIds}
562566
/>
563567
)
564568
})

0 commit comments

Comments
 (0)