From 04fd77c3a9a3a4d1cbbcac6a7ff93b1494db7e2d Mon Sep 17 00:00:00 2001 From: Ensar Kurt Date: Mon, 17 Mar 2025 23:42:09 +0300 Subject: [PATCH 1/4] replicas input cannot be zero and empty --- .../application/advanced/cluster/show-cluster-settings.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/dokploy/components/dashboard/application/advanced/cluster/show-cluster-settings.tsx b/apps/dokploy/components/dashboard/application/advanced/cluster/show-cluster-settings.tsx index 1eadf8bab..57f851c9e 100644 --- a/apps/dokploy/components/dashboard/application/advanced/cluster/show-cluster-settings.tsx +++ b/apps/dokploy/components/dashboard/application/advanced/cluster/show-cluster-settings.tsx @@ -40,7 +40,7 @@ interface Props { } const AddRedirectchema = z.object({ - replicas: z.number(), + replicas: z.number().min(1, "Replicas must be at least 1"), registryId: z.string(), }); @@ -130,9 +130,11 @@ export const ShowClusterSettings = ({ applicationId }: Props) => { placeholder="1" {...field} onChange={(e) => { - field.onChange(Number(e.target.value)); + const value = e.target.value; + field.onChange(value === "" ? 0 : Number(value)); }} type="number" + value={field.value || ""} /> From fe57333f846c488e48eb9477d35cbee4e00307aa Mon Sep 17 00:00:00 2001 From: Ensar Kurt Date: Mon, 17 Mar 2025 23:47:54 +0300 Subject: [PATCH 2/4] manage port inputs, default zero fix --- .../settings/web-server/manage-traefik-ports.tsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/dokploy/components/dashboard/settings/web-server/manage-traefik-ports.tsx b/apps/dokploy/components/dashboard/settings/web-server/manage-traefik-ports.tsx index 92ef9f128..d20b7c91a 100644 --- a/apps/dokploy/components/dashboard/settings/web-server/manage-traefik-ports.tsx +++ b/apps/dokploy/components/dashboard/settings/web-server/manage-traefik-ports.tsx @@ -159,9 +159,11 @@ export const ManageTraefikPorts = ({ children, serverId }: Props) => { - field.onChange(Number(e.target.value)) - } + onChange={(e) => { + const value = e.target.value; + field.onChange(value === "" ? undefined : Number(value)); + }} + value={field.value || ""} className="w-full dark:bg-black" placeholder="e.g. 8080" /> @@ -185,9 +187,11 @@ export const ManageTraefikPorts = ({ children, serverId }: Props) => { - field.onChange(Number(e.target.value)) - } + onChange={(e) => { + const value = e.target.value; + field.onChange(value === "" ? undefined : Number(value)); + }} + value={field.value || ""} className="w-full dark:bg-black" placeholder="e.g. 80" /> From 7cb184dc979c39272421040a6ac4298742b758be Mon Sep 17 00:00:00 2001 From: Ensar Kurt Date: Mon, 17 Mar 2025 23:48:17 +0300 Subject: [PATCH 3/4] email notification port, last digit staying error fix --- .../settings/notifications/handle-notifications.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/dokploy/components/dashboard/settings/notifications/handle-notifications.tsx b/apps/dokploy/components/dashboard/settings/notifications/handle-notifications.tsx index 7a3e286e3..e04765298 100644 --- a/apps/dokploy/components/dashboard/settings/notifications/handle-notifications.tsx +++ b/apps/dokploy/components/dashboard/settings/notifications/handle-notifications.tsx @@ -663,13 +663,16 @@ export const HandleNotifications = ({ notificationId }: Props) => { {...field} onChange={(e) => { const value = e.target.value; - if (value) { + if (value === "") { + field.onChange(undefined); + } else { const port = Number.parseInt(value); if (port > 0 && port < 65536) { field.onChange(port); } } }} + value={field.value || ""} type="number" /> From 3cdf4c426c01842a9f034b17518ec55a6de61fe9 Mon Sep 17 00:00:00 2001 From: Ensar Kurt Date: Tue, 18 Mar 2025 00:05:59 +0300 Subject: [PATCH 4/4] revert commit from #1513 --- apps/dokploy/components/ui/input.tsx | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/apps/dokploy/components/ui/input.tsx b/apps/dokploy/components/ui/input.tsx index 7339d21a2..18b713af5 100644 --- a/apps/dokploy/components/ui/input.tsx +++ b/apps/dokploy/components/ui/input.tsx @@ -39,7 +39,7 @@ const NumberInput = React.forwardRef( className={cn("text-left", className)} ref={ref} {...props} - value={props.value === undefined || props.value === "" ? "" : String(props.value)} + value={props.value === undefined ? undefined : String(props.value)} onChange={(e) => { const value = e.target.value; if (value === "") { @@ -60,21 +60,6 @@ const NumberInput = React.forwardRef( } } }} - onBlur={(e) => { - // If input is empty, make 0 when focus is lost - if (e.target.value === "") { - const syntheticEvent = { - ...e, - target: { - ...e.target, - value: "0", - }, - }; - props.onChange?.( - syntheticEvent as unknown as React.ChangeEvent, - ); - } - }} /> ); },