mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Fix bug for default value in silence matcher (#38735)
This commit is contained in:
parent
4f479de88e
commit
ad610a1916
@ -5,7 +5,7 @@ import { css, cx } from '@emotion/css';
|
|||||||
import { useFormContext, useFieldArray } from 'react-hook-form';
|
import { useFormContext, useFieldArray } from 'react-hook-form';
|
||||||
import { SilenceFormFields } from '../../types/silence-form';
|
import { SilenceFormFields } from '../../types/silence-form';
|
||||||
import { MatcherOperator } from 'app/plugins/datasource/alertmanager/types';
|
import { MatcherOperator } from 'app/plugins/datasource/alertmanager/types';
|
||||||
import { matcherToOperator, matcherFieldToMatcher, matcherFieldOptions } from '../../utils/alertmanager';
|
import { matcherFieldOptions } from '../../utils/alertmanager';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
className?: string;
|
className?: string;
|
||||||
@ -49,16 +49,12 @@ const MatchersField: FC<Props> = ({ className }) => {
|
|||||||
render={({ field: { onChange, ref, ...field } }) => (
|
render={({ field: { onChange, ref, ...field } }) => (
|
||||||
<Select
|
<Select
|
||||||
{...field}
|
{...field}
|
||||||
|
onChange={(value) => onChange(value.value)}
|
||||||
className={styles.matcherOptions}
|
className={styles.matcherOptions}
|
||||||
onChange={(value) => onChange(value?.value)}
|
|
||||||
options={matcherFieldOptions}
|
options={matcherFieldOptions}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
defaultValue={
|
defaultValue={matcher.operator || matcherFieldOptions[0].value}
|
||||||
matcherFieldOptions.find(
|
|
||||||
(field) => field.label === matcherToOperator(matcherFieldToMatcher(matcher))
|
|
||||||
) || matcherFieldOptions[0]
|
|
||||||
}
|
|
||||||
name={`matchers.${index}.operator` as const}
|
name={`matchers.${index}.operator` as const}
|
||||||
rules={{ required: { value: true, message: 'Required.' } }}
|
rules={{ required: { value: true, message: 'Required.' } }}
|
||||||
/>
|
/>
|
||||||
|
Loading…
Reference in New Issue
Block a user