import { css } from '@emotion/css';
import React from 'react';
import { GrafanaTheme2 } from '@grafana/data';
import { Badge, clearButtonStyles, useStyles2 } from '@grafana/ui';
interface AlertConditionProps {
enabled?: boolean;
error?: Error;
warning?: Error;
onSetCondition?: () => void;
}
export const AlertConditionIndicator = ({ enabled = false, error, warning, onSetCondition }: AlertConditionProps) => {
const styles = useStyles2(getStyles);
if (enabled && error) {
return ;
}
if (enabled && warning) {
return ;
}
if (enabled && !error && !warning) {
return ;
}
if (!enabled) {
return (
);
}
return null;
};
const getStyles = (theme: GrafanaTheme2) => {
const clearButton = clearButtonStyles(theme);
return {
actionLink: css`
${clearButton};
color: ${theme.colors.text.link};
cursor: pointer;
&:hover {
text-decoration: underline;
}
`,
};
};