From 845128dde9c393a4f4fd1e6a38341327e3734ef1 Mon Sep 17 00:00:00 2001 From: Gilles De Mey Date: Thu, 19 Jan 2023 21:51:45 +0100 Subject: [PATCH] Alerting: Swap templates and contact points places (#61808) Alerting: swap templates and contact points places --- .../receivers/ReceiversAndTemplatesView.tsx | 21 ++++++---------- .../components/receivers/ReceiversSection.tsx | 8 +++--- .../components/receivers/ReceiversTable.tsx | 25 +------------------ 3 files changed, 13 insertions(+), 41 deletions(-) diff --git a/public/app/features/alerting/unified/components/receivers/ReceiversAndTemplatesView.tsx b/public/app/features/alerting/unified/components/receivers/ReceiversAndTemplatesView.tsx index 88d4533b8bf..ceaf42f4e2a 100644 --- a/public/app/features/alerting/unified/components/receivers/ReceiversAndTemplatesView.tsx +++ b/public/app/features/alerting/unified/components/receivers/ReceiversAndTemplatesView.tsx @@ -1,8 +1,7 @@ -import { css } from '@emotion/css'; import React, { FC } from 'react'; -import { GrafanaTheme2 } from '@grafana/data'; -import { Alert, LinkButton, useStyles2 } from '@grafana/ui'; +import { Stack } from '@grafana/experimental'; +import { Alert, LinkButton } from '@grafana/ui'; import { AlertManagerCortexConfig } from 'app/plugins/datasource/alertmanager/types'; import { AccessControlAction } from 'app/types'; @@ -20,15 +19,15 @@ interface Props { export const ReceiversAndTemplatesView: FC = ({ config, alertManagerName }) => { const isCloud = alertManagerName !== GRAFANA_RULES_SOURCE_NAME; - const styles = useStyles2(getStyles); const isVanillaAM = isVanillaPrometheusAlertManagerDataSource(alertManagerName); + return ( - <> - {!isVanillaAM && } + + {!isVanillaAM && } {isCloud && ( - +

For each external Alertmanager you can define global settings, like server addresses, usernames and password, for all the supported contact points. @@ -39,12 +38,6 @@ export const ReceiversAndTemplatesView: FC = ({ config, alertManagerName )} - + ); }; - -const getStyles = (theme: GrafanaTheme2) => ({ - section: css` - margin-top: ${theme.spacing(4)}; - `, -}); diff --git a/public/app/features/alerting/unified/components/receivers/ReceiversSection.tsx b/public/app/features/alerting/unified/components/receivers/ReceiversSection.tsx index 87acc6530be..c31ad0c7891 100644 --- a/public/app/features/alerting/unified/components/receivers/ReceiversSection.tsx +++ b/public/app/features/alerting/unified/components/receivers/ReceiversSection.tsx @@ -3,6 +3,7 @@ import React from 'react'; import { Link } from 'react-router-dom'; import { GrafanaTheme2 } from '@grafana/data'; +import { Stack } from '@grafana/experimental'; import { Button, useStyles2 } from '@grafana/ui'; interface Props { @@ -25,11 +26,11 @@ export const ReceiversSection = ({ }: React.PropsWithChildren) => { const styles = useStyles2(getStyles); return ( - <> +

{title}

-

{description}

+
{description}
{showButton && ( @@ -40,7 +41,7 @@ export const ReceiversSection = ({ )}
{children} - +
); }; @@ -48,6 +49,7 @@ const getStyles = (theme: GrafanaTheme2) => ({ heading: css` display: flex; justify-content: space-between; + align-items: flex-end; `, description: css` color: ${theme.colors.text.secondary}; diff --git a/public/app/features/alerting/unified/components/receivers/ReceiversTable.tsx b/public/app/features/alerting/unified/components/receivers/ReceiversTable.tsx index 3eaa0851f7e..b3654602d8f 100644 --- a/public/app/features/alerting/unified/components/receivers/ReceiversTable.tsx +++ b/public/app/features/alerting/unified/components/receivers/ReceiversTable.tsx @@ -1,8 +1,7 @@ -import { css } from '@emotion/css'; import pluralize from 'pluralize'; import React, { FC, useMemo, useState } from 'react'; -import { GrafanaTheme2, dateTime, dateTimeFormat } from '@grafana/data'; +import { dateTime, dateTimeFormat } from '@grafana/data'; import { Stack } from '@grafana/experimental'; import { Button, ConfirmModal, Modal, useStyles2, Badge, Icon } from '@grafana/ui'; import { contextSrv } from 'app/core/services/context_srv'; @@ -241,7 +240,6 @@ interface Props { export const ReceiversTable: FC = ({ config, alertManagerName }) => { const dispatch = useDispatch(); - const styles = useStyles2(getStyles); const isVanillaAM = isVanillaPrometheusAlertManagerDataSource(alertManagerName); const permissions = getNotificationsPermissions(alertManagerName); const grafanaNotifiers = useUnifiedAlertingSelector((state) => state.grafanaNotifiers); @@ -299,7 +297,6 @@ export const ReceiversTable: FC = ({ config, alertManagerName }) => { return ( ({ - section: css` - margin-top: ${theme.spacing(4)}; - `, - warning: css` - color: ${theme.colors.warning.text}; - `, - countMessage: css``, - onCallBadgeWrapper: css` - text-align: left; - height: 22px; - display: inline-flex; - padding: 1px 4px; - border-radius: 3px; - border: 1px solid rgba(245, 95, 62, 1); - color: rgba(245, 95, 62, 1); - font-weight: ${theme.typography.fontWeightRegular}; - `, -});