diff --git a/public/app/features/alerting/unified/components/rule-editor/FolderAndGroup.tsx b/public/app/features/alerting/unified/components/rule-editor/FolderAndGroup.tsx index 44da084962e..a10eb9f7f19 100644 --- a/public/app/features/alerting/unified/components/rule-editor/FolderAndGroup.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/FolderAndGroup.tsx @@ -431,7 +431,10 @@ function EvaluationGroupCreationModal({ className={styles.formInput} id={evaluateEveryId} placeholder={DEFAULT_GROUP_EVALUATION_INTERVAL} - {...register('evaluateEvery', evaluateEveryValidationOptions(groupRules))} + {...register( + 'evaluateEvery', + evaluateEveryValidationOptions<{ group: string; evaluateEvery: string }>(groupRules) + )} /> diff --git a/public/app/features/alerting/unified/components/rule-editor/GrafanaEvaluationBehavior.tsx b/public/app/features/alerting/unified/components/rule-editor/GrafanaEvaluationBehavior.tsx index 5d091aa083d..4f703b9901e 100644 --- a/public/app/features/alerting/unified/components/rule-editor/GrafanaEvaluationBehavior.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/GrafanaEvaluationBehavior.tsx @@ -25,12 +25,12 @@ import { RuleEditorSection } from './RuleEditorSection'; export const MIN_TIME_RANGE_STEP_S = 10; // 10 seconds -const forValidationOptions = (evaluateEvery: string): RegisterOptions => ({ +const forValidationOptions = (evaluateEvery: string): RegisterOptions<{ evaluateFor: string }> => ({ required: { value: true, message: 'Required.', }, - validate: (value: string) => { + validate: (value) => { // parsePrometheusDuration does not allow 0 but does allow 0s if (value === '0') { return true; diff --git a/public/app/features/alerting/unified/components/rules/EditRuleGroupModal.tsx b/public/app/features/alerting/unified/components/rules/EditRuleGroupModal.tsx index 73015c380ce..e318499b3c8 100644 --- a/public/app/features/alerting/unified/components/rules/EditRuleGroupModal.tsx +++ b/public/app/features/alerting/unified/components/rules/EditRuleGroupModal.tsx @@ -1,7 +1,7 @@ import { css } from '@emotion/css'; import { compact } from 'lodash'; import { useMemo } from 'react'; -import { FormProvider, RegisterOptions, useForm, useFormContext } from 'react-hook-form'; +import { FieldValues, FormProvider, RegisterOptions, useForm, useFormContext } from 'react-hook-form'; import { GrafanaTheme2 } from '@grafana/data'; import { Alert, Badge, Button, Field, Input, Label, LinkButton, Modal, Stack, useStyles2 } from '@grafana/ui'; @@ -135,7 +135,7 @@ interface FormValues { groupInterval: string; } -export const evaluateEveryValidationOptions = (rules: RulerRuleDTO[]): RegisterOptions => ({ +export const evaluateEveryValidationOptions = (rules: RulerRuleDTO[]): RegisterOptions => ({ required: { value: true, message: 'Required.',