import React , { FC } from 'react' ; import { EuiIcon , EuiToolTip } from '@elastic/eui' ; import { AuditMessageBase } from '../../../common/types/messages' ; interface Props { message : AuditMessageBase ; showTooltip ? : boolean ; } const [ INFO , WARNING , ERROR ] = [ 'info' , 'warning' , 'error' ] ; export const JobIcon = ( { message , showTooltip = false } ) => { if ( message === undefined ) { return < span />; } let color = 'primary' ; const icon = 'alert' ; if ( message . level === INFO ) { color = 'primary' ; } else if ( message . level === WARNING ) { color = 'warning' ; } else if ( message . level === ERROR ) { color = 'danger' ; } if ( showTooltip ) { return ( < EuiToolTip position = "bottom" content = { message . text } > < EuiIcon type = { icon } color = { color } / > < /EuiToolTip>); } else { return < EuiIcon type = { icon } color = { color } / > ; } } ;