From b41ad688f27048f1aef255269ce5a85f0421446b Mon Sep 17 00:00:00 2001 From: Alex Khomenko Date: Thu, 21 Mar 2024 11:59:41 +0100 Subject: [PATCH] Alerting: Remove deprecated InputControl (#84793) --- .../receivers/form/ChannelSubForm.tsx | 6 ++--- .../receivers/form/fields/OptionField.tsx | 12 +++++----- .../rule-editor/AnnotationHeaderField.tsx | 6 ++--- .../rule-editor/CloudEvaluationBehavior.tsx | 6 ++--- .../components/rule-editor/FolderAndGroup.tsx | 20 ++++------------- .../rule-editor/GrafanaEvaluationBehavior.tsx | 22 +++++-------------- .../rule-editor/GroupAndNamespaceFields.tsx | 8 +++---- .../components/rule-editor/LabelsField.tsx | 18 ++++----------- .../contactPoint/ContactPointSelector.tsx | 5 ++--- .../route-settings/MuteTimingFields.tsx | 6 ++--- .../route-settings/RouteSettings.tsx | 16 +++----------- .../CloudDataSourceSelector.tsx | 6 ++--- .../QueryAndExpressionsStep.tsx | 18 +++------------ .../components/silences/MatchersField.tsx | 6 ++--- 14 files changed, 49 insertions(+), 106 deletions(-) diff --git a/public/app/features/alerting/unified/components/receivers/form/ChannelSubForm.tsx b/public/app/features/alerting/unified/components/receivers/form/ChannelSubForm.tsx index 995b81b3c25..9ea1c7a05de 100644 --- a/public/app/features/alerting/unified/components/receivers/form/ChannelSubForm.tsx +++ b/public/app/features/alerting/unified/components/receivers/form/ChannelSubForm.tsx @@ -1,10 +1,10 @@ import { css } from '@emotion/css'; import { sortBy } from 'lodash'; import React, { useCallback, useEffect, useMemo, useState } from 'react'; -import { useFormContext, FieldErrors, FieldValues } from 'react-hook-form'; +import { useFormContext, FieldErrors, FieldValues, Controller } from 'react-hook-form'; import { GrafanaTheme2, SelectableValue } from '@grafana/data'; -import { Alert, Button, Field, InputControl, Select, useStyles2 } from '@grafana/ui'; +import { Alert, Button, Field, Select, useStyles2 } from '@grafana/ui'; import { useUnifiedAlertingSelector } from '../../../hooks/useUnifiedAlertingSelector'; import { ChannelValues, CommonSettingsComponentType } from '../../../types/receiver-form'; @@ -134,7 +134,7 @@ export function ChannelSubForm({
- ( diff --git a/public/app/features/alerting/unified/components/receivers/form/fields/OptionField.tsx b/public/app/features/alerting/unified/components/receivers/form/fields/OptionField.tsx index e5058dca9b9..fe7c202cea7 100644 --- a/public/app/features/alerting/unified/components/receivers/form/fields/OptionField.tsx +++ b/public/app/features/alerting/unified/components/receivers/form/fields/OptionField.tsx @@ -1,10 +1,10 @@ import { css } from '@emotion/css'; import { isEmpty } from 'lodash'; import React, { FC, useEffect } from 'react'; -import { useFormContext, FieldError, DeepMap } from 'react-hook-form'; +import { useFormContext, FieldError, DeepMap, Controller } from 'react-hook-form'; import { GrafanaTheme2 } from '@grafana/data'; -import { Checkbox, Field, Input, InputControl, RadioButtonList, Select, TextArea, useStyles2 } from '@grafana/ui'; +import { Checkbox, Field, Input, RadioButtonList, Select, TextArea, useStyles2 } from '@grafana/ui'; import { NotificationChannelOption } from 'app/types'; import { KeyValueMapInput } from './KeyValueMapInput'; @@ -134,7 +134,7 @@ const OptionInput: FC = ({ case 'select': return ( - ( {(!isCreatingFolder && ( <> - (
- ( - ( - ( - ( { error={errors.namespace?.message} invalid={!!errors.namespace?.message} > - ( { /> - ( = ({ dataSourceName error={errors.labels?.[index]?.key?.message} data-testid={`label-key-${index}`} > - = ({ dataSourceName error={errors.labels?.[index]?.value?.message} data-testid={`label-value-${index}`} > - - ( <>
diff --git a/public/app/features/alerting/unified/components/rule-editor/alert-rule-form/simplifiedRouting/route-settings/MuteTimingFields.tsx b/public/app/features/alerting/unified/components/rule-editor/alert-rule-form/simplifiedRouting/route-settings/MuteTimingFields.tsx index ddb93051902..d52230f4e94 100644 --- a/public/app/features/alerting/unified/components/rule-editor/alert-rule-form/simplifiedRouting/route-settings/MuteTimingFields.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/alert-rule-form/simplifiedRouting/route-settings/MuteTimingFields.tsx @@ -1,8 +1,8 @@ import React from 'react'; -import { useFormContext } from 'react-hook-form'; +import { useFormContext, Controller } from 'react-hook-form'; import { SelectableValue } from '@grafana/data'; -import { Field, InputControl, MultiSelect, useStyles2 } from '@grafana/ui'; +import { Field, MultiSelect, useStyles2 } from '@grafana/ui'; import { alertmanagerApi } from 'app/features/alerting/unified/api/alertmanagerApi'; import { RuleFormValues } from 'app/features/alerting/unified/types/rule-form'; import { timeIntervalToString } from 'app/features/alerting/unified/utils/alertmanager'; @@ -29,7 +29,7 @@ export function MuteTimingFields({ alertManager }: MuteTimingFieldsProps) { description="Select a mute timing to define when not to send notifications for this alert rule" invalid={!!errors.contactPoints?.[alertManager]?.muteTimeIntervals} > - ( { invalid={!!errors.contactPoints?.[alertManager]?.groupBy} className={styles.optionalContent} > - { if (!value || value.length === 0) { diff --git a/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/CloudDataSourceSelector.tsx b/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/CloudDataSourceSelector.tsx index 88e4ee494ce..447be8edd9d 100644 --- a/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/CloudDataSourceSelector.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/CloudDataSourceSelector.tsx @@ -1,9 +1,9 @@ import { css } from '@emotion/css'; import React from 'react'; -import { useFormContext } from 'react-hook-form'; +import { useFormContext, Controller } from 'react-hook-form'; import { DataSourceInstanceSettings, GrafanaTheme2 } from '@grafana/data'; -import { Field, InputControl, useStyles2 } from '@grafana/ui'; +import { Field, useStyles2 } from '@grafana/ui'; import { RuleFormType, RuleFormValues } from '../../../types/rule-form'; import { CloudRulesSourcePicker } from '../CloudRulesSourcePicker'; @@ -33,7 +33,7 @@ export const CloudDataSourceSelector = ({ disabled, onChangeCloudDatasource }: C error={errors.dataSourceName?.message} invalid={!!errors.dataSourceName?.message} > - ( - { return ( diff --git a/public/app/features/alerting/unified/components/silences/MatchersField.tsx b/public/app/features/alerting/unified/components/silences/MatchersField.tsx index 2400274d5c8..fa2b82a5b94 100644 --- a/public/app/features/alerting/unified/components/silences/MatchersField.tsx +++ b/public/app/features/alerting/unified/components/silences/MatchersField.tsx @@ -1,9 +1,9 @@ import { css, cx } from '@emotion/css'; import React from 'react'; -import { useFormContext, useFieldArray } from 'react-hook-form'; +import { useFormContext, useFieldArray, Controller } from 'react-hook-form'; import { GrafanaTheme2 } from '@grafana/data'; -import { Button, Field, Input, IconButton, InputControl, useStyles2, Select } from '@grafana/ui'; +import { Button, Field, Input, IconButton, useStyles2, Select } from '@grafana/ui'; import { MatcherOperator } from 'app/plugins/datasource/alertmanager/types'; import { SilenceFormFields } from '../../types/silence-form'; @@ -46,7 +46,7 @@ const MatchersField = ({ className }: Props) => { /> - (