import * as React from 'react'; import { Link } from 'react-router-dom'; import { DescriptionList, DescriptionListDescription, DescriptionListGroup, DescriptionListTerm, Divider, DrawerActions, DrawerCloseButton, DrawerHead, DrawerPanelBody, } from '@patternfly/react-core'; import { ElementModel, GraphElement } from '@patternfly/react-topology'; import { FeatureFlagIndicator } from '~/feature-flags/FeatureFlagIndicator'; import { useTaskRunsForPipelineRuns } from '~/hooks/useTaskRunsV2'; import { useNamespace } from '~/shared/providers/Namespace'; import PipelineIcon from '../../../../assets/pipelineIcon.svg'; import { PipelineRunLabel } from '../../../../consts/pipelinerun'; import { PIPELINE_RUNS_DETAILS_PATH, COMPONENT_DETAILS_PATH, PIPELINE_RUNS_LOG_PATH, } from '../../../../routes/paths'; import { Timestamp } from '../../../../shared/components/timestamp/Timestamp'; import { PipelineRunKind } from '../../../../types'; import { calculateDuration, pipelineRunStatus, isPipelineV1Beta1, } from '../../../../utils/pipeline-utils'; import RunParamsList from '../../../PipelineRun/PipelineRunDetailsView/tabs/RunParamsList'; import RunResultsList from '../../../PipelineRun/PipelineRunDetailsView/tabs/RunResultsList'; import ScanDescriptionListGroup from '../../../PipelineRun/PipelineRunDetailsView/tabs/ScanDescriptionListGroup'; import { StatusIconWithTextLabel } from '../../../topology/StatusIcon'; import { CommitWorkflowNodeModelData } from '../visualization/commit-visualization-types'; export interface PipelineSidePanelBodyProps { onClose: () => void; workflowNode: GraphElement; } const BuildSidePanel: React.FC> = ({ workflowNode, onClose, }) => { const namespace = useNamespace(); const workflowData = workflowNode.getData(); const pipelineRun = workflowData.resource as PipelineRunKind; const [taskRuns, taskRunsLoaded, taskRunsError] = useTaskRunsForPipelineRuns( namespace, pipelineRun?.metadata?.name ?? '', ); if (!pipelineRun) { return null; } const duration = calculateDuration( typeof pipelineRun.status?.startTime === 'string' ? pipelineRun.status?.startTime : '', typeof pipelineRun.status?.completionTime === 'string' ? pipelineRun.status?.completionTime : '', ); const pipelineStatus = pipelineRunStatus(pipelineRun); const results = isPipelineV1Beta1(pipelineRun) ? pipelineRun.status?.pipelineResults : pipelineRun.status?.results; const specParams = pipelineRun?.spec?.params; return ( <> {pipelineRun.metadata.name} Pipeline run{' '} Created at Duration {duration ?? '-'} Type Build Pipeline {pipelineRun.metadata?.labels[PipelineRunLabel.PIPELINE_NAME] ?? '-'} Component {pipelineRun.metadata?.labels?.[PipelineRunLabel.COMPONENT] ? ( pipelineRun.metadata?.labels?.[PipelineRunLabel.APPLICATION] ? ( {pipelineRun.metadata.labels[PipelineRunLabel.COMPONENT]} ) : ( pipelineRun.metadata.labels[PipelineRunLabel.COMPONENT] ) ) : ( '-' )} {taskRunsLoaded && !taskRunsError && ( )} View logs {results ? (
) : null} {specParams?.length && ( <> )}
); }; export default BuildSidePanel;