import * as React from 'react'; import { Link } from 'react-router-dom'; import { Button, CodeBlock, CodeBlockCode, DescriptionList, DescriptionListDescription, DescriptionListGroup, DescriptionListTerm, 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 PipelineIcon from '../../../../assets/pipelineIcon.svg'; import { PipelineRunLabel } from '../../../../consts/pipelinerun'; import { COMPONENT_DETAILS_PATH, INTEGRATION_TEST_DETAILS_PATH, PIPELINE_RUNS_LOG_PATH, } from '../../../../routes/paths'; import { ErrorDetailsWithStaticLog } from '../../../../shared/components/pipeline-run-logs/logs/log-snippet-types'; import { getPLRLogSnippet } from '../../../../shared/components/pipeline-run-logs/logs/pipelineRunLogSnippet'; import { Timestamp } from '../../../../shared/components/timestamp/Timestamp'; import { useNamespace } from '../../../../shared/providers/Namespace'; import { PipelineRunKind } from '../../../../types'; import { calculateDuration } from '../../../../utils/pipeline-utils'; import ScanDescriptionListGroup from '../../../PipelineRun/PipelineRunDetailsView/tabs/ScanDescriptionListGroup'; import { StatusIconWithTextLabel } from '../../../topology/StatusIcon'; import { CommitWorkflowNodeModelData } from '../visualization/commit-visualization-types'; import { CommitIntegrationTestsList } from './CommitIntegrationTestsList'; export interface IntegrationTestSidePanelBodyProps { onClose: () => void; workflowNode: GraphElement; } const IntegrationTestSidePanel: React.FC< React.PropsWithChildren > = ({ workflowNode, onClose }) => { const namespace = useNamespace(); const workflowData = workflowNode.getData(); const integrationTestPipeline = workflowData.resource as PipelineRunKind; const [taskRuns, taskRunsLoaded, taskRunsError] = useTaskRunsForPipelineRuns( namespace, integrationTestPipeline?.metadata.name, ); const duration = integrationTestPipeline ? calculateDuration( typeof integrationTestPipeline.status?.startTime === 'string' ? integrationTestPipeline.status?.startTime : '', typeof integrationTestPipeline.status?.completionTime === 'string' ? integrationTestPipeline.status?.completionTime : '', ) : '-'; const pipelineRunFailed = (getPLRLogSnippet(integrationTestPipeline, taskRuns) || {}) as ErrorDetailsWithStaticLog; return ( <> {integrationTestPipeline ? ( {workflowNode.getLabel()} ) : ( workflowNode.getLabel() )} Integration test{' '} Started Duration {duration ?? '-'} Type Test Pipeline {integrationTestPipeline?.metadata?.namespace ?? '-'} Component {integrationTestPipeline?.metadata?.labels?.[PipelineRunLabel.COMPONENT] ? ( integrationTestPipeline?.metadata?.labels?.[PipelineRunLabel.APPLICATION] ? ( {integrationTestPipeline.metadata.labels[PipelineRunLabel.COMPONENT]} ) : ( integrationTestPipeline?.metadata.labels[PipelineRunLabel.COMPONENT] ) ) : ( '-' )} {integrationTestPipeline && taskRunsLoaded && !taskRunsError ? ( ) : null} {Object.keys(pipelineRunFailed).length > 0 && ( Message {pipelineRunFailed.title ?? '-'} Log snippet {pipelineRunFailed.staticMessage ?? '-'} {integrationTestPipeline ? ( ) : null} )} ); }; export default IntegrationTestSidePanel;