Skip to content

Commit 2039e57

Browse files
committed
Merge branch 'feat/add-delete-cd' into fix/workflow-node-overlap
2 parents 49f43ff + 26496b7 commit 2039e57

29 files changed

+1214
-438
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"homepage": "/dashboard",
66
"dependencies": {
7-
"@devtron-labs/devtron-fe-common-lib": "0.0.45",
7+
"@devtron-labs/devtron-fe-common-lib": "0.0.45-beta-27",
88
"@rjsf/core": "^5.13.3",
99
"@rjsf/utils": "^5.13.3",
1010
"@rjsf/validator-ajv8": "^5.13.3",

src/components/ApplicationGroup/AppGroup.service.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@ import {
44
CiPipelineResult,
55
WorkflowResult,
66
NodeAttr,
7-
PipelineType,
8-
WorkflowNodeType,
97
CiPipeline,
108
} from '../app/details/triggerView/types'
119
import { WebhookListResponse } from '../ciPipeline/Webhook/types'
1210
import { processWorkflow } from '../app/details/triggerView/workflow.service'
1311
import { WorkflowTrigger } from '../app/details/triggerView/config'
1412
import { ModuleNameMap, Routes, URLS } from '../../config'
15-
import { get, post, put, ResponseType, trash } from '@devtron-labs/devtron-fe-common-lib'
13+
import { get, post, put, ResponseType, trash, WorkflowNodeType, PipelineType } from '@devtron-labs/devtron-fe-common-lib'
1614
import {
1715
AppGroupList,
1816
CIConfigListType,

src/components/ApplicationGroup/AppGroup.types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import {
44
FilterConditionsListType,
55
ResponseType,
66
UserApprovalConfigType,
7+
WorkflowNodeType
78
} from '@devtron-labs/devtron-fe-common-lib'
89
import { MultiValue } from 'react-select'
9-
import { WebhookPayloads, WorkflowNodeType, WorkflowType } from '../app/details/triggerView/types'
10+
import { WebhookPayloads, WorkflowType } from '../app/details/triggerView/types'
1011
import { EditDescRequest, OptionType } from '../app/types'
1112
import { AppFilterTabs, BulkResponseStatus } from './Constants'
1213

src/components/ApplicationGroup/Details/EnvCIDetails/EnvCIDetails.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useEffect, useState } from 'react'
22
import { generatePath, Route, useHistory, useParams, useRouteMatch } from 'react-router-dom'
3-
import { Progressing, showError, sortCallback, useAsync } from '@devtron-labs/devtron-fe-common-lib'
3+
import { Progressing, showError, sortCallback, useAsync, PipelineType } from '@devtron-labs/devtron-fe-common-lib'
44
import { URLS } from '../../../../config'
55
import { APP_GROUP_CI_DETAILS } from '../../../../config/constantMessaging'
66
import { EmptyView, LogResizeButton } from '../../../app/details/cicdHistory/History.components'
@@ -12,7 +12,7 @@ import {
1212
FetchIdDataStatus,
1313
} from '../../../app/details/cicdHistory/types'
1414
import { Details } from '../../../app/details/cIDetails/CIDetails'
15-
import { CiPipeline, PipelineType } from '../../../app/details/triggerView/types'
15+
import { CiPipeline } from '../../../app/details/triggerView/types'
1616
import { getTriggerHistory } from '../../../app/service'
1717
import { asyncWrap, mapByKey, useInterval } from '../../../common'
1818
import { getCIConfigList } from '../../AppGroup.service'

src/components/ApplicationGroup/Details/TriggerView/EnvTriggerView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
Checkbox,
1616
CHECKBOX_VALUE,
1717
VisibleModal,
18+
WorkflowNodeType,
1819
} from '@devtron-labs/devtron-fe-common-lib'
1920
import CDMaterial from '../../../app/details/triggerView/cdMaterial'
2021
import { CIMaterial } from '../../../app/details/triggerView/ciMaterial'
@@ -24,7 +25,6 @@ import {
2425
CIMaterialRouterProps,
2526
MATERIAL_TYPE,
2627
NodeAttr,
27-
WorkflowNodeType,
2828
WorkflowType,
2929
} from '../../../app/details/triggerView/types'
3030
import { Workflow } from '../../../app/details/triggerView/workflow/Workflow'

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export default function AppComposeRouter({
9494
getWorkflows={getWorkflows}
9595
isJobView={isJobView}
9696
envList={environments}
97+
reloadEnvironments={reloadEnvironments}
9798
/>
9899
)}
99100
/>,
@@ -192,6 +193,7 @@ export default function AppComposeRouter({
192193
respondOnSuccess={respondOnSuccess}
193194
getWorkflows={getWorkflows}
194195
filteredEnvIds={filteredEnvIds}
196+
reloadEnvironments={reloadEnvironments}
195197
/>
196198
)}
197199
/>,

src/components/app/details/cIDetails/CIDetails.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState, useEffect, useMemo } from 'react'
2-
import { showError, Progressing, Reload, GenericEmptyState, useAsync } from '@devtron-labs/devtron-fe-common-lib'
2+
import { showError, Progressing, Reload, GenericEmptyState, useAsync, PipelineType } from '@devtron-labs/devtron-fe-common-lib'
33
import {
44
getCIPipelines,
55
getCIHistoricalStatus,
@@ -30,7 +30,6 @@ import { EMPTY_STATE_STATUS } from '../../../../config/constantMessaging'
3030
import { ReactComponent as NoVulnerability } from '../../../../assets/img/ic-vulnerability-not-found.svg'
3131
import { ScannedByToolModal } from '../../../common/security/ScannedByToolModal'
3232
import { CIPipelineBuildType } from '../../../ciPipeline/types'
33-
import { PipelineType } from '../triggerView/types'
3433

3534
const terminalStatus = new Set(['succeeded', 'failed', 'error', 'cancelled', 'nottriggered', 'notbuilt'])
3635
let statusSet = new Set(['starting', 'running', 'pending'])

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ export const WorkflowCreate = {
3434
cINodeSizes: {
3535
nodeHeight: 64,
3636
nodeWidth: 240,
37-
distanceX: 60,
37+
distanceX: 100,
3838
distanceY: 25,
3939
} as NodeDimension,
4040
cDNodeSizes: {
4141
nodeHeight: 64,
4242
nodeWidth: 240,
43-
distanceX: 60,
43+
distanceX: 100,
4444
distanceY: 25,
4545
} as NodeDimension,
4646
workflow: {

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

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
TaskErrorObj,
1717
FilterConditionsListType,
1818
CDMaterialResponseType,
19+
PipelineType,
1920
} from '@devtron-labs/devtron-fe-common-lib'
2021
import { Environment } from '../../../cdPipeline/cdPipeline.types'
2122
import { WorkflowDimensions } from './config'
@@ -410,13 +411,6 @@ export interface ApplicationConditionResponse {
410411
message: string
411412
}
412413

413-
export enum PipelineType {
414-
CI_PIPELINE = 'CI_PIPELINE',
415-
CD_PIPELINE = 'CD_PIPELINE',
416-
WEBHOOK = 'WEBHOOK',
417-
LINKED_CD = 'LINKED_CD',
418-
}
419-
420414
export enum CIPipelineNodeType {
421415
EXTERNAL_CI = 'EXTERNAL-CI',
422416
CI = 'CI',
@@ -425,15 +419,6 @@ export enum CIPipelineNodeType {
425419
LINKED_CD = 'LINKED_CD',
426420
}
427421

428-
export enum WorkflowNodeType {
429-
GIT = 'GIT',
430-
CI = 'CI',
431-
WEBHOOK = 'WEBHOOK',
432-
PRE_CD = 'PRECD',
433-
CD = 'CD',
434-
POST_CD = 'POSTCD',
435-
}
436-
437422
export interface Task {
438423
name?: string
439424
type?: string

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

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,14 @@ import {
88
CiPipelineResult,
99
Workflow,
1010
WorkflowResult,
11-
PipelineType,
12-
WorkflowNodeType,
1311
AddDimensionsToDownstreamDeploymentsParams,
1412
} from './types'
1513
import { WorkflowTrigger, WorkflowCreate, Offset, WorkflowDimensions, WorkflowDimensionType } from './config'
1614
import { TriggerType, DEFAULT_STATUS, GIT_BRANCH_NOT_CONFIGURED } from '../../../../config'
1715
import { isEmpty } from '../../../common'
1816
import { WebhookDetailsType } from '../../../ciPipeline/Webhook/types'
1917
import { getExternalCIList } from '../../../ciPipeline/Webhook/webhook.service'
20-
import { TriggerTypeMap } from '@devtron-labs/devtron-fe-common-lib'
18+
import { CommonNodeAttr, TriggerTypeMap, WorkflowNodeType, PipelineType, DownstreamNodesEnvironmentsType } from '@devtron-labs/devtron-fe-common-lib'
2119
import { CIPipelineBuildType } from '../../../ciPipeline/types'
2220
import { BlackListedCI } from '../../../workflowEditor/types'
2321

@@ -295,6 +293,7 @@ function addDimensions(workflows: WorkflowType[], workflowOffset: Offset, dimens
295293
dimensions.type === WorkflowDimensionType.CREATE &&
296294
node.parentPipelineType === PipelineType.WEBHOOK
297295
) {
296+
// Maybe need to manipulate it
298297
node.x = node.x - 40
299298
}
300299
node.preNode && finalWorkflow.push(node.preNode)
@@ -325,6 +324,7 @@ function addDimensions(workflows: WorkflowType[], workflowOffset: Offset, dimens
325324
workflow.nodes = finalWorkflow
326325
})
327326

327+
// FIXME: This might be the key to solve scrolling workflows in case one scrolls, all other scrolls
328328
workflows.forEach((workflow) => (workflow.width = maxWorkflowWidth))
329329
}
330330

@@ -349,10 +349,17 @@ function addDownstreams(workflows: WorkflowType[]) {
349349

350350
if (!!parentNode) {
351351
const _downstream = type + '-' + node.id
352+
const environmentDetails: DownstreamNodesEnvironmentsType = {
353+
environmentId: node.environmentId,
354+
environmentName: node.environmentName,
355+
}
356+
352357
if (parentNode.postNode) {
353358
parentNode.postNode.downstreams.push(_downstream)
359+
parentNode.postNode.downstreamEnvironments?.push(environmentDetails)
354360
} else {
355361
parentNode.downstreams.push(_downstream)
362+
parentNode.downstreamEnvironments?.push(environmentDetails)
356363
}
357364
parentNode.downstreamNodes.push(node)
358365
}
@@ -455,6 +462,7 @@ function ciPipelineToNode(ciPipeline: CiPipeline, dimensions: WorkflowDimensions
455462
url: '',
456463
id: `${WorkflowNodeType.GIT}-${materialName}-${index}`,
457464
downstreams: [`${WorkflowNodeType.CI}-${ciPipeline.id}`],
465+
downstreamEnvironments: [],
458466
type: WorkflowNodeType.GIT,
459467
icon: 'git',
460468
branch: getStaticCurrentBranchName(ciMaterial),
@@ -488,6 +496,7 @@ function ciPipelineToNode(ciPipeline: CiPipeline, dimensions: WorkflowDimensions
488496
type: WorkflowNodeType.CI,
489497
inputMaterialList: [],
490498
downstreams: [],
499+
downstreamEnvironments: [],
491500
isExternalCI: ciPipeline.isExternal,
492501
// Can't rely on pipelineType for legacy pipelines, so using parentCiPipeline as well
493502
isLinkedCI: ciPipeline.pipelineType !== PipelineType.LINKED_CD && !!ciPipeline.parentCiPipeline,
@@ -519,6 +528,7 @@ function webhookToNode(webhookDetails: WebhookDetailsType, dimensions: WorkflowD
519528
type: WorkflowNodeType.WEBHOOK,
520529
inputMaterialList: [],
521530
downstreams: [],
531+
downstreamEnvironments: [],
522532
isExternalCI: true,
523533
isLinkedCI: false,
524534
linkedCount: 0,
@@ -547,6 +557,7 @@ function cdPipelineToNode(cdPipeline: CdPipeline, dimensions: WorkflowDimensions
547557
activeIn: false,
548558
activeOut: false,
549559
downstreams: [`${WorkflowNodeType.CD}-${cdPipeline.id}`],
560+
downstreamEnvironments: [],
550561
type: WorkflowNodeType.PRE_CD,
551562
status: cdPipeline.preDeployStage?.status || cdPipeline.preStage?.status || DEFAULT_STATUS,
552563
triggerType: TriggerTypeMap[trigger],
@@ -583,6 +594,7 @@ function cdPipelineToNode(cdPipeline: CdPipeline, dimensions: WorkflowDimensions
583594
activeIn: false,
584595
activeOut: false,
585596
downstreams: cdDownstreams,
597+
downstreamEnvironments: [],
586598
type: WorkflowNodeType.CD,
587599
status: DEFAULT_STATUS,
588600
triggerType: TriggerTypeMap[trigger],
@@ -606,7 +618,8 @@ function cdPipelineToNode(cdPipeline: CdPipeline, dimensions: WorkflowDimensions
606618
isVirtualEnvironment: cdPipeline.isVirtualEnvironment,
607619
deploymentAppType: cdPipeline.deploymentAppType,
608620
helmPackageName: cdPipeline?.helmPackageName || '',
609-
isLast: isLast
621+
isLast: isLast,
622+
deploymentAppCreated: cdPipeline?.deploymentAppCreated,
610623
} as NodeAttr
611624
stageIndex++
612625

@@ -625,6 +638,7 @@ function cdPipelineToNode(cdPipeline: CdPipeline, dimensions: WorkflowDimensions
625638
activeIn: false,
626639
activeOut: false,
627640
downstreams: [],
641+
downstreamEnvironments: [],
628642
type: WorkflowNodeType.POST_CD,
629643
status: cdPipeline.postDeployStage?.status || cdPipeline.postStage?.status || DEFAULT_STATUS,
630644
triggerType: TriggerTypeMap[trigger],
@@ -677,3 +691,34 @@ function getCINodeHeight(dimensionType: WorkflowDimensionType, pipeline: CiPipel
677691
}
678692
return WorkflowTrigger.cINodeSizes.nodeHeight
679693
}
694+
695+
export function getAllChildDownstreams(node: CommonNodeAttr, workflow: any): { downstreamNodes: CommonNodeAttr[] } {
696+
let downstreamNodes = []
697+
// Not using downstreamNodes since they get deleted in service itself
698+
if (node?.downstreams?.length) {
699+
node.downstreams.forEach((downstreamData) => {
700+
// separating id and type from downstreamData by splitting on -
701+
const [type, id] = downstreamData.split('-')
702+
const _node = workflow.nodes?.find((wfNode) => String(wfNode.id) === id && wfNode.type === type)
703+
if (_node) {
704+
const { downstreamNodes: _downstreamNodes } = getAllChildDownstreams(_node, workflow)
705+
downstreamNodes = [...downstreamNodes, ..._downstreamNodes]
706+
}
707+
})
708+
}
709+
return { downstreamNodes: [...downstreamNodes, node] }
710+
}
711+
712+
export function getMaxYFromFirstLevelDownstream(node: CommonNodeAttr, workflow: any): number {
713+
let maxY = 0
714+
if (node?.downstreams?.length) {
715+
node.downstreams.forEach((downstreamData) => {
716+
const [type, id] = downstreamData.split('-')
717+
const _node = workflow.nodes?.find((wfNode) => String(wfNode.id) === id && wfNode.type === type)
718+
if (_node) {
719+
maxY = Math.max(maxY, _node.y)
720+
}
721+
})
722+
}
723+
return maxY
724+
}

0 commit comments

Comments
 (0)