Update alert state tag to display Paused as its own "state"

This commit is contained in:
Tom Ratcliffe
2024-03-25 18:22:17 +00:00
committed by Tom Ratcliffe
parent a881e7e404
commit 93fd11fe86

View File

@@ -1,6 +1,7 @@
import React from 'react'; import React from 'react';
import { AlertState } from '@grafana/data'; import { AlertState } from '@grafana/data';
import { Tag, Tooltip } from '@grafana/ui';
import { GrafanaAlertState, GrafanaAlertStateWithReason, PromAlertingRuleState } from 'app/types/unified-alerting-dto'; import { GrafanaAlertState, GrafanaAlertStateWithReason, PromAlertingRuleState } from 'app/types/unified-alerting-dto';
import { alertStateToReadable, alertStateToState } from '../../utils/rules'; import { alertStateToReadable, alertStateToState } from '../../utils/rules';
@@ -12,9 +13,18 @@ interface Props {
muted?: boolean; muted?: boolean;
} }
export const AlertStateTag = React.memo(({ state, isPaused = false, size = 'md', muted = false }: Props) => ( export const AlertStateTag = React.memo(({ state, isPaused = false, size = 'md', muted = false }: Props) => {
if (isPaused) {
return (
<Tooltip content={'Alert evaluation is currently paused'} placement="top">
<Tag icon="pause" name="Paused" colorIndex={1} />
</Tooltip>
);
}
return (
<StateTag state={alertStateToState(state)} size={size} muted={muted}> <StateTag state={alertStateToState(state)} size={size} muted={muted}>
{alertStateToReadable(state)} {isPaused ? ' (Paused)' : ''} {alertStateToReadable(state)}
</StateTag> </StateTag>
)); );
});
AlertStateTag.displayName = 'AlertStateTag'; AlertStateTag.displayName = 'AlertStateTag';