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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 42x 42x 42x 19x 44x 42x 42x 42x 42x 42x 42x 42x 42x 42x 42x 27x | /* * 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 { Card, Icon, Tag, TagsPopover, Text } from '@wings-software/uicore' import { FontVariation, Color } from '@harness/design-system' import { useHistory, useParams } from 'react-router-dom' import { Popover } from '@blueprintjs/core' import { defaultTo, get, isEmpty } from 'lodash-es' import cx from 'classnames' import type { PipelineExecutionSummary } from 'services/pipeline-ng' import { UserLabel, Duration, TimeAgoPopover } from '@common/exports' import ExecutionStatusLabel from '@pipeline/components/ExecutionStatusLabel/ExecutionStatusLabel' import ExecutionActions from '@pipeline/components/ExecutionActions/ExecutionActions' import { String, useStrings } from 'framework/strings' import routes from '@common/RouteDefinitions' import type { PipelineType, ProjectPathProps } from '@common/interfaces/RouteInterfaces' import { usePermission } from '@rbac/hooks/usePermission' import { ResourceType } from '@rbac/interfaces/ResourceType' import { PermissionIdentifier } from '@rbac/interfaces/PermissionIdentifier' import { ExecutionStatus, isExecutionIgnoreFailed, isExecutionNotStarted } from '@pipeline/utils/statusHelpers' import executionFactory from '@pipeline/factories/ExecutionFactory' import { hasCDStage, hasCIStage, StageType } from '@pipeline/utils/stageHelpers' import { mapTriggerTypeToStringID } from '@pipeline/utils/triggerUtils' import GitPopover from '@pipeline/components/GitPopover/GitPopover' import { CardVariant } from '@pipeline/utils/constants' import type { ExecutionCardInfoProps } from '@pipeline/factories/ExecutionFactory/types' import MiniExecutionGraph from './MiniExecutionGraph/MiniExecutionGraph' import css from './ExecutionCard.module.scss' export interface ExecutionCardProps { pipelineExecution: PipelineExecutionSummary variant?: CardVariant staticCard?: boolean isPipelineInvalid?: boolean } function ExecutionCardFooter({ pipelineExecution, variant }: ExecutionCardProps): React.ReactElement { const fontVariation = variant === CardVariant.Minimal ? FontVariation.TINY : FontVariation.SMALL const variantSize = variant === CardVariant.Minimal ? 10 : 14 return ( <div className={css.footer}> <div className={css.triggerInfo}> <UserLabel className={css.user} name={ get(pipelineExecution, 'moduleInfo.ci.ciExecutionInfoDTO.author.name') || get(pipelineExecution, 'moduleInfo.ci.ciExecutionInfoDTO.author.id') || get(pipelineExecution, 'executionTriggerInfo.triggeredBy.identifier') || 'Anonymous' } email={ get(pipelineExecution, 'moduleInfo.ci.ciExecutionInfoDTO.author.email') || get(pipelineExecution, 'executionTriggerInfo.triggeredBy.extraInfo.email') } profilePictureUrl={ get(pipelineExecution, 'moduleInfo.ci.ciExecutionInfoDTO.author.avatar') || get(pipelineExecution, 'executionTriggerInfo.triggeredBy.avatar') } textProps={{ font: { variation: fontVariation } }} iconProps={{ color: Color.GREY_900 }} /> <Text font={{ variation: fontVariation }}> <String className={css.triggerType} stringID={mapTriggerTypeToStringID(get(pipelineExecution, 'executionTriggerInfo.triggerType'))} /> </Text> </div> <div className={css.timers}> <TimeAgoPopover iconProps={{ size: variantSize, color: Color.GREY_900 }} icon="calendar" time={defaultTo(pipelineExecution?.startTs, 0)} inline={false} className={css.timeAgo} font={{ variation: fontVariation }} /> <Duration icon="time" className={css.duration} iconProps={{ size: variantSize, color: Color.GREY_900 }} startTime={pipelineExecution?.startTs} durationText={variant === CardVariant.Default ? undefined : ' '} endTime={pipelineExecution?.endTs} font={{ variation: fontVariation }} /> </div> </div> ) } export default function ExecutionCard(props: ExecutionCardProps): React.ReactElement { const { pipelineExecution, variant = CardVariant.Default, staticCard = false, isPipelineInvalid } = props const { orgIdentifier, projectIdentifier, accountId, module } = useParams<PipelineType<ProjectPathProps>>() const history = useHistory() const { getString } = useStrings() const HAS_CD = hasCDStage(pipelineExecution) const HAS_CI = hasCIStage(pipelineExecution) const cdInfo = executionFactory.getCardInfo(StageType.DEPLOY) const ciInfo = executionFactory.getCardInfo(StageType.BUILD) const [canEdit, canExecute] = usePermission( { resourceScope: { accountIdentifier: accountId, orgIdentifier, projectIdentifier }, resource: { resourceType: ResourceType.PIPELINE, resourceIdentifier: pipelineExecution.pipelineIdentifier as string }, permissions: [PermissionIdentifier.EDIT_PIPELINE, PermissionIdentifier.EXECUTE_PIPELINE] }, [orgIdentifier, projectIdentifier, accountId, pipelineExecution.pipelineIdentifier] ) const disabled = isExecutionNotStarted(pipelineExecution.status) function handleClick(): void { const { pipelineIdentifier, planExecutionId } = pipelineExecution if (!disabled && pipelineIdentifier && planExecutionId) { history.push( routes.toExecutionPipelineView({ orgIdentifier, pipelineIdentifier, executionIdentifier: planExecutionId, projectIdentifier, accountId, module }) ) } } return ( <Card elevation={0} className={cx(css.card, !staticCard && css.hoverCard)} data-disabled={disabled} data-variant={variant} > <div className={cx(!staticCard && css.cardLink)} onClick={handleClick}> <div className={css.content}> <div className={css.header}> <div className={css.info}> <div className={css.nameGroup}> <div className={css.pipelineName}>{pipelineExecution?.name}</div> {variant === CardVariant.Default ? ( <String className={css.executionId} stringID={ module === 'cd' ? 'execution.pipelineIdentifierTextCD' : 'execution.pipelineIdentifierTextCI' } vars={pipelineExecution} /> ) : null} </div> {!isEmpty(pipelineExecution?.tags) ? ( <TagsPopover iconProps={{ size: 14 }} className={css.tags} popoverProps={{ wrapperTagName: 'div', targetTagName: 'div' }} tags={defaultTo(pipelineExecution?.tags, []).reduce((val, tag) => { return Object.assign(val, { [tag.key]: tag.value }) }, {} as { [key: string]: string })} /> ) : null} {pipelineExecution.gitDetails ? ( <GitPopover data={pipelineExecution.gitDetails} iconProps={{ size: 14 }} popoverProps={{ wrapperTagName: 'div', targetTagName: 'div' }} /> ) : null} </div> <div className={css.actions}> <div className={css.statusContainer}> <ExecutionStatusLabel status={pipelineExecution.status as ExecutionStatus} /> {isExecutionIgnoreFailed(pipelineExecution.status) ? ( <Popover wrapperTagName="div" targetTagName="div" interactionKind="hover" popoverClassName={css.ignoreFailedPopover} content={ <String tagName="div" className={css.ignoreFailedTooltip} stringID="pipeline.execution.ignoreFailedWarningText" /> } > <Icon name="warning-sign" size={16} className={css.ignoreWarning} /> </Popover> ) : null} </div> {variant === CardVariant.Default || variant === CardVariant.MinimalWithActions ? ( <ExecutionActions executionStatus={pipelineExecution.status as ExecutionStatus} params={{ accountId, orgIdentifier, pipelineIdentifier: defaultTo(pipelineExecution?.pipelineIdentifier, ''), executionIdentifier: defaultTo(pipelineExecution?.planExecutionId, ''), projectIdentifier, module, repoIdentifier: pipelineExecution?.gitDetails?.repoIdentifier, branch: pipelineExecution?.gitDetails?.branch, stagesExecuted: pipelineExecution?.stagesExecuted }} isPipelineInvalid={isPipelineInvalid} canEdit={canEdit} canExecute={canExecute} canRetry={pipelineExecution.canRetry} modules={pipelineExecution.modules} /> ) : null} </div> </div> <div className={css.main}> <div className={css.modulesContainer}> {pipelineExecution?.stagesExecuted?.length ? ( <Tag className={css.singleExecutionTag}>{`${getString('pipeline.singleStageExecution')} ${ !!pipelineExecution.stagesExecutedNames && Object.values(pipelineExecution.stagesExecutedNames).join(', ') } `}</Tag> ) : null} {HAS_CI && ciInfo ? ( <div className={css.moduleData}> <Icon name={ciInfo.icon} size={20} className={css.moduleIcon} /> {React.createElement<ExecutionCardInfoProps>(ciInfo.component, { data: defaultTo(pipelineExecution?.moduleInfo?.ci, {}), nodeMap: defaultTo(pipelineExecution?.layoutNodeMap, {}), startingNodeId: defaultTo(pipelineExecution?.startingNodeId, ''), variant })} </div> ) : null} {HAS_CD && cdInfo ? ( <div className={css.moduleData}> <Icon name={cdInfo.icon} size={20} className={css.moduleIcon} /> {React.createElement<ExecutionCardInfoProps>(cdInfo.component, { data: defaultTo(pipelineExecution?.moduleInfo?.cd, {}), nodeMap: defaultTo(pipelineExecution?.layoutNodeMap, {}), startingNodeId: defaultTo(pipelineExecution?.startingNodeId, ''), variant })} </div> ) : null} </div> {variant === CardVariant.Default ? ( <MiniExecutionGraph pipelineExecution={pipelineExecution} projectIdentifier={projectIdentifier} orgIdentifier={orgIdentifier} accountId={accountId} module={module} /> ) : null} </div> </div> <ExecutionCardFooter pipelineExecution={pipelineExecution} variant={variant} /> </div> </Card> ) } |