mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Always invalidate the AM config after mutation (#73162)
This commit is contained in:
parent
ff1fdac675
commit
51a67b99f2
@ -156,7 +156,6 @@ const AmRoutes = () => {
|
|||||||
oldConfig: result,
|
oldConfig: result,
|
||||||
alertManagerSourceName: selectedAlertmanager!,
|
alertManagerSourceName: selectedAlertmanager!,
|
||||||
successMessage: 'Updated notification policies',
|
successMessage: 'Updated notification policies',
|
||||||
refetch: true,
|
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -68,7 +68,6 @@ export default function AlertmanagerConfig(): JSX.Element {
|
|||||||
oldConfig: config,
|
oldConfig: config,
|
||||||
alertManagerSourceName: selectedAlertmanager,
|
alertManagerSourceName: selectedAlertmanager,
|
||||||
successMessage: 'Alertmanager configuration updated.',
|
successMessage: 'Alertmanager configuration updated.',
|
||||||
refetch: true,
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -311,7 +311,7 @@ describe('Receivers', () => {
|
|||||||
// see that we're back to main page and proper api calls have been made
|
// see that we're back to main page and proper api calls have been made
|
||||||
await ui.receiversTable.find();
|
await ui.receiversTable.find();
|
||||||
expect(mocks.api.updateConfig).toHaveBeenCalledTimes(1);
|
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(locationService.getLocation().pathname).toEqual('/alerting/notifications');
|
||||||
expect(mocks.api.updateConfig).toHaveBeenLastCalledWith(GRAFANA_RULES_SOURCE_NAME, {
|
expect(mocks.api.updateConfig).toHaveBeenLastCalledWith(GRAFANA_RULES_SOURCE_NAME, {
|
||||||
...someGrafanaAlertManagerConfig,
|
...someGrafanaAlertManagerConfig,
|
||||||
@ -405,7 +405,7 @@ describe('Receivers', () => {
|
|||||||
// see that we're back to main page and proper api calls have been made
|
// see that we're back to main page and proper api calls have been made
|
||||||
await ui.receiversTable.find();
|
await ui.receiversTable.find();
|
||||||
expect(mocks.api.updateConfig).toHaveBeenCalledTimes(1);
|
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(locationService.getLocation().pathname).toEqual('/alerting/notifications');
|
||||||
expect(mocks.api.updateConfig).toHaveBeenLastCalledWith('CloudManager', {
|
expect(mocks.api.updateConfig).toHaveBeenLastCalledWith('CloudManager', {
|
||||||
|
@ -498,13 +498,12 @@ interface UpdateAlertManagerConfigActionOptions {
|
|||||||
successMessage?: string; // show toast on success
|
successMessage?: string; // show toast on success
|
||||||
redirectPath?: string; // where to redirect on success
|
redirectPath?: string; // where to redirect on success
|
||||||
redirectSearch?: string; // additional redirect query params
|
redirectSearch?: string; // additional redirect query params
|
||||||
refetch?: boolean; // refetch config on success
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const updateAlertManagerConfigAction = createAsyncThunk<void, UpdateAlertManagerConfigActionOptions, {}>(
|
export const updateAlertManagerConfigAction = createAsyncThunk<void, UpdateAlertManagerConfigActionOptions, {}>(
|
||||||
'unifiedalerting/updateAMConfig',
|
'unifiedalerting/updateAMConfig',
|
||||||
(
|
(
|
||||||
{ alertManagerSourceName, oldConfig, newConfig, successMessage, redirectPath, redirectSearch, refetch },
|
{ alertManagerSourceName, oldConfig, newConfig, successMessage, redirectPath, redirectSearch },
|
||||||
thunkAPI
|
thunkAPI
|
||||||
): Promise<void> =>
|
): Promise<void> =>
|
||||||
withAppEvents(
|
withAppEvents(
|
||||||
@ -523,9 +522,7 @@ export const updateAlertManagerConfigAction = createAsyncThunk<void, UpdateAlert
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
await updateAlertManagerConfig(alertManagerSourceName, addDefaultsToAlertmanagerConfig(newConfig));
|
await updateAlertManagerConfig(alertManagerSourceName, addDefaultsToAlertmanagerConfig(newConfig));
|
||||||
if (refetch) {
|
thunkAPI.dispatch(alertmanagerApi.util.invalidateTags(['AlertmanagerConfiguration']));
|
||||||
thunkAPI.dispatch(alertmanagerApi.util.invalidateTags(['AlertmanagerConfiguration']));
|
|
||||||
}
|
|
||||||
if (redirectPath) {
|
if (redirectPath) {
|
||||||
const options = new URLSearchParams(redirectSearch ?? '');
|
const options = new URLSearchParams(redirectSearch ?? '');
|
||||||
locationService.push(makeAMLink(redirectPath, alertManagerSourceName, options));
|
locationService.push(makeAMLink(redirectPath, alertManagerSourceName, options));
|
||||||
@ -604,7 +601,6 @@ export const deleteReceiverAction = (receiverName: string, alertManagerSourceNam
|
|||||||
oldConfig: config,
|
oldConfig: config,
|
||||||
alertManagerSourceName,
|
alertManagerSourceName,
|
||||||
successMessage: 'Contact point deleted.',
|
successMessage: 'Contact point deleted.',
|
||||||
refetch: true,
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@ -638,7 +634,6 @@ export const deleteTemplateAction = (templateName: string, alertManagerSourceNam
|
|||||||
oldConfig: config,
|
oldConfig: config,
|
||||||
alertManagerSourceName,
|
alertManagerSourceName,
|
||||||
successMessage: 'Template deleted.',
|
successMessage: 'Template deleted.',
|
||||||
refetch: true,
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@ -707,7 +702,6 @@ export const deleteMuteTimingAction = (alertManagerSourceName: string, muteTimin
|
|||||||
mute_time_intervals: muteIntervals,
|
mute_time_intervals: muteIntervals,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
refetch: true,
|
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user