import { has } from 'lodash'; import React from 'react'; import type { Application } from '../../../application/application.model'; import type { IExecution } from '../../../domain'; import { ExecutionBuildLink } from '../../../pipeline/executionBuild/ExecutionBuildLink'; import { ExecutionMarker } from '../../../pipeline/executions/execution/ExecutionMarker'; import { ReactInjector } from '../../../reactShims'; import { timestamp } from '../../../utils/timeFormatters'; import './projectPipeline.less'; export interface IProjectPipelineProps { application: Application; execution: IExecution; } export interface IProjectPipelineState { hasBuildInfo: boolean; loaded: boolean; stageWidth: string; } export class ProjectPipeline extends React.Component { constructor(props: IProjectPipelineProps) { super(props); this.state = { hasBuildInfo: this.props.execution.buildInfo || has(this.props.execution, 'trigger.buildInfo') || has(this.props.execution, 'trigger.parentPipelineId'), loaded: true, stageWidth: `${100 / this.props.execution.stageSummaries.length}%`, }; } private handleExecutionTitleClick = (): void => { ReactInjector.$state.go('^.application.pipelines.executions.execution', { application: this.props.execution.application, executionId: this.props.execution.id, }); }; private handleStageClick = (stageIndex: number) => { ReactInjector.$state.go('^.application.pipelines.executionDetails.execution', { application: this.props.execution.application, executionId: this.props.execution.id, stage: stageIndex, }); }; public render() { const execution = this.props.execution; const stages = execution.stageSummaries.map((stage) => ( )); return (
{`${execution.application.toUpperCase()}: ${execution.name}`}
 ( {this.state.hasBuildInfo && , } started {timestamp(this.props.execution.startTime)})
{stages}
); } }