From 175891a5e39be5e21480296a869c7c4f6e3645ff Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 18 Feb 2022 17:13:31 +0100 Subject: [PATCH] Update dependency react-hook-form to v7.26.1 (#43670) * Update dependency react-hook-form to v7.27.0 * fix type errors for alerting components with new react-hook-form version (#45341) Co-authored-by: Renovate Bot Co-authored-by: Nathan Rodman --- package.json | 2 +- packages/grafana-ui/package.json | 2 +- .../components/receivers/form/ReceiverForm.tsx | 8 ++++---- .../components/rule-editor/AlertTypeStep.tsx | 6 ++++-- yarn.lock | 13 +++++++++++-- 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index e3620684890..e9de55d74b1 100644 --- a/package.json +++ b/package.json @@ -334,7 +334,7 @@ "react-draggable": "4.4.4", "react-grid-layout": "1.3.3", "react-highlight-words": "0.17.0", - "react-hook-form": "7.5.3", + "react-hook-form": "7.27.0", "react-inlinesvg": "2.3.0", "react-loadable": "5.5.0", "react-moveable": "0.30.3", diff --git a/packages/grafana-ui/package.json b/packages/grafana-ui/package.json index 149fac977ac..768b671ed45 100644 --- a/packages/grafana-ui/package.json +++ b/packages/grafana-ui/package.json @@ -74,7 +74,7 @@ "react-dom": "17.0.2", "react-dropzone": "11.5.1", "react-highlight-words": "0.17.0", - "react-hook-form": "7.5.3", + "react-hook-form": "7.27.0", "react-inlinesvg": "2.3.0", "react-popper": "2.2.5", "react-popper-tooltip": "^4.3.1", diff --git a/public/app/features/alerting/unified/components/receivers/form/ReceiverForm.tsx b/public/app/features/alerting/unified/components/receivers/form/ReceiverForm.tsx index 516986bb8ee..ccc021b313b 100644 --- a/public/app/features/alerting/unified/components/receivers/form/ReceiverForm.tsx +++ b/public/app/features/alerting/unified/components/receivers/form/ReceiverForm.tsx @@ -5,7 +5,7 @@ import { useCleanup } from 'app/core/hooks/useCleanup'; import { AlertManagerCortexConfig } from 'app/plugins/datasource/alertmanager/types'; import { NotifierDTO } from 'app/types'; import React, { useCallback } from 'react'; -import { useForm, FormProvider, FieldErrors, Validate } from 'react-hook-form'; +import { useForm, FormProvider, FieldErrors, Validate, SubmitHandler } from 'react-hook-form'; import { useControlledFieldArray } from '../../../hooks/useControlledFieldArray'; import { useUnifiedAlertingSelector } from '../../../hooks/useUnifiedAlertingSelector'; import { ChannelValues, CommonSettingsComponentType, ReceiverFormValues } from '../../../types/receiver-form'; @@ -94,7 +94,7 @@ export function ReceiverForm({ Because there is no default policy configured yet, this contact point will automatically be set as default. )} -
+ >, onInvalid)}>

{readOnly ? 'Contact point' : initialValues ? 'Update contact point' : 'Create contact point'}

@@ -121,13 +121,13 @@ export function ReceiverForm({ defaultValues={field} key={field.__id} onDuplicate={() => { - const currentValues: R = getValues().items[index]; + const currentValues = getValues().items[index] as R; append({ ...currentValues, __id: String(Math.random()) }); }} onTest={ onTestChannel ? () => { - const currentValues: R = getValues().items[index]; + const currentValues = getValues().items[index] as R; onTestChannel(currentValues); } : undefined diff --git a/public/app/features/alerting/unified/components/rule-editor/AlertTypeStep.tsx b/public/app/features/alerting/unified/components/rule-editor/AlertTypeStep.tsx index 4a96553d037..54daf57fa7c 100644 --- a/public/app/features/alerting/unified/components/rule-editor/AlertTypeStep.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/AlertTypeStep.tsx @@ -10,6 +10,7 @@ import { GroupAndNamespaceFields } from './GroupAndNamespaceFields'; import { contextSrv } from 'app/core/services/context_srv'; import { CloudRulesSourcePicker } from './CloudRulesSourcePicker'; import { checkForPathSeparator } from './util'; +import { get } from 'lodash'; interface Props { editingExistingRule: boolean; @@ -148,8 +149,9 @@ export const AlertTypeStep: FC = ({ editingExistingRule }) => {