Skip to content

Commit 3fc67d3

Browse files
devin-ai-integration[bot]desertaxle
authored andcommitted
feat(ui-v2): add WorkPoolEditForm component for editing work pools
- Create WorkPoolEditForm component with name, description, concurrency limit, and type fields - Name and type fields are disabled/read-only - Description and concurrency limit fields are editable - Add comprehensive test file with 16 test cases - Add Storybook stories with MSW handlers - Update index.ts exports to include new component and useUpdateWorkPool hook - Update route component to use new form Co-Authored-By: alex.s@prefect.io <ajstreed1@gmail.com>
1 parent c97b36d commit 3fc67d3

6 files changed

Lines changed: 644 additions & 1 deletion

File tree

ui-v2/src/api/work-pools/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ export {
88
useDeleteWorkPool,
99
usePauseWorkPool,
1010
useResumeWorkPool,
11+
useUpdateWorkPool,
1112
type WorkPool,
1213
type WorkPoolCreate,
1314
type WorkPoolStatus,
1415
type WorkPoolsCountFilter,
1516
type WorkPoolsFilter,
17+
type WorkPoolUpdate,
1618
type WorkPoolWorker,
1719
} from "./work-pools";
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
export { type WorkPoolEditFormValues, workPoolEditSchema } from "./schema";
2+
export { WorkPoolEditForm } from "./work-pool-edit-form";
13
export { WorkPoolEditPageHeader } from "./work-pool-edit-page-header";
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
import type { Meta, StoryObj } from "@storybook/react";
2+
import { HttpResponse, http } from "msw";
3+
import { createFakeWorkPool } from "@/mocks/create-fake-work-pool";
4+
import {
5+
reactQueryDecorator,
6+
routerDecorator,
7+
toastDecorator,
8+
} from "@/storybook/utils";
9+
import { WorkPoolEditForm } from "./work-pool-edit-form";
10+
11+
const meta: Meta<typeof WorkPoolEditForm> = {
12+
title: "Components/WorkPools/WorkPoolEditForm",
13+
component: WorkPoolEditForm,
14+
decorators: [reactQueryDecorator, routerDecorator, toastDecorator],
15+
parameters: {
16+
layout: "padded",
17+
},
18+
};
19+
20+
export default meta;
21+
type Story = StoryObj<typeof WorkPoolEditForm>;
22+
23+
export const Default: Story = {
24+
args: {
25+
workPool: createFakeWorkPool({
26+
name: "my-work-pool",
27+
description: "A work pool for running flow runs",
28+
concurrency_limit: 10,
29+
type: "process",
30+
}),
31+
},
32+
parameters: {
33+
msw: {
34+
handlers: [
35+
http.patch("http://localhost:4200/api/work_pools/:name", () => {
36+
return new HttpResponse(null, { status: 204 });
37+
}),
38+
],
39+
},
40+
},
41+
};
42+
43+
export const WithNullDescription: Story = {
44+
args: {
45+
workPool: createFakeWorkPool({
46+
name: "no-description-pool",
47+
description: null,
48+
concurrency_limit: 5,
49+
type: "docker",
50+
}),
51+
},
52+
parameters: {
53+
msw: {
54+
handlers: [
55+
http.patch("http://localhost:4200/api/work_pools/:name", () => {
56+
return new HttpResponse(null, { status: 204 });
57+
}),
58+
],
59+
},
60+
},
61+
};
62+
63+
export const WithNullConcurrencyLimit: Story = {
64+
args: {
65+
workPool: createFakeWorkPool({
66+
name: "unlimited-pool",
67+
description: "A pool with unlimited concurrency",
68+
concurrency_limit: null,
69+
type: "kubernetes",
70+
}),
71+
},
72+
parameters: {
73+
msw: {
74+
handlers: [
75+
http.patch("http://localhost:4200/api/work_pools/:name", () => {
76+
return new HttpResponse(null, { status: 204 });
77+
}),
78+
],
79+
},
80+
},
81+
};
82+
83+
export const WithLongDescription: Story = {
84+
args: {
85+
workPool: createFakeWorkPool({
86+
name: "detailed-pool",
87+
description:
88+
"This is a very detailed description of the work pool that explains its purpose, configuration, and usage guidelines. It spans multiple lines to demonstrate how the textarea handles longer content. The pool is configured for high-throughput batch processing workloads.",
89+
concurrency_limit: 100,
90+
type: "process",
91+
}),
92+
},
93+
parameters: {
94+
msw: {
95+
handlers: [
96+
http.patch("http://localhost:4200/api/work_pools/:name", () => {
97+
return new HttpResponse(null, { status: 204 });
98+
}),
99+
],
100+
},
101+
},
102+
};
103+
104+
export const SuccessResponse: Story = {
105+
args: {
106+
workPool: createFakeWorkPool({
107+
name: "success-pool",
108+
description: "Test successful update",
109+
concurrency_limit: 10,
110+
type: "process",
111+
}),
112+
},
113+
parameters: {
114+
msw: {
115+
handlers: [
116+
http.patch("http://localhost:4200/api/work_pools/:name", () => {
117+
return new HttpResponse(null, { status: 204 });
118+
}),
119+
],
120+
},
121+
},
122+
};
123+
124+
export const ErrorResponse: Story = {
125+
args: {
126+
workPool: createFakeWorkPool({
127+
name: "error-pool",
128+
description: "Test error handling",
129+
concurrency_limit: 10,
130+
type: "process",
131+
}),
132+
},
133+
parameters: {
134+
msw: {
135+
handlers: [
136+
http.patch("http://localhost:4200/api/work_pools/:name", () => {
137+
return HttpResponse.json(
138+
{ detail: "Work pool not found" },
139+
{ status: 404 },
140+
);
141+
}),
142+
],
143+
},
144+
},
145+
};
146+
147+
export const KubernetesWorkPool: Story = {
148+
args: {
149+
workPool: createFakeWorkPool({
150+
name: "production-k8s-pool",
151+
description: "Kubernetes work pool for production deployments",
152+
concurrency_limit: 50,
153+
type: "kubernetes",
154+
}),
155+
},
156+
parameters: {
157+
msw: {
158+
handlers: [
159+
http.patch("http://localhost:4200/api/work_pools/:name", () => {
160+
return new HttpResponse(null, { status: 204 });
161+
}),
162+
],
163+
},
164+
},
165+
};
166+
167+
export const DockerWorkPool: Story = {
168+
args: {
169+
workPool: createFakeWorkPool({
170+
name: "docker-dev-pool",
171+
description: "Docker work pool for development",
172+
concurrency_limit: 20,
173+
type: "docker",
174+
}),
175+
},
176+
parameters: {
177+
msw: {
178+
handlers: [
179+
http.patch("http://localhost:4200/api/work_pools/:name", () => {
180+
return new HttpResponse(null, { status: 204 });
181+
}),
182+
],
183+
},
184+
},
185+
};

0 commit comments

Comments
 (0)