Skip to content

Commit 26496b7

Browse files
Merge pull request #1536 from devtron-labs/feat/workflow-environment-list-tippy
feat: add support for tooltip in addCDButtons
2 parents fa17ab6 + f33736f commit 26496b7

File tree

5 files changed

+31
-2
lines changed

5 files changed

+31
-2
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-beta-18",
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/app/details/triggerView/workflow.service.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { TriggerType, DEFAULT_STATUS, GIT_BRANCH_NOT_CONFIGURED } from '../../..
1414
import { isEmpty } from '../../../common'
1515
import { WebhookDetailsType } from '../../../ciPipeline/Webhook/types'
1616
import { getExternalCIList } from '../../../ciPipeline/Webhook/webhook.service'
17-
import { CommonNodeAttr, TriggerTypeMap, WorkflowNodeType, PipelineType } from '@devtron-labs/devtron-fe-common-lib'
17+
import { CommonNodeAttr, TriggerTypeMap, WorkflowNodeType, PipelineType, DownstreamNodesEnvironmentsType } from '@devtron-labs/devtron-fe-common-lib'
1818
import { CIPipelineBuildType } from '../../../ciPipeline/types'
1919
import { BlackListedCI } from '../../../workflowEditor/types'
2020

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

349349
if (!!parentNode) {
350350
const _downstream = type + '-' + node.id
351+
const environmentDetails: DownstreamNodesEnvironmentsType = {
352+
environmentId: node.environmentId,
353+
environmentName: node.environmentName,
354+
}
355+
351356
if (parentNode.postNode) {
352357
parentNode.postNode.downstreams.push(_downstream)
358+
parentNode.postNode.downstreamEnvironments?.push(environmentDetails)
353359
} else {
354360
parentNode.downstreams.push(_downstream)
361+
parentNode.downstreamEnvironments?.push(environmentDetails)
355362
}
356363
parentNode.downstreamNodes.push(node)
357364
}
@@ -453,6 +460,7 @@ function ciPipelineToNode(ciPipeline: CiPipeline, dimensions: WorkflowDimensions
453460
url: '',
454461
id: `${WorkflowNodeType.GIT}-${materialName}-${index}`,
455462
downstreams: [`${WorkflowNodeType.CI}-${ciPipeline.id}`],
463+
downstreamEnvironments: [],
456464
type: WorkflowNodeType.GIT,
457465
icon: 'git',
458466
branch: getStaticCurrentBranchName(ciMaterial),
@@ -486,6 +494,7 @@ function ciPipelineToNode(ciPipeline: CiPipeline, dimensions: WorkflowDimensions
486494
type: WorkflowNodeType.CI,
487495
inputMaterialList: [],
488496
downstreams: [],
497+
downstreamEnvironments: [],
489498
isExternalCI: ciPipeline.isExternal,
490499
// Can't rely on pipelineType for legacy pipelines, so using parentCiPipeline as well
491500
isLinkedCI: ciPipeline.pipelineType !== PipelineType.LINKED_CD && !!ciPipeline.parentCiPipeline,
@@ -517,6 +526,7 @@ function webhookToNode(webhookDetails: WebhookDetailsType, dimensions: WorkflowD
517526
type: WorkflowNodeType.WEBHOOK,
518527
inputMaterialList: [],
519528
downstreams: [],
529+
downstreamEnvironments: [],
520530
isExternalCI: true,
521531
isLinkedCI: false,
522532
linkedCount: 0,
@@ -545,6 +555,7 @@ function cdPipelineToNode(cdPipeline: CdPipeline, dimensions: WorkflowDimensions
545555
activeIn: false,
546556
activeOut: false,
547557
downstreams: [`${WorkflowNodeType.CD}-${cdPipeline.id}`],
558+
downstreamEnvironments: [],
548559
type: WorkflowNodeType.PRE_CD,
549560
status: cdPipeline.preDeployStage?.status || cdPipeline.preStage?.status || DEFAULT_STATUS,
550561
triggerType: TriggerTypeMap[trigger],
@@ -581,6 +592,7 @@ function cdPipelineToNode(cdPipeline: CdPipeline, dimensions: WorkflowDimensions
581592
activeIn: false,
582593
activeOut: false,
583594
downstreams: cdDownstreams,
595+
downstreamEnvironments: [],
584596
type: WorkflowNodeType.CD,
585597
status: DEFAULT_STATUS,
586598
triggerType: TriggerTypeMap[trigger],
@@ -624,6 +636,7 @@ function cdPipelineToNode(cdPipeline: CdPipeline, dimensions: WorkflowDimensions
624636
activeIn: false,
625637
activeOut: false,
626638
downstreams: [],
639+
downstreamEnvironments: [],
627640
type: WorkflowNodeType.POST_CD,
628641
status: cdPipeline.postDeployStage?.status || cdPipeline.postStage?.status || DEFAULT_STATUS,
629642
triggerType: TriggerTypeMap[trigger],

src/components/common/edge/rectangularEdge.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ interface EdgeProps {
3636
ciPipelineId?: number | string
3737
isWebhookCD?: boolean
3838
isParallelEdge?: boolean
39+
leftTooltipContent?: string
3940
}
4041

4142
interface LineDots {
@@ -171,6 +172,7 @@ export default class Edge extends Component<EdgeProps> {
171172
endNode={this.props.endNode}
172173
startNode={this.props.startNode}
173174
handleAddCD={this.handleAddCDClick}
175+
tooltipContent={this.props.leftTooltipContent}
174176
/>
175177
<AddCDButton
176178
position={AddCDPositions.RIGHT}

src/components/workflowEditor/Workflow.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,14 @@ export class Workflow extends Component<WorkflowProps, WorkflowState> {
474474
}, [])
475475
}
476476

477+
getAddCDButtonTooltipContent = (node: NodeAttr): string => {
478+
const environments = node.downstreamEnvironments?.map((env) => env.environmentName) ?? []
479+
const environmentsString = environments.slice(0, 3).join('\n')
480+
const moreEnvCount = environments.length - 3
481+
const moreEnvString = moreEnvCount > 0 ? `\n+${moreEnvCount}` : ''
482+
return `before pipelines\n${environmentsString} ${moreEnvString}`
483+
}
484+
477485
onClickNodeEdge = ({
478486
nodeId,
479487
nodesWithBufferHeight,
@@ -558,6 +566,7 @@ export class Workflow extends Component<WorkflowProps, WorkflowState> {
558566
const addCDButtons =
559567
selectedNodeEndNodes.length > 1 ? [AddCDPositions.LEFT, AddCDPositions.RIGHT] : [AddCDPositions.RIGHT]
560568

569+
const leftTooltipContent = this.getAddCDButtonTooltipContent(startNode)
561570
if (ApprovalNodeEdge) {
562571
edgeList.push(
563572
<ApprovalNodeEdge
@@ -572,6 +581,7 @@ export class Workflow extends Component<WorkflowProps, WorkflowState> {
572581
ciPipelineId={workflowCIPipelineId}
573582
isParallelEdge
574583
isWebhookCD={isWebhookCD}
584+
leftTooltipContent={leftTooltipContent}
575585
/>,
576586
)
577587
} else {
@@ -589,6 +599,7 @@ export class Workflow extends Component<WorkflowProps, WorkflowState> {
589599
ciPipelineId={workflowCIPipelineId}
590600
isParallelEdge
591601
isWebhookCD={isWebhookCD}
602+
leftTooltipContent={leftTooltipContent}
592603
/>,
593604
)
594605
}

src/css/base.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,9 @@ a:focus {
266266
.dc__white-space-pre {
267267
white-space: pre;
268268
}
269+
.dc__white-space-pre-wrap {
270+
white-space: pre-wrap;
271+
}
269272

270273
.dc__hyphens-auto {
271274
-ms-hyphens: auto;

0 commit comments

Comments
 (0)