This is an automated email from the ASF dual-hosted git repository.
bbovenzi pushed a commit to branch v3-1-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v3-1-test by this push:
new 66c39f7f5d4 [v3-1-test] Update pools slot input (#63900) (#64175)
66c39f7f5d4 is described below
commit 66c39f7f5d49d6d773ef4b09cf2cd69d993c6537
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Mar 24 14:03:31 2026 -0400
[v3-1-test] Update pools slot input (#63900) (#64175)
* Update pools slot input
* Simplify
* Add validation for <-1
(cherry picked from commit ee2e5d2c6ef0bef2ba2b50b3ea6bb683e783d51b)
Co-authored-by: Brent Bovenzi <[email protected]>
---
.../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 e55c81ee5b0..291ad573cac 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
@@ -311,6 +311,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 3f033eb4bad..fba746dceb4 100644
--- a/airflow-core/src/airflow/ui/src/pages/Pools/PoolForm.tsx
+++ b/airflow-core/src/airflow/ui/src/pages/Pools/PoolForm.tsx
@@ -40,6 +40,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 {
@@ -84,23 +86,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