Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | 20x 20x 20x 20x 20x 20x 20x 20x 1x 10x 1x 3x | /*
* Copyright 2021 Harness Inc. All rights reserved.
* Use of this source code is governed by the PolyForm Shield 1.0.0 license
* that can be found in the licenses directory at the root of this repository, also available at
* https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt.
*/
import React from 'react'
import { sortBy } from 'lodash-es'
import { Popover } from '@blueprintjs/core'
import type { ModulePathParams, PipelinePathProps } from '@common/interfaces/RouteInterfaces'
import type { GraphLayoutNode } from 'services/pipeline-ng'
import type { ExecutionStatus } from '@pipeline/utils/statusHelpers'
import { StageNode } from './StageNode'
import css from './MiniExecutionGraph.module.scss'
// Higher the number, Higher the Priority, Max 100.
const StagePriority: Record<ExecutionStatus, number> = {
Success: 1,
Running: 2,
AsyncWaiting: 2,
TaskWaiting: 2,
TimedWaiting: 2,
Failed: 20,
Errored: 20,
IgnoreFailed: 20,
Expired: 18,
Aborted: 19,
Discontinuing: 19,
Suspended: 17,
Queued: 0,
NotStarted: 0,
Paused: 24,
ResourceWaiting: 25,
Skipped: 15,
ApprovalRejected: 22,
ApprovalWaiting: 26,
InterventionWaiting: 27,
Pausing: 23
}
const STEP_DETAILS_LIMIT = 4
export interface ParallelNodeProps extends PipelinePathProps, ModulePathParams {
stages: GraphLayoutNode[]
planExecutionId: string
}
export function ParallelStageNode(props: ParallelNodeProps): React.ReactElement {
const { stages, accountId, orgIdentifier, projectIdentifier, pipelineIdentifier, planExecutionId, module } = props
const sortedStages = sortBy(stages, stage => 100 - StagePriority[stage.status as ExecutionStatus])
return (
<Popover
interactionKind="hover"
minimal
position="bottom"
lazy
autoFocus={false}
enforceFocus={false}
className={css.parallelNodes}
wrapperTagName="div"
targetTagName="div"
targetClassName={css.ghostNodes}
popoverClassName={css.moreStages}
targetProps={{ 'data-stages': sortedStages.length } as any}
modifiers={{ offset: { offset: '0,8px' } }}
>
<StageNode
stage={sortedStages[0]}
{...{ accountId, orgIdentifier, projectIdentifier, module, pipelineIdentifier, planExecutionId }}
/>
<React.Fragment>
{sortedStages.slice(1, STEP_DETAILS_LIMIT).map((stage: GraphLayoutNode, i) => (
<StageNode
key={i}
stage={stage}
{...{ accountId, orgIdentifier, projectIdentifier, module, pipelineIdentifier, planExecutionId }}
/>
))}
{sortedStages.length > STEP_DETAILS_LIMIT ? (
<div className={css.extraCount}>+ {stages.length - STEP_DETAILS_LIMIT}</div>
) : null}
</React.Fragment>
</Popover>
)
}
|