diff --git a/public/app/features/alerting/unified/components/Strong.tsx b/public/app/features/alerting/unified/components/Strong.tsx deleted file mode 100644 index 14f4f87adf3..00000000000 --- a/public/app/features/alerting/unified/components/Strong.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import React, { ReactNode } from 'react'; - -import { Text } from '@grafana/ui'; - -interface Props { - children: NonNullable; -} - -const Strong = ({ children }: Props) => { - return {children}; -}; - -export { Strong }; diff --git a/public/app/features/alerting/unified/components/alert-groups/AlertGroup.tsx b/public/app/features/alerting/unified/components/alert-groups/AlertGroup.tsx index c6ba937c33b..0c3d7232ac1 100644 --- a/public/app/features/alerting/unified/components/alert-groups/AlertGroup.tsx +++ b/public/app/features/alerting/unified/components/alert-groups/AlertGroup.tsx @@ -2,13 +2,13 @@ import { css } from '@emotion/css'; import React, { useState } from 'react'; import { GrafanaTheme2 } from '@grafana/data'; -import { useStyles2, Stack } from '@grafana/ui'; +import { useStyles2, Stack, TextLink } from '@grafana/ui'; import { AlertmanagerGroup, AlertState } from 'app/plugins/datasource/alertmanager/types'; +import { createContactPointLink } from '../../utils/misc'; import { AlertLabels } from '../AlertLabels'; import { CollapseToggle } from '../CollapseToggle'; import { MetaText } from '../MetaText'; -import { Strong } from '../Strong'; import { AlertGroupAlertsTable } from './AlertGroupAlertsTable'; import { AlertGroupHeader } from './AlertGroupHeader'; @@ -21,8 +21,11 @@ interface Props { export const AlertGroup = ({ alertManagerSourceName, group }: Props) => { const [isCollapsed, setIsCollapsed] = useState(true); const styles = useStyles2(getStyles); + // When group is grouped, receiver.name is 'NONE' as it can contain multiple receivers const receiverInGroup = group.receiver.name !== 'NONE'; + const contactPoint = group.receiver.name; + return (
@@ -39,7 +42,15 @@ export const AlertGroup = ({ alertManagerSourceName, group }: Props) => { {receiverInGroup && ( - Delivered to {group.receiver.name} + Delivered to{' '} + + {group.receiver.name} + )} diff --git a/public/app/features/alerting/unified/components/contact-points/ContactPoints.test.tsx b/public/app/features/alerting/unified/components/contact-points/ContactPoints.test.tsx index 0779b398c72..8fe4f17e61e 100644 --- a/public/app/features/alerting/unified/components/contact-points/ContactPoints.test.tsx +++ b/public/app/features/alerting/unified/components/contact-points/ContactPoints.test.tsx @@ -239,7 +239,7 @@ describe('contact points', () => { wrapper, }); - expect(screen.getByRole('link', { name: 'is used by 1 notification policy' })).toBeInTheDocument(); + expect(screen.getByRole('link', { name: /1 notification policy/ })).toBeInTheDocument(); const moreActions = screen.getByRole('button', { name: /More/ }); await userEvent.click(moreActions); diff --git a/public/app/features/alerting/unified/components/contact-points/ContactPoints.tsx b/public/app/features/alerting/unified/components/contact-points/ContactPoints.tsx index f8733d208b9..4bcc0428a68 100644 --- a/public/app/features/alerting/unified/components/contact-points/ContactPoints.tsx +++ b/public/app/features/alerting/unified/components/contact-points/ContactPoints.tsx @@ -4,7 +4,6 @@ import { SerializedError } from '@reduxjs/toolkit'; import { groupBy, size, uniq, upperFirst } from 'lodash'; import pluralize from 'pluralize'; import React, { Fragment, ReactNode, useCallback, useMemo, useState } from 'react'; -import { Link } from 'react-router-dom'; import { useToggle } from 'react-use'; import { dateTime, GrafanaTheme2 } from '@grafana/data'; @@ -22,6 +21,7 @@ import { TabContent, TabsBar, Text, + TextLink, Tooltip, useStyles2, } from '@grafana/ui'; @@ -42,7 +42,6 @@ import { MetaText } from '../MetaText'; import MoreButton from '../MoreButton'; import { ProvisioningBadge } from '../Provisioning'; import { Spacer } from '../Spacer'; -import { Strong } from '../Strong'; import { GrafanaReceiverExporter } from '../export/GrafanaReceiverExporter'; import { GrafanaReceiversExporter } from '../export/GrafanaReceiversExporter'; import { ReceiverMetadataBadge } from '../receivers/grafanaAppReceivers/ReceiverMetadataBadge'; @@ -444,11 +443,17 @@ const ContactPointHeader = (props: ContactPointHeaderProps) => { {isReferencedByAnyPolicy && ( - - - is used by {numberOfPolicies} {pluralize('notification policy', numberOfPolicies)} - - + + is used by{' '} + + {`${numberOfPolicies} ${pluralize('notification policy', numberOfPolicies)}`} + + )} {provisioned && } {!isReferencedByAnyPolicy && } @@ -612,12 +617,12 @@ const ContactPointReceiverMetadataRow = ({ diagnostics, sendingResolved }: Conta Last delivery attempt{' '} - {lastDeliveryAttempt.locale('en').fromNow()} + {lastDeliveryAttempt.locale('en').fromNow()} - took {lastDeliveryAttemptDuration} + took {lastDeliveryAttemptDuration} )} @@ -626,7 +631,7 @@ const ContactPointReceiverMetadataRow = ({ diagnostics, sendingResolved }: Conta {/* this is only shown for contact points that only want "firing" updates */} {!sendingResolved && ( - Delivering only firing notifications + Delivering only firing notifications )} diff --git a/public/app/features/alerting/unified/components/notification-policies/Policy.tsx b/public/app/features/alerting/unified/components/notification-policies/Policy.tsx index 2acbb8f6732..3652bd64281 100644 --- a/public/app/features/alerting/unified/components/notification-policies/Policy.tsx +++ b/public/app/features/alerting/unified/components/notification-policies/Policy.tsx @@ -2,7 +2,6 @@ import { css } from '@emotion/css'; import { defaults, groupBy, isArray, sumBy, uniqueId, upperFirst } from 'lodash'; import pluralize from 'pluralize'; import React, { FC, Fragment, ReactNode, useState } from 'react'; -import { Link } from 'react-router-dom'; import { useToggle } from 'react-use'; import { GrafanaTheme2 } from '@grafana/data'; @@ -16,6 +15,7 @@ import { Menu, Stack, Text, + TextLink, Tooltip, getTagColorsFromName, useStyles2, @@ -44,7 +44,6 @@ import { Label } from '../Label'; import { MetaText } from '../MetaText'; import { ProvisioningBadge } from '../Provisioning'; import { Spacer } from '../Spacer'; -import { Strong } from '../Strong'; import { GrafanaPoliciesExporter } from '../export/GrafanaPoliciesExporter'; import { Matchers } from './Matchers'; @@ -447,7 +446,7 @@ function MetadataRow({ }} data-testid="matching-instances" > - {numberOfAlertInstances ?? '-'} + {numberOfAlertInstances ?? '-'} {pluralize('instance', numberOfAlertInstances)} )} @@ -466,7 +465,7 @@ function MetadataRow({ {customGrouping && ( Grouped by - {groupBy.join(', ')} + {groupBy.join(', ')} )} {singleGroup && ( @@ -670,19 +669,13 @@ const InheritedProperties: FC<{ properties: InheritableProperties }> = ({ proper return null; } - return ( -