Alerting: Set mimir implementation in jsonData by default when creating a new a… (#85513)

Set mimir implementation in jsonData by default when creating a new alert manager data source
This commit is contained in:
Sonia Aguilar 2024-04-03 12:31:49 +02:00 committed by GitHub
parent b4dc79401b
commit 034931f9e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,5 +1,5 @@
import { produce } from 'immer';
import React from 'react';
import React, { useEffect } from 'react';
import { Link } from 'react-router-dom';
import { SIGV4ConnectionConfig } from '@grafana/aws-sdk';
@ -33,6 +33,17 @@ const IMPL_OPTIONS: Array<SelectableValue<AlertManagerImplementation>> = [
export const ConfigEditor = (props: Props) => {
const { options, onOptionsChange } = props;
// As we default to Mimir, we need to make sure the implementation is set from the start
useEffect(() => {
if (!options.jsonData.implementation) {
onOptionsChange(
produce(options, (draft) => {
draft.jsonData.implementation = AlertManagerImplementation.mimir;
})
);
}
}, [options, onOptionsChange]);
return (
<>
<h3 className="page-heading">Alertmanager</h3>