[Monitoring] Update Kibana rules/alerts language in setup mode (#102441) (#102979)

This commit is contained in:
Lisa Cawley 2021-06-22 13:28:09 -07:00 committed by GitHub
parent 3d4521b32e
commit 8792ca1b13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,13 +19,18 @@ import { getAlertPanelsByCategory } from './lib/get_alert_panels_by_category';
import { getAlertPanelsByNode } from './lib/get_alert_panels_by_node';
export const numberOfAlertsLabel = (count: number) => `${count} alert${count > 1 ? 's' : ''}`;
export const numberOfRulesLabel = (count: number) => `${count} rule${count > 1 ? 's' : ''}`;
const MAX_TO_SHOW_BY_CATEGORY = 8;
const PANEL_TITLE = i18n.translate('xpack.monitoring.alerts.badge.panelTitle', {
const PANEL_TITLE_ALERTS = i18n.translate('xpack.monitoring.alerts.badge.panelTitle', {
defaultMessage: 'Alerts',
});
const PANEL_TITLE_RULES = i18n.translate('xpack.monitoring.rules.badge.panelTitle', {
defaultMessage: 'Rules',
});
const GROUP_BY_NODE = i18n.translate('xpack.monitoring.alerts.badge.groupByNode', {
defaultMessage: 'Group by node',
});
@ -54,6 +59,7 @@ export const AlertsBadge: React.FC<Props> = (props: Props) => {
const [showByNode, setShowByNode] = React.useState(
!inSetupMode && alertCount > MAX_TO_SHOW_BY_CATEGORY
);
const PANEL_TITLE = inSetupMode ? PANEL_TITLE_RULES : PANEL_TITLE_ALERTS;
React.useEffect(() => {
if (inSetupMode && showByNode) {
@ -93,10 +99,12 @@ export const AlertsBadge: React.FC<Props> = (props: Props) => {
<EuiBadge
iconType="bell"
color={inSetupMode ? 'default' : 'danger'}
onClickAriaLabel={numberOfAlertsLabel(alertCount)}
onClickAriaLabel={
inSetupMode ? numberOfRulesLabel(alertCount) : numberOfAlertsLabel(alertCount)
}
onClick={() => setShowPopover(true)}
>
{numberOfAlertsLabel(alertCount)}
{inSetupMode ? numberOfRulesLabel(alertCount) : numberOfAlertsLabel(alertCount)}
</EuiBadge>
);