Skip to content

Commit bc97b4a

Browse files
committed
fix(hub): refactor validation for functions (#2647)
## Changes 1. Modified the path validation regex in `route-edit-form.tsx` to allow empty paths by: - Removing the `.min(1)` validation - Changing the regex from `/^(\/[a-zA-Z0-9-_]+)+$/` to `/^(\/[a-zA-Z0-9-_]+)*$/` 2. Added form error handling for tags in the route edit form by including a `FormMessage` component when no selectors are added 3. Improved UI layout consistency across multiple pages by adding padding: - Added `p-4` to header sections in builds, functions, and settings pages - Added `p-2` to content containers in the same pages
1 parent 520b83c commit bc97b4a

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

frontend/apps/hub/src/domains/project/forms/route-edit-form.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,8 @@ export const formSchema = z.object({
5757
),
5858
path: z
5959
.string()
60-
.min(1)
6160
.refine((value) => {
62-
const regex = /^(\/[a-zA-Z0-9-_]+)+$/;
61+
const regex = /^(\/[a-zA-Z0-9-_]+)*$/;
6362
return regex.test(value);
6463
}, "Path must start with a / and contain only alphanumeric characters, dashes, and underscores")
6564
.refine((value) => {
@@ -180,7 +179,18 @@ export const Tags = ({
180179
return (
181180
<>
182181
{fields.length === 0 ? (
183-
<p className="text-xs mb-2">There's no selectors added.</p>
182+
<div>
183+
<p className="text-xs mb-2">There's no selectors added.</p>
184+
<FormField
185+
control={control}
186+
name="tags"
187+
render={({ field }) => (
188+
<FormItem>
189+
<FormMessage />
190+
</FormItem>
191+
)}
192+
/>
193+
</div>
184194
) : null}
185195
{fields.map((field, index) => (
186196
<div

frontend/apps/hub/src/routes/_authenticated/_layout/projects/$projectNameId/environments/$environmentNameId._v2/actor-versions.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function ProjectBuildsRoute() {
5353

5454
return (
5555
<>
56-
<div className="max-w-5xl mx-auto my-8 flex justify-between items-center">
56+
<div className="max-w-5xl mx-auto my-8 flex justify-between items-center p-4">
5757
<H1>Builds</H1>
5858
<div className="flex items-center gap-2">
5959
<TagsSelect
@@ -85,7 +85,7 @@ function ProjectBuildsRoute() {
8585
<hr className="mb-4" />
8686

8787
<div className="p-4">
88-
<div className="max-w-5xl mx-auto">
88+
<div className="max-w-5xl mx-auto p-2">
8989
<div className="border rounded-md">
9090
<Table>
9191
<TableHeader>

frontend/apps/hub/src/routes/_authenticated/_layout/projects/$projectNameId/environments/$environmentNameId._v2/functions.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function ProjectFunctionsRoute() {
7171
<>
7272
<Modals />
7373

74-
<div className="max-w-5xl mx-auto my-8 flex justify-between items-center">
74+
<div className="max-w-5xl mx-auto my-8 flex justify-between items-center p-4">
7575
<H1>Functions</H1>
7676
<div className="flex items-center gap-2">
7777
<Button
@@ -96,7 +96,7 @@ function ProjectFunctionsRoute() {
9696
<hr className="mb-4" />
9797

9898
<div className="p-4">
99-
<div className="max-w-5xl mx-auto">
99+
<div className="max-w-5xl mx-auto p-2">
100100
<div className="border rounded-md">
101101
<Table>
102102
<TableHeader>

frontend/apps/hub/src/routes/_authenticated/_layout/projects/$projectNameId/environments/$environmentNameId._v2/settings.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ import { z } from "zod";
1515
function EnvironmentSettingsRoute() {
1616
return (
1717
<>
18-
<div className="max-w-5xl mx-auto my-8 flex justify-between items-center">
18+
<div className="max-w-5xl mx-auto my-8 flex justify-between items-center p-4">
1919
<H1>Settings</H1>
2020
</div>
2121

2222
<hr />
2323
<div className="p-4">
24-
<div className="max-w-5xl mx-auto flex flex-col gap-8">
24+
<div className="max-w-5xl mx-auto flex flex-col gap-8 p-2">
2525
<ServiceTokenCard />
2626
<Modals />
2727
</div>

0 commit comments

Comments
 (0)