/********************************************************************* * © Copyright IBM Corp. 2024 *********************************************************************/ import React from 'react' import PropTypes from 'prop-types' import { FontColorSuccess, FontColorError, FontColorWarning, Third, Second } from '@targetprocess/css-variables' export const Types = { passed: 'passed', failed: 'failed', pending: 'pending', running: 'running', skipped: 'skipped', warning: 'warning', cancelled: 'cancelled' } export const Color = { [Types.passed]: FontColorSuccess, [Types.failed]: FontColorError, [Types.pending]: FontColorWarning, [Types.running]: Third, [Types.skipped]: Second, [Types.warning]: FontColorWarning, [Types.cancelled]: Second } const Path: {[key: string]: (color: string) => JSX.Element | JSX.Element[]} = { [Types.passed]: color => ( ), [Types.failed]: color => ( ), [Types.pending]: color => ( ), [Types.running]: color => ( ), [Types.skipped]: color => [ , ], [Types.warning]: color => ( ), [Types.cancelled]: color => [ , ] } export interface PipelineIconProps { color?: string type: keyof typeof Types } export const PipelineIcon = (props: PipelineIconProps) => { const iconColor = props.color || Color[props.type] return ( {Path[props.type] && Path[props.type](iconColor)} ) } PipelineIcon.category = 'Messages' PipelineIcon.propTypes = { color: PropTypes.string, type: PropTypes.oneOf(Object.keys(Types)) } PipelineIcon.Types = Types