From 51a67b99f2adb5b040092b2faa2b71dde51a9f55 Mon Sep 17 00:00:00 2001 From: Gilles De Mey Date: Fri, 11 Aug 2023 08:36:49 +0200 Subject: [PATCH] Alerting: Always invalidate the AM config after mutation (#73162) --- .../features/alerting/unified/NotificationPolicies.tsx | 1 - .../unified/components/admin/AlertmanagerConfig.tsx | 1 - .../contact-points/ContactPoints.v1.test.tsx | 4 ++-- public/app/features/alerting/unified/state/actions.ts | 10 ++-------- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/public/app/features/alerting/unified/NotificationPolicies.tsx b/public/app/features/alerting/unified/NotificationPolicies.tsx index ad9ffa9f457..822463db4e3 100644 --- a/public/app/features/alerting/unified/NotificationPolicies.tsx +++ b/public/app/features/alerting/unified/NotificationPolicies.tsx @@ -156,7 +156,6 @@ const AmRoutes = () => { oldConfig: result, alertManagerSourceName: selectedAlertmanager!, successMessage: 'Updated notification policies', - refetch: true, }) ) .unwrap() diff --git a/public/app/features/alerting/unified/components/admin/AlertmanagerConfig.tsx b/public/app/features/alerting/unified/components/admin/AlertmanagerConfig.tsx index 914949b39c2..d4c4054fe97 100644 --- a/public/app/features/alerting/unified/components/admin/AlertmanagerConfig.tsx +++ b/public/app/features/alerting/unified/components/admin/AlertmanagerConfig.tsx @@ -68,7 +68,6 @@ export default function AlertmanagerConfig(): JSX.Element { oldConfig: config, alertManagerSourceName: selectedAlertmanager, successMessage: 'Alertmanager configuration updated.', - refetch: true, }) ); } diff --git a/public/app/features/alerting/unified/components/contact-points/ContactPoints.v1.test.tsx b/public/app/features/alerting/unified/components/contact-points/ContactPoints.v1.test.tsx index c0ee2251e07..5fc33aaaa3a 100644 --- a/public/app/features/alerting/unified/components/contact-points/ContactPoints.v1.test.tsx +++ b/public/app/features/alerting/unified/components/contact-points/ContactPoints.v1.test.tsx @@ -311,7 +311,7 @@ describe('Receivers', () => { // see that we're back to main page and proper api calls have been made await ui.receiversTable.find(); expect(mocks.api.updateConfig).toHaveBeenCalledTimes(1); - expect(mocks.api.fetchConfig).toHaveBeenCalledTimes(1); + expect(mocks.api.fetchConfig).toHaveBeenCalledTimes(2); expect(locationService.getLocation().pathname).toEqual('/alerting/notifications'); expect(mocks.api.updateConfig).toHaveBeenLastCalledWith(GRAFANA_RULES_SOURCE_NAME, { ...someGrafanaAlertManagerConfig, @@ -405,7 +405,7 @@ describe('Receivers', () => { // see that we're back to main page and proper api calls have been made await ui.receiversTable.find(); expect(mocks.api.updateConfig).toHaveBeenCalledTimes(1); - expect(mocks.api.fetchConfig).toHaveBeenCalledTimes(1); + expect(mocks.api.fetchConfig).toHaveBeenCalledTimes(2); expect(locationService.getLocation().pathname).toEqual('/alerting/notifications'); expect(mocks.api.updateConfig).toHaveBeenLastCalledWith('CloudManager', { diff --git a/public/app/features/alerting/unified/state/actions.ts b/public/app/features/alerting/unified/state/actions.ts index f300639c451..79b0aa71e78 100644 --- a/public/app/features/alerting/unified/state/actions.ts +++ b/public/app/features/alerting/unified/state/actions.ts @@ -498,13 +498,12 @@ interface UpdateAlertManagerConfigActionOptions { successMessage?: string; // show toast on success redirectPath?: string; // where to redirect on success redirectSearch?: string; // additional redirect query params - refetch?: boolean; // refetch config on success } export const updateAlertManagerConfigAction = createAsyncThunk( 'unifiedalerting/updateAMConfig', ( - { alertManagerSourceName, oldConfig, newConfig, successMessage, redirectPath, redirectSearch, refetch }, + { alertManagerSourceName, oldConfig, newConfig, successMessage, redirectPath, redirectSearch }, thunkAPI ): Promise => withAppEvents( @@ -523,9 +522,7 @@ export const updateAlertManagerConfigAction = createAsyncThunk