import { Link, useParams } from 'react-router-dom'; import { Bullseye, Spinner, Title, DescriptionList, DescriptionListGroup, DescriptionListTerm, DescriptionListDescription, CodeBlock, CodeBlockCode, ClipboardCopy, Button, Flex, FlexItem, } from '@patternfly/react-core'; import GitRepoLink from '~/components/GitLink/GitRepoLink'; import MetadataList from '~/components/MetadataList'; import { useModalLauncher } from '~/components/modal/ModalProvider'; import RelatedNamespacePipelineRuns from '~/components/PipelineRun/NamespacePipelineRunDetails/RelatedNamespacePipelineRuns'; import { createPipelineRunSBOMsModal } from '~/components/PipelineRun/PipelineRunDetailsView/tabs/PipelineRunSBOMsModal'; import RunParamsList from '~/components/PipelineRun/PipelineRunDetailsView/tabs/RunParamsList'; import RunResultsList from '~/components/PipelineRun/PipelineRunDetailsView/tabs/RunResultsList'; import ScanDescriptionListGroup from '~/components/PipelineRun/PipelineRunDetailsView/tabs/ScanDescriptionListGroup'; import { SnapshotCreationStatus } from '~/components/PipelineRun/PipelineRunDetailsView/tabs/SnapshotCreationStatus'; import { usePipelineRunImageData } from '~/components/PipelineRun/PipelineRunDetailsView/usePipelineRunImageData'; import { getSBOMsFromTaskRuns } from '~/components/PipelineRun/PipelineRunDetailsView/utils/pipelinerun-utils'; import PipelineRunVisualization from '~/components/PipelineRun/PipelineRunDetailsView/visualization/PipelineRunVisualization'; import { StatusIconWithText } from '~/components/StatusIcon/StatusIcon'; import { PipelineRunLabel } from '~/consts/pipelinerun'; import { usePipelineRunV2 } from '~/hooks/usePipelineRunsV2'; import { useTaskRunsForPipelineRuns } from '~/hooks/useTaskRunsV2'; import { useSbomUrl } from '~/hooks/useUIInstance'; import { COMPONENT_DETAILS_V2_PATH, GROUP_DETAILS_PATH, GROUP_SNAPSHOT_DETAILS_PATH, GROUP_INTEGRATION_TEST_DETAILS_PATH, } from '~/routes/paths'; import { Timestamp } from '~/shared'; import ExternalLink from '~/shared/components/links/ExternalLink'; import { getPLRLogSnippet } from '~/shared/components/pipeline-run-logs/logs/pipelineRunLogSnippet'; import { useNamespace } from '~/shared/providers/Namespace'; import { getErrorState } from '~/shared/utils/error-utils'; import { getCommitSha, getCommitShortName } from '~/utils/commits-utils'; import { getPipelineRunDetailsPath } from '~/utils/pipeline-run-routes'; import { calculateDuration, pipelineRunStatus } from '~/utils/pipeline-utils'; import { getSourceUrl } from '~/utils/pipelinerun-utils'; const NamespacePipelineRunDetailsTab = () => { const { pipelineRunName } = useParams(); const namespace = useNamespace(); const [run, loaded, error] = usePipelineRunV2(namespace, pipelineRunName); const [tasks, tasksLoaded, taskError] = useTaskRunsForPipelineRuns(namespace, pipelineRunName); const generateSbomUrl = useSbomUrl(); const showModal = useModalLauncher(); const { results, params: runParams, imageUrl: image } = usePipelineRunImageData(run, namespace); if (!loaded || !tasksLoaded) return ( ); if (error) return getErrorState(error, loaded, 'pipeline run'); if (!run) return getErrorState({ code: 404 }, true, 'pipeline run'); const labels = run.metadata.labels; const groupName = labels?.[PipelineRunLabel.COMPONENT_GROUP]; const componentName = labels?.[PipelineRunLabel.COMPONENT]; const snapshotName = run.metadata.annotations?.[PipelineRunLabel.SNAPSHOT] || labels?.[PipelineRunLabel.SNAPSHOT]; const integrationTestName = labels?.[PipelineRunLabel.TEST_SERVICE_SCENARIO]; const params = { workspaceName: namespace, groupName }; const status = pipelineRunStatus(run); const snippet = getPLRLogSnippet(run, tasks); const source = getSourceUrl(run); const sha = getCommitSha(run); const commitUrl = run.metadata.annotations?.[PipelineRunLabel.COMMIT_URL_ANNOTATION]; const sboms = getSBOMsFromTaskRuns(tasks, generateSbomUrl); const failureMessage = run.status?.conditions?.find( (condition) => condition.type === 'Succeeded', )?.message; const staticMessage = snippet && 'staticMessage' in snippet ? snippet.staticMessage : undefined; return ( <> Pipeline run details {taskError ? ( getErrorState(taskError, tasksLoaded, 'task runs', true) ) : ( )} Name {run.metadata.name || '-'} Namespace {namespace || '-'} Labels Annotations Created at Duration {calculateDuration( typeof run.status?.startTime === 'string' ? run.status.startTime : '', typeof run.status?.completionTime === 'string' ? run.status.completionTime : '', ) || '-'} Status {snippet && ( <> Message {snippet.title} {failureMessage && failureMessage !== staticMessage && ( {failureMessage} )} Log snippet {staticMessage ?? '-'} See logs )} Pipeline {labels?.[PipelineRunLabel.PIPELINE_NAME] || '-'} {snapshotName && ( Snapshot {groupName ? ( {snapshotName} ) : ( snapshotName )} )} {image && ( Download SBOM {`cosign download sbom ${image}`} )} {sboms.length > 0 && ( SBOM {sboms.length === 1 ? ( View SBOM ) : ( )} )} Component group {groupName ? ( {groupName} ) : ( '-' )} Component {componentName ? ( {componentName} ) : ( '-' )} {sha && ( Commit {commitUrl ? ( {getCommitShortName(sha)} ) : ( getCommitShortName(sha) )} )} {source && ( Source )} {integrationTestName && ( Integration test {groupName ? ( {integrationTestName} ) : ( integrationTestName )} )} Related pipeline runs {!!results?.length && (
)} {!!runParams?.length && (
)} ); }; export default NamespacePipelineRunDetailsTab;