Skip to content

Commit d164e8b

Browse files
shubhamraj-gitYour friendly bot
authored andcommitted
[v3-1-test] Patch pools should have an optional description (apache#58066)
(cherry picked from commit 3afad4d) Co-authored-by: Shubham Raj <[email protected]>
1 parent 154d48c commit d164e8b

File tree

7 files changed

+17
-15
lines changed

7 files changed

+17
-15
lines changed

airflow-core/src/airflow/api_fastapi/core_api/datamodels/pools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class BasePool(BaseModel):
3939

4040
pool: str = Field(serialization_alias="name")
4141
slots: int
42-
description: str | None
42+
description: str | None = Field(default=None)
4343
include_deferred: bool
4444

4545

airflow-core/src/airflow/api_fastapi/core_api/openapi/v2-rest-api-generated.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11548,7 +11548,6 @@ components:
1154811548
required:
1154911549
- name
1155011550
- slots
11551-
- description
1155211551
- include_deferred
1155311552
- occupied_slots
1155411553
- running_slots

airflow-core/src/airflow/ui/openapi-gen/requests/schemas.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4393,7 +4393,7 @@ export const $PoolResponse = {
43934393
}
43944394
},
43954395
type: 'object',
4396-
required: ['name', 'slots', 'description', 'include_deferred', 'occupied_slots', 'running_slots', 'queued_slots', 'scheduled_slots', 'open_slots', 'deferred_slots'],
4396+
required: ['name', 'slots', 'include_deferred', 'occupied_slots', 'running_slots', 'queued_slots', 'scheduled_slots', 'open_slots', 'deferred_slots'],
43974397
title: 'PoolResponse',
43984398
description: 'Pool serializer for responses.'
43994399
} as const;

airflow-core/src/airflow/ui/openapi-gen/requests/types.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ export type PoolPatchBody = {
11571157
export type PoolResponse = {
11581158
name: string;
11591159
slots: number;
1160-
description: string | null;
1160+
description?: string | null;
11611161
include_deferred: boolean;
11621162
occupied_slots: number;
11631163
running_slots: number;

airflow-core/src/airflow/ui/src/pages/Pools/PoolForm.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,17 @@ const PoolForm = ({ error, initialPool, isPending, manageMutate, setError }: Poo
8787
render={({ field }) => (
8888
<Field.Root mt={4}>
8989
<Field.Label fontSize="md">{translate("pools.form.slots")}</Field.Label>
90-
<Input {...field} min={initialPool.slots} size="sm" type="number" />
90+
<Input
91+
min={initialPool.slots}
92+
onChange={(event) => {
93+
const value = event.target.valueAsNumber;
94+
95+
field.onChange(isNaN(value) ? field.value : value);
96+
}}
97+
size="sm"
98+
type="number"
99+
value={field.value}
100+
/>
91101
</Field.Root>
92102
)}
93103
/>
@@ -128,7 +138,7 @@ const PoolForm = ({ error, initialPool, isPending, manageMutate, setError }: Poo
128138
<Spacer />
129139
<Button
130140
colorPalette="brand"
131-
disabled={!isValid || isPending}
141+
disabled={!isValid || isPending || !isDirty}
132142
onClick={() => void handleSubmit(onSubmit)()}
133143
>
134144
<FiSave /> {translate("formActions.save")}

airflow-core/src/airflow/ui/src/queries/useEditPool.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,19 @@ export const useEditPool = (
6565

6666
const editPool = (editPoolRequestBody: PoolBody) => {
6767
const updateMask: Array<string> = [];
68+
let parsedDescription = undefined;
6869

6970
if (editPoolRequestBody.slots !== initialPool.slots) {
7071
updateMask.push("slots");
7172
}
7273
if (editPoolRequestBody.description !== initialPool.description) {
74+
parsedDescription = editPoolRequestBody.description;
7375
updateMask.push("description");
7476
}
7577
if (editPoolRequestBody.include_deferred !== initialPool.include_deferred) {
7678
updateMask.push("include_deferred");
7779
}
7880

79-
const parsedDescription =
80-
editPoolRequestBody.description === "" ? undefined : editPoolRequestBody.description;
81-
8281
mutate({
8382
poolName: initialPool.name,
8483
requestBody: {

airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_pools.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,6 @@ class TestPatchPool(TestPoolsEndpoint):
250250
"msg": "Field required",
251251
"type": "missing",
252252
},
253-
{
254-
"input": {"pool": POOL1_NAME},
255-
"loc": ["description"],
256-
"msg": "Field required",
257-
"type": "missing",
258-
},
259253
{
260254
"input": {"pool": POOL1_NAME},
261255
"loc": ["include_deferred"],

0 commit comments

Comments
 (0)