Skip to content

Commit 2029434

Browse files
committed
chore: shift handleAddCD to common
1 parent 370fef4 commit 2029434

File tree

2 files changed

+18
-34
lines changed

2 files changed

+18
-34
lines changed

src/components/common/edge/rectangularEdge.tsx

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import React, { Component } from 'react'
22
import {
33
AddCDPositions,
4-
WorkflowNodeType,
5-
PipelineType,
64
AddPipelineType,
75
AddCDButton,
86
Point,
97
EdgeNodeType,
8+
EdgeEndNodeType,
9+
handleAddCD,
1010
} from '@devtron-labs/devtron-fe-common-lib'
1111
import { nodeColors } from './colors'
1212

@@ -18,7 +18,7 @@ interface Line {
1818
interface EdgeProps {
1919
// type should not be any but WorkflowNodeType, but node type is something else have to look into it
2020
startNode: Point & EdgeNodeType
21-
endNode: Point & EdgeNodeType
21+
endNode: Point & EdgeEndNodeType
2222
onClickEdge: (event: any) => void
2323
deleteEdge: () => void
2424
onMouseOverEdge: (startID: any, endID: any) => void
@@ -134,31 +134,17 @@ export default class Edge extends Component<EdgeProps> {
134134
}
135135
}
136136

137-
getPipelineType = () => {
138-
if (this.props.isWebhookCD) {
139-
return PipelineType.WEBHOOK
140-
}
141-
142-
if (this.props.startNode.type === WorkflowNodeType.CI) {
143-
return PipelineType.CI_PIPELINE
144-
}
145-
146-
return PipelineType.CD_PIPELINE
147-
}
148-
149-
handleAddCD = (position: AddCDPositions) => {
150-
if (!this.props.handleCDSelect) {
151-
return
152-
}
153-
const { handleCDSelect, startNode, endNode, workflowId, ciPipelineId, isWebhookCD } = this.props
154-
const pipelineType = this.getPipelineType()
155-
const addPipelineType =
156-
this.props.isParallelEdge && position === AddCDPositions.RIGHT
157-
? AddPipelineType.PARALLEL
158-
: AddPipelineType.SEQUENTIAL
159-
const endNodeId = !this.props.isParallelEdge && position === AddCDPositions.RIGHT ? endNode.id : null
160-
161-
handleCDSelect(workflowId, ciPipelineId, pipelineType, startNode.id, isWebhookCD, endNodeId, addPipelineType)
137+
handleAddCDClick = (position: AddCDPositions) => {
138+
handleAddCD({
139+
position,
140+
handleCDSelect: this.props.handleCDSelect,
141+
startNode: this.props.startNode,
142+
endNode: this.props.endNode,
143+
workflowId: this.props.workflowId,
144+
ciPipelineId: this.props.ciPipelineId,
145+
isWebhookCD: this.props.isWebhookCD,
146+
isParallelEdge: this.props.isParallelEdge,
147+
})
162148
}
163149

164150
render() {
@@ -184,14 +170,14 @@ export default class Edge extends Component<EdgeProps> {
184170
addCDButtons={this.props.addCDButtons}
185171
endNode={this.props.endNode}
186172
startNode={this.props.startNode}
187-
handleAddCD={this.handleAddCD}
173+
handleAddCD={this.handleAddCDClick}
188174
/>
189175
<AddCDButton
190176
position={AddCDPositions.RIGHT}
191177
addCDButtons={this.props.addCDButtons}
192178
endNode={this.props.endNode}
193179
startNode={this.props.startNode}
194-
handleAddCD={this.handleAddCD}
180+
handleAddCD={this.handleAddCDClick}
195181
/>
196182
</g>
197183
)

src/components/workflowEditor/nodes/CDNode.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,16 @@ export class CDNode extends Component<CDNodeProps, CDNodeState> {
9090
deleteCDPipeline(payload, force, cascadeDelete)
9191
.then((response) => {
9292
if (response.result) {
93+
this.handleHideDeleteModal()
94+
this.handleClusterNameUpdate(response.result.deleteResponse?.clusterName)
9395
if (
9496
cascadeDelete &&
9597
!response.result.deleteResponse?.clusterReachable &&
9698
!response.result.deleteResponse?.deleteInitiated
9799
) {
98-
this.handleHideDeleteModal()
99-
this.handleClusterNameUpdate(response.result.deleteResponse?.clusterName)
100100
this.handleDeleteDialogUpdate(DeleteDialogType.showNonCascadeDeleteDialog)
101101
} else {
102102
toast.success(TOAST_INFO.PIPELINE_DELETION_INIT)
103-
this.handleHideDeleteModal()
104-
this.handleClusterNameUpdate(response.result.deleteResponse?.clusterName)
105103
this.handleDeleteDialogUpdate(DeleteDialogType.showNormalDeleteDialog)
106104
this.props.getWorkflows?.()
107105
this.props.reloadEnvironments?.()

0 commit comments

Comments
 (0)