This is an automated email from the ASF dual-hosted git repository.

rahulvats pushed a commit to branch py-client-sync
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 200b8f63ff42a7de07452de0ba829cac197b18b0
Author: Brent Bovenzi <[email protected]>
AuthorDate: Tue Mar 24 13:26:58 2026 -0400

    Update pools slot input (#63900)
    
    * Update pools slot input
    
    * Simplify
    
    * Add validation for <-1
---
 .../airflow/ui/public/i18n/locales/en/common.json  |  4 +++
 .../src/airflow/ui/src/pages/Pools/PoolForm.tsx    | 34 +++++++++++++++++-----
 2 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/airflow-core/src/airflow/ui/public/i18n/locales/en/common.json 
b/airflow-core/src/airflow/ui/public/i18n/locales/en/common.json
index 0bbea8fc42d..49037f58815 100644
--- a/airflow-core/src/airflow/ui/public/i18n/locales/en/common.json
+++ b/airflow-core/src/airflow/ui/public/i18n/locales/en/common.json
@@ -351,6 +351,10 @@
   "triggered": "Triggered",
   "tryNumber": "Try Number",
   "user": "User",
+  "validation": {
+    "mustBeAtLeast": "Must be at least {{min}}.",
+    "mustBeValidNumber": "Must be a valid number."
+  },
   "wrap": {
     "hotkey": "w",
     "tooltip": "Press {{hotkey}} to toggle wrap",
diff --git a/airflow-core/src/airflow/ui/src/pages/Pools/PoolForm.tsx 
b/airflow-core/src/airflow/ui/src/pages/Pools/PoolForm.tsx
index 6fe5784d995..bb88f8f91d9 100644
--- a/airflow-core/src/airflow/ui/src/pages/Pools/PoolForm.tsx
+++ b/airflow-core/src/airflow/ui/src/pages/Pools/PoolForm.tsx
@@ -42,6 +42,8 @@ type PoolFormProps = {
   readonly setError: (error: unknown) => void;
 };
 
+const POOL_SLOTS_MIN = -1;
+
 const PoolForm = ({ error, initialPool, isPending, manageMutate, setError }: 
PoolFormProps) => {
   const { t: translate } = useTranslation(["admin", "common"]);
   const {
@@ -87,23 +89,41 @@ const PoolForm = ({ error, initialPool, isPending, 
manageMutate, setError }: Poo
       <Controller
         control={control}
         name="slots"
-        render={({ field }) => (
-          <Field.Root mt={4}>
+        render={({ field, fieldState }) => (
+          <Field.Root invalid={Boolean(fieldState.error)} mt={4}>
             <Field.Label 
fontSize="md">{translate("pools.form.slots")}</Field.Label>
             <Input
-              min={-1}
+              min={POOL_SLOTS_MIN}
+              onBlur={field.onBlur}
               onChange={(event) => {
-                const value = event.target.valueAsNumber;
+                const { value: raw, valueAsNumber } = event.target;
 
-                field.onChange(isNaN(value) ? field.value : value);
+                field.onChange(raw === "" ? Number.NaN : valueAsNumber);
               }}
+              ref={field.ref}
               size="sm"
               type="number"
-              value={field.value}
+              value={Number.isFinite(field.value) ? field.value : ""}
             />
-            
<Field.HelperText>{translate("pools.form.slotsHelperText")}</Field.HelperText>
+            {fieldState.error ? (
+              <Field.ErrorText>{fieldState.error.message}</Field.ErrorText>
+            ) : (
+              
<Field.HelperText>{translate("pools.form.slotsHelperText")}</Field.HelperText>
+            )}
           </Field.Root>
         )}
+        rules={{
+          validate: (value: number) => {
+            if (!Number.isFinite(value)) {
+              return translate("common:validation.mustBeValidNumber");
+            }
+            if (value < POOL_SLOTS_MIN) {
+              return translate("common:validation.mustBeAtLeast", { min: 
POOL_SLOTS_MIN });
+            }
+
+            return true;
+          },
+        }}
       />
 
       <Controller

Reply via email to