import React from 'react'; import { Alert, DescriptionListDescription, DescriptionListGroup, DescriptionListTerm, } from '@patternfly/react-core'; import { PipelineRunLabel } from '~/consts/pipelinerun'; import { PipelineRunKind } from '~/types'; export type SnapshotCreationStatusType = { message?: string; status?: string; }; type Props = { pipelineRun?: PipelineRunKind; }; export const SnapshotCreationStatus: React.FC = ({ pipelineRun }) => { const snapshotStatusAnnotation = pipelineRun?.metadata?.annotations?.[PipelineRunLabel.CREATE_SNAPSHOT_STATUS]; const snapshotCreationStatus = React.useMemo(() => { try { return JSON.parse(snapshotStatusAnnotation ?? ''); } catch (e) { return null; } }, [snapshotStatusAnnotation]); if (!snapshotCreationStatus?.message) return null; return ( Snapshot creation status {snapshotCreationStatus.status === 'failed' ? ( ) : ( snapshotCreationStatus.message )} ); }; export default SnapshotCreationStatus;