mirror of
https://github.com/fosrl/pangolin.git
synced 2026-05-19 22:59:53 +00:00
fix cant save form
This commit is contained in:
@@ -1371,7 +1371,7 @@
|
|||||||
"alertingColumnTrigger": "Trigger",
|
"alertingColumnTrigger": "Trigger",
|
||||||
"alertingColumnActions": "Actions",
|
"alertingColumnActions": "Actions",
|
||||||
"alertingColumnEnabled": "Enabled",
|
"alertingColumnEnabled": "Enabled",
|
||||||
"alertingDeleteQuestion": "Delete this alert rule? This cannot be undone.",
|
"alertingDeleteQuestion": "Please confirm you want to delete this alert rule.",
|
||||||
"alertingDeleteRule": "Delete alert rule",
|
"alertingDeleteRule": "Delete alert rule",
|
||||||
"alertingRuleDeleted": "Alert rule deleted",
|
"alertingRuleDeleted": "Alert rule deleted",
|
||||||
"alertingRuleSaved": "Alert rule saved",
|
"alertingRuleSaved": "Alert rule saved",
|
||||||
@@ -1489,7 +1489,7 @@
|
|||||||
"standaloneHcNameLabel": "Name",
|
"standaloneHcNameLabel": "Name",
|
||||||
"standaloneHcNamePlaceholder": "My HTTP Monitor",
|
"standaloneHcNamePlaceholder": "My HTTP Monitor",
|
||||||
"standaloneHcDeleteTitle": "Delete health check",
|
"standaloneHcDeleteTitle": "Delete health check",
|
||||||
"standaloneHcDeleteQuestion": "Delete this health check? This cannot be undone.",
|
"standaloneHcDeleteQuestion": "Please confirm you want to delete this health check.",
|
||||||
"standaloneHcDeleted": "Health check deleted",
|
"standaloneHcDeleted": "Health check deleted",
|
||||||
"standaloneHcSaved": "Health check saved",
|
"standaloneHcSaved": "Health check saved",
|
||||||
"standaloneHcColumnHealth": "Health",
|
"standaloneHcColumnHealth": "Health",
|
||||||
|
|||||||
@@ -1156,6 +1156,7 @@ export function AlertRuleSourceFields({
|
|||||||
<FormField
|
<FormField
|
||||||
control={control}
|
control={control}
|
||||||
name="allSites"
|
name="allSites"
|
||||||
|
shouldUnregister={false}
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<StrategySelect
|
<StrategySelect
|
||||||
@@ -1198,6 +1199,7 @@ export function AlertRuleSourceFields({
|
|||||||
<FormField
|
<FormField
|
||||||
control={control}
|
control={control}
|
||||||
name="allResources"
|
name="allResources"
|
||||||
|
shouldUnregister={false}
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<StrategySelect
|
<StrategySelect
|
||||||
@@ -1240,6 +1242,7 @@ export function AlertRuleSourceFields({
|
|||||||
<FormField
|
<FormField
|
||||||
control={control}
|
control={control}
|
||||||
name="allHealthChecks"
|
name="allHealthChecks"
|
||||||
|
shouldUnregister={false}
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<StrategySelect
|
<StrategySelect
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import { ChevronLeft, Cog, Flag, Zap } from "lucide-react";
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useMemo, useState, type ReactNode } from "react";
|
import { useMemo, useState, type ReactNode } from "react";
|
||||||
import { useFieldArray, useForm } from "react-hook-form";
|
import { useFieldArray, useForm, type Resolver } from "react-hook-form";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { PaidFeaturesAlert } from "@app/components/PaidFeaturesAlert";
|
import { PaidFeaturesAlert } from "@app/components/PaidFeaturesAlert";
|
||||||
import { SwitchInput } from "@app/components/SwitchInput";
|
import { SwitchInput } from "@app/components/SwitchInput";
|
||||||
@@ -116,7 +116,7 @@ export default function AlertRuleGraphEditor({
|
|||||||
const [isSaving, setIsSaving] = useState(false);
|
const [isSaving, setIsSaving] = useState(false);
|
||||||
const schema = useMemo(() => buildFormSchema(t), [t]);
|
const schema = useMemo(() => buildFormSchema(t), [t]);
|
||||||
const form = useForm<AlertRuleFormValues>({
|
const form = useForm<AlertRuleFormValues>({
|
||||||
resolver: zodResolver(schema),
|
resolver: zodResolver(schema) as Resolver<AlertRuleFormValues>,
|
||||||
defaultValues: initialValues ?? defaultFormValues()
|
defaultValues: initialValues ?? defaultFormValues()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -142,12 +142,12 @@ export function buildFormSchema(t: (k: string) => string) {
|
|||||||
.min(1, { message: t("alertingErrorNameRequired") }),
|
.min(1, { message: t("alertingErrorNameRequired") }),
|
||||||
enabled: z.boolean(),
|
enabled: z.boolean(),
|
||||||
sourceType: z.enum(["site", "health_check", "resource"]),
|
sourceType: z.enum(["site", "health_check", "resource"]),
|
||||||
allSites: z.boolean(),
|
allSites: z.boolean().default(true),
|
||||||
siteIds: z.array(z.number()),
|
siteIds: z.array(z.number()).default([]),
|
||||||
allHealthChecks: z.boolean(),
|
allHealthChecks: z.boolean().default(true),
|
||||||
healthCheckIds: z.array(z.number()),
|
healthCheckIds: z.array(z.number()).default([]),
|
||||||
allResources: z.boolean(),
|
allResources: z.boolean().default(true),
|
||||||
resourceIds: z.array(z.number()),
|
resourceIds: z.array(z.number()).default([]),
|
||||||
trigger: z.enum([
|
trigger: z.enum([
|
||||||
"site_online",
|
"site_online",
|
||||||
"site_offline",
|
"site_offline",
|
||||||
@@ -332,8 +332,8 @@ export function apiResponseToFormValues(
|
|||||||
const sourceType = rule.eventType.startsWith("site_")
|
const sourceType = rule.eventType.startsWith("site_")
|
||||||
? "site"
|
? "site"
|
||||||
: rule.eventType.startsWith("resource_")
|
: rule.eventType.startsWith("resource_")
|
||||||
? "resource"
|
? "resource"
|
||||||
: "health_check";
|
: "health_check";
|
||||||
|
|
||||||
// Collect notify recipients into a single notify action (if any)
|
// Collect notify recipients into a single notify action (if any)
|
||||||
const userTags = rule.recipients
|
const userTags = rule.recipients
|
||||||
|
|||||||
Reference in New Issue
Block a user