diff --git a/public/app/features/alerting/unified/AmRoutes.tsx b/public/app/features/alerting/unified/AmRoutes.tsx index cc1effb81d1..bb237b25834 100644 --- a/public/app/features/alerting/unified/AmRoutes.tsx +++ b/public/app/features/alerting/unified/AmRoutes.tsx @@ -58,6 +58,10 @@ const AmRoutes: FC = () => { useCleanup((state) => state.unifiedAlerting.saveAMConfig); const handleSave = (data: Partial) => { + if (!result) { + return; + } + const newData = formAmRouteToAmRoute( alertManagerSourceName, { diff --git a/public/app/features/alerting/unified/components/admin/AlertmanagerConfig.tsx b/public/app/features/alerting/unified/components/admin/AlertmanagerConfig.tsx index ec78d1c79c1..662d97a1c5d 100644 --- a/public/app/features/alerting/unified/components/admin/AlertmanagerConfig.tsx +++ b/public/app/features/alerting/unified/components/admin/AlertmanagerConfig.tsx @@ -55,7 +55,7 @@ export default function AlertmanagerConfig(): JSX.Element { const loading = isDeleting || isLoadingConfig || isSaving; const onSubmit = (values: FormValues) => { - if (alertManagerSourceName) { + if (alertManagerSourceName && config) { dispatch( updateAlertManagerConfigAction({ newConfig: JSON.parse(values.configJSON), diff --git a/public/app/features/alerting/unified/utils/redux.ts b/public/app/features/alerting/unified/utils/redux.ts index 068c3c4f920..b2c50b2658e 100644 --- a/public/app/features/alerting/unified/utils/redux.ts +++ b/public/app/features/alerting/unified/utils/redux.ts @@ -13,8 +13,13 @@ export interface AsyncRequestState { requestId?: string; } -export const initialAsyncRequestState: AsyncRequestState = Object.freeze({ +export const initialAsyncRequestState: Pick< + AsyncRequestState, + 'loading' | 'dispatched' | 'result' | 'error' +> = Object.freeze({ loading: false, + result: undefined, + error: undefined, dispatched: false, });