import React from 'react' ; import { MissingAnnotationEmptyState } from '@backstage/core-components' ; import { useEntity } from '@backstage/plugin-catalog-react' ; import { isPrometheusAlertAvailable , PROMETHEUS_ALERT_ANNOTATION , } from '../util' ; import { PrometheusAlertStatus } from './PrometheusAlertStatus' ; export const PrometheusAlertEntityWrapper = ( ) => { const { entity } = useEntity ( ) ; const alertContent = isPrometheusAlertAvailable ( entity ) ; if ( ! alertContent ) { return ( < MissingAnnotationEmptyState annotation = { PROMETHEUS_ALERT_ANNOTATION } / > ) ; } const alerts = alertContent ? entity . metadata . annotations ! ! [ PROMETHEUS_ALERT_ANNOTATION ] . split ( ',' ) : [ ] ; return alerts . length > 0 && alerts [ 0 ] === 'all' ? ( < PrometheusAlertStatus alerts = "all" / > ) : ( < PrometheusAlertStatus alerts = { alerts } / > ) ; } ;