Alerting: Change tooltip error text in collapsed contact point table (#67022)

Change tooltip error message in collapsed contact point table
This commit is contained in:
Sonia Aguilar 2023-04-21 09:37:31 +02:00 committed by GitHub
parent 607b94aaa2
commit 400fae3bd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,10 +3,10 @@ import React, { useMemo, useState } from 'react';
import { dateTime, dateTimeFormat } from '@grafana/data';
import { Stack } from '@grafana/experimental';
import { Button, ConfirmModal, Modal, useStyles2, Badge, Icon } from '@grafana/ui';
import { Badge, Button, ConfirmModal, Icon, Modal, useStyles2 } from '@grafana/ui';
import { contextSrv } from 'app/core/services/context_srv';
import { AlertManagerCortexConfig } from 'app/plugins/datasource/alertmanager/types';
import { useDispatch, AccessControlAction, ContactPointsState, NotifiersState, ReceiversState } from 'app/types';
import { AccessControlAction, ContactPointsState, NotifiersState, ReceiversState, useDispatch } from 'app/types';
import { useGetContactPointsState } from '../../api/receiversApi';
import { Authorize } from '../../components/Authorize';
@ -84,11 +84,13 @@ interface ReceiverErrorProps {
errorCount: number;
errorDetail?: string;
showErrorCount: boolean;
tooltip?: string;
}
function ReceiverError({ errorCount, errorDetail, showErrorCount }: ReceiverErrorProps) {
function ReceiverError({ errorCount, errorDetail, showErrorCount, tooltip }: ReceiverErrorProps) {
const text = showErrorCount ? `${errorCount} ${pluralize('error', errorCount)}` : 'Error';
return <Badge color="orange" icon="exclamation-triangle" text={text} tooltip={errorDetail ?? 'Error'} />;
const tooltipToRender = tooltip ?? errorDetail ?? 'Error';
return <Badge color="orange" icon="exclamation-triangle" text={text} tooltip={tooltipToRender} />;
}
interface NotifierHealthProps {
errorsByNotifier: number;
@ -115,7 +117,11 @@ function ReceiverHealth({ errorsByReceiver, someWithNoAttempt }: ReceiverHealthP
const noErrorsColor = someWithNoAttempt ? 'orange' : 'green';
const noErrorsText = someWithNoAttempt ? 'No attempts' : 'OK';
return errorsByReceiver > 0 ? (
<ReceiverError errorCount={errorsByReceiver} showErrorCount={true} />
<ReceiverError
errorCount={errorsByReceiver}
showErrorCount={true}
tooltip="Expand the contact point to see error details."
/>
) : (
<Badge color={noErrorsColor} text={noErrorsText} tooltip="" />
);