-
Notifications
You must be signed in to change notification settings - Fork 11.7k
/
RuleConfigStatus.tsx
52 lines (44 loc) · 1.38 KB
/
RuleConfigStatus.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { css } from '@emotion/css';
import React, { useMemo } from 'react';
import { GrafanaTheme2 } from '@grafana/data/src';
import { config } from '@grafana/runtime/src';
import { Icon, Tooltip, useStyles2 } from '@grafana/ui/src';
import { CombinedRule } from '../../../../../types/unified-alerting';
import { checkEvaluationIntervalGlobalLimit } from '../../utils/config';
interface RuleConfigStatusProps {
rule: CombinedRule;
}
export function RuleConfigStatus({ rule }: RuleConfigStatusProps) {
const styles = useStyles2(getStyles);
const { exceedsLimit } = useMemo(
() => checkEvaluationIntervalGlobalLimit(rule.group.interval),
[rule.group.interval]
);
if (!exceedsLimit) {
return null;
}
return (
<Tooltip
theme="error"
content={
<div>
A minimum evaluation interval of{' '}
<span className={styles.globalLimitValue}>{config.unifiedAlerting.minInterval}</span> has been configured in
Grafana and will be used instead of the {rule.group.interval} interval configured for the Rule Group.
</div>
}
>
<Icon name="stopwatch-slash" className={styles.icon} />
</Tooltip>
);
}
function getStyles(theme: GrafanaTheme2) {
return {
globalLimitValue: css`
font-weight: ${theme.typography.fontWeightBold};
`,
icon: css`
fill: ${theme.colors.warning.text};
`,
};
}