From 089305e39914fee2e81bf33ff543d08b1ad4c47e Mon Sep 17 00:00:00 2001 From: Gilles De Mey Date: Fri, 7 Jul 2023 13:00:53 +0200 Subject: [PATCH] Alerting: improve provisioning indicator for notification policies (#71160) --- .../alerting/unified/NotificationPolicies.tsx | 5 +- .../contact-points/ContactPoints.v2.tsx | 5 +- .../notification-policies/Policy.tsx | 96 +++++++++++-------- .../components/rule-editor/FolderAndGroup.tsx | 5 +- 4 files changed, 65 insertions(+), 46 deletions(-) diff --git a/public/app/features/alerting/unified/NotificationPolicies.tsx b/public/app/features/alerting/unified/NotificationPolicies.tsx index fce3f746176..e31e212a253 100644 --- a/public/app/features/alerting/unified/NotificationPolicies.tsx +++ b/public/app/features/alerting/unified/NotificationPolicies.tsx @@ -16,7 +16,6 @@ import { alertmanagerApi } from './api/alertmanagerApi'; import { useGetContactPointsState } from './api/receiversApi'; import { AlertmanagerPageWrapper } from './components/AlertingPageWrapper'; import { GrafanaAlertmanagerDeliveryWarning } from './components/GrafanaAlertmanagerDeliveryWarning'; -import { ProvisionedResource, ProvisioningAlert } from './components/Provisioning'; import { MuteTimingsTable } from './components/mute-timings/MuteTimingsTable'; import { computeInheritedTree, @@ -183,7 +182,7 @@ const AmRoutes = () => { } const vanillaPrometheusAlertManager = isVanillaPrometheusAlertManagerDataSource(selectedAlertmanager); - const readOnlyPolicies = vanillaPrometheusAlertManager || isProvisioned; + const readOnlyPolicies = vanillaPrometheusAlertManager; const readOnlyMuteTimings = vanillaPrometheusAlertManager; const numberOfMuteTimings = result?.alertmanager_config.mute_time_intervals?.length ?? 0; @@ -227,7 +226,6 @@ const AmRoutes = () => { {policyTreeTabActive && ( <> - {isProvisioned && } {rootRoute && ( { alertGroups={alertGroups ?? []} contactPointsState={contactPointsState.receivers} readOnly={readOnlyPolicies} + provisioned={isProvisioned} alertManagerSourceName={selectedAlertmanager} onAddPolicy={openAddModal} onEditPolicy={openEditModal} diff --git a/public/app/features/alerting/unified/components/contact-points/ContactPoints.v2.tsx b/public/app/features/alerting/unified/components/contact-points/ContactPoints.v2.tsx index 2ea0c2deac2..77582420a80 100644 --- a/public/app/features/alerting/unified/components/contact-points/ContactPoints.v2.tsx +++ b/public/app/features/alerting/unified/components/contact-points/ContactPoints.v2.tsx @@ -3,13 +3,14 @@ import React from 'react'; import { GrafanaTheme2 } from '@grafana/data'; import { Stack } from '@grafana/experimental'; -import { Badge, Button, Dropdown, Icon, Menu, Tooltip, useStyles2 } from '@grafana/ui'; +import { Button, Dropdown, Icon, Menu, Tooltip, useStyles2 } from '@grafana/ui'; import { Span } from '@grafana/ui/src/unstable'; import ConditionalWrap from 'app/features/alerting/components/ConditionalWrap'; import { GrafanaNotifierType } from 'app/types/alerting'; import { INTEGRATION_ICONS } from '../../types/contact-points'; import { MetaText } from '../MetaText'; +import { ProvisioningBadge } from '../Provisioning'; import { Spacer } from '../Spacer'; import { Strong } from '../Strong'; @@ -113,7 +114,7 @@ const ContactPointHeader = (props: ContactPointHeaderProps) => { ) : ( is not used )} - {isProvisioned && } + {isProvisioned && } ; routesMatchingFilters?: RouteWithID[]; // routeAlertGroupsMap?: Map; @@ -50,6 +53,7 @@ const Policy: FC = ({ receivers = [], contactPointsState, readOnly = false, + provisioned = false, alertGroups = [], alertManagerSourceName, currentRoute, @@ -143,49 +147,57 @@ const Policy: FC = ({ {/* TODO maybe we should move errors to the gutter instead? */} {errors.length > 0 && } - {!readOnly && ( + {provisioned && } + {readOnly ? null : ( - - - onEditPolicy(currentRoute, isDefaultPolicy)} - /> - {isDeletable && ( - <> - - onDeletePolicy(currentRoute)} - /> - - )} - - } - > + + + + + + onEditPolicy(currentRoute, isDefaultPolicy)} + /> + {isDeletable && ( + <> + + onDeletePolicy(currentRoute)} + /> + + )} + + } + > +