Skip to content

Commit 3707bc6

Browse files
committed
fix for node delete in case of env filter
1 parent 7e871e2 commit 3707bc6

File tree

6 files changed

+25
-19
lines changed

6 files changed

+25
-19
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??false)
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 & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export default function NewCDPipeline({
6868
getWorkflows,
6969
refreshParentWorkflows,
7070
envIds,
71+
isLastNode
7172
}) {
7273
const isCdPipeline = true
7374
const urlParams = new URLSearchParams(location.search)
@@ -706,7 +707,7 @@ export default function NewCDPipeline({
706707
const request = responseCode()
707708

708709
const _form = { ...formData }
709-
710+
710711
let promise = cdPipelineId ? updateCDPipeline(request) : saveCDPipeline(request)
711712
promise
712713
.then((response) => {
@@ -897,9 +898,9 @@ export default function NewCDPipeline({
897898

898899
const renderSecondaryButton = () => {
899900
if (cdPipelineId) {
900-
let canDeletePipeline = downstreamNodeSize === 0
901-
let message =
902-
downstreamNodeSize > 0 ? 'This Pipeline cannot be deleted as it has connected CD pipeline' : ''
901+
const canDeletePipeline = isLastNode //?? downstreamNodeSize === 0
902+
const message =
903+
!canDeletePipeline ? 'This Pipeline cannot be deleted as it has connected CD pipeline' : ''
903904
return (
904905
<ConditionalWrap
905906
condition={!canDeletePipeline}
@@ -1060,7 +1061,7 @@ export default function NewCDPipeline({
10601061
} else {
10611062
title = CREATE_DEPLOYMENT_PIPELINE;
10621063
}
1063-
1064+
10641065
return (
10651066
<div
10661067
className={`modal__body modal__body__ci_new_ui br-0 modal__body--p-0 ${

src/components/workflowEditor/workflowEditor.tsx

Lines changed: 13 additions & 10 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) => {
@@ -361,6 +364,7 @@ class WorkflowEdit extends Component<WorkflowEditProps, WorkflowEditState> {
361364
getWorkflows={this.getWorkflows}
362365
refreshParentWorkflows={this.props.getWorkflows}
363366
envIds={this.state.envIds}
367+
isLastNode={cdNode['isLast']}
364368
/>
365369
)
366370
}}
@@ -438,10 +442,9 @@ class WorkflowEdit extends Component<WorkflowEditProps, WorkflowEditState> {
438442
<>
439443
<button
440444
type="button"
441-
className="cta dc__no-decor flex mb-20"
445+
className={`cta dc__no-decor flex mb-20 ${this.props.filteredEnvIds ? 'dc__disabled' : ''}`}
442446
data-testid="new-workflow-button"
443447
onClick={this.toggleCIMenu}
444-
disabled={!!this.props.filteredEnvIds}
445448
>
446449
<img src={add} alt="add-worflow" className="icon-dim-18 mr-5" />
447450
New workflow

src/css/base.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3658,6 +3658,6 @@ textarea::placeholder {
36583658
}
36593659

36603660
.dc__disabled {
3661-
cursor: not-allowed;
3661+
cursor: not-allowed !important;
36623662
opacity: 0.5;
36633663
}

0 commit comments

Comments
 (0)