mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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 <bot@renovateapp.com> Co-authored-by: Nathan Rodman <nathanrodman@gmail.com>
This commit is contained in:
@@ -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<R extends ChannelValues>({
|
||||
Because there is no default policy configured yet, this contact point will automatically be set as default.
|
||||
</Alert>
|
||||
)}
|
||||
<form onSubmit={handleSubmit(submitCallback, onInvalid)}>
|
||||
<form onSubmit={handleSubmit(submitCallback as SubmitHandler<ReceiverFormValues<R>>, onInvalid)}>
|
||||
<h4 className={styles.heading}>
|
||||
{readOnly ? 'Contact point' : initialValues ? 'Update contact point' : 'Create contact point'}
|
||||
</h4>
|
||||
@@ -121,13 +121,13 @@ export function ReceiverForm<R extends ChannelValues>({
|
||||
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
|
||||
|
||||
@@ -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<Props> = ({ editingExistingRule }) => {
|
||||
<Field
|
||||
label="Folder"
|
||||
className={styles.formInput}
|
||||
error={errors.folder?.message}
|
||||
invalid={!!errors.folder?.message}
|
||||
// Use get to make react-hook-form + TS happy for object fields
|
||||
error={get(errors, 'folder.message')}
|
||||
invalid={!!get(errors, 'folder.message')}
|
||||
data-testid="folder-picker"
|
||||
>
|
||||
<InputControl
|
||||
|
||||
Reference in New Issue
Block a user