mirror of
https://github.com/andwati/dokploy.git
synced 2026-12-05 09:08:47 +00:00
fix: swarm health check fields not resetting to default values (#4558)
Fixes #4553 - Replace z.coerce.number() with a custom transform that converts empty strings to undefined instead of 0 - Add value={field.value ?? ""} to numeric inputs so they visually clear when reset to undefined
This commit is contained in:
+13
-8
@@ -16,12 +16,17 @@ import {
|
|||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { api } from "@/utils/api";
|
import { api } from "@/utils/api";
|
||||||
|
|
||||||
|
const optionalNumber = z
|
||||||
|
.union([z.string(), z.number()])
|
||||||
|
.transform((val) => (val === "" ? undefined : Number(val)))
|
||||||
|
.optional();
|
||||||
|
|
||||||
export const healthCheckFormSchema = z.object({
|
export const healthCheckFormSchema = z.object({
|
||||||
Test: z.array(z.string()).optional(),
|
Test: z.array(z.string()).optional(),
|
||||||
Interval: z.coerce.number().optional(),
|
Interval: optionalNumber,
|
||||||
Timeout: z.coerce.number().optional(),
|
Timeout: optionalNumber,
|
||||||
StartPeriod: z.coerce.number().optional(),
|
StartPeriod: optionalNumber,
|
||||||
Retries: z.coerce.number().optional(),
|
Retries: optionalNumber,
|
||||||
});
|
});
|
||||||
|
|
||||||
interface HealthCheckFormProps {
|
interface HealthCheckFormProps {
|
||||||
@@ -195,7 +200,7 @@ export const HealthCheckForm = ({ id, type }: HealthCheckFormProps) => {
|
|||||||
Time between health checks (e.g., 10000000000 for 10 seconds)
|
Time between health checks (e.g., 10000000000 for 10 seconds)
|
||||||
</FormDescription>
|
</FormDescription>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input type="number" placeholder="10000000000" {...field} />
|
<Input type="number" placeholder="10000000000" {...field} value={field.value ?? ""} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
@@ -212,7 +217,7 @@ export const HealthCheckForm = ({ id, type }: HealthCheckFormProps) => {
|
|||||||
Maximum time to wait for health check response
|
Maximum time to wait for health check response
|
||||||
</FormDescription>
|
</FormDescription>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input type="number" placeholder="10000000000" {...field} />
|
<Input type="number" placeholder="10000000000" {...field} value={field.value ?? ""} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
@@ -229,7 +234,7 @@ export const HealthCheckForm = ({ id, type }: HealthCheckFormProps) => {
|
|||||||
Initial grace period before health checks begin
|
Initial grace period before health checks begin
|
||||||
</FormDescription>
|
</FormDescription>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input type="number" placeholder="10000000000" {...field} />
|
<Input type="number" placeholder="10000000000" {...field} value={field.value ?? ""} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
@@ -247,7 +252,7 @@ export const HealthCheckForm = ({ id, type }: HealthCheckFormProps) => {
|
|||||||
unhealthy
|
unhealthy
|
||||||
</FormDescription>
|
</FormDescription>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input type="number" placeholder="3" {...field} />
|
<Input type="number" placeholder="3" {...field} value={field.value ?? ""} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|||||||
Reference in New Issue
Block a user