8000 fix(site): validate group name before submitting to the backend · coder/coder@c592357 · GitHub
[go: up one dir, main page]

Skip to content {"props":{"docsUrl":"https://docs.github.com/get-started/accessibility/keyboard-shortcuts"}}

Commit c592357

Browse files
committed
fix(site): validate group name before submitting to the backend
Change-Id: I6ffc2d571b2f6c6387ef143e0b0e74cf4196a551 Signed-off-by: Thomas Kosiewski <tk@coder.com>
1 parent 24dd8a1 commit c592357

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ site/stats/
5454

5555
# direnv
5656
.envrc
57+
.direnv
5758
*.test
5859

5960
# Loadtesting

site/src/pages/GroupsPage/CreateGroupPageView.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@ import { Stack } from "components/Stack/Stack";
1212
import { type FormikTouched, useFormik } from "formik";
1313
import type { FC } from "react";
1414
import { useNavigate } from "react-router-dom";
15-
import { getFormHelpers, onChangeTrimmed } from "utils/formUtils";
15+
import {
16+
getFormHelpers,
17+
nameValidator,
18+
onChangeTrimmed,
19+
} from "utils/formUtils";
1620
import * as Yup from "yup";
1721

1822
const validationSchema = Yup.object({
19-
name: Yup.string().required().label("Name"),
23+
name: nameValidator("Name"),
2024
});
2125

2226
export type CreateGroupPageViewProps = {
@@ -62,13 +66,16 @@ export const CreateGroupPageView: FC<CreateGroupPageViewProps> = ({
6266
autoFocus
6367
fullWidth
6468
label="Name"
69+
onChange={onChangeTrimmed(form)}
70+
autoComplete="name"
6571
/>
6672
<TextField
6773
{...getFieldHelpers("display_name", {
6874
helperText: "Optional: keep empty to default to the name.",
6975
})}
7076
fullWidth
7177
label="Display Name"
78+
autoComplete="display_name"
7279
/>
7380
<IconField
7481
{...getFieldHelpers("avatar_url")}

site/src/pages/ManagementSettingsPage/GroupsPage/CreateGroupPageView.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@ import { Spinner } from "components/Spinner/Spinner";
1515
import { useFormik } from "formik";
1616
import type { FC } from "react";
1717
import { useNavigate } from "react-router-dom";
18-
import { getFormHelpers, onChangeTrimmed } from "utils/formUtils";
18+
import {
19+
getFormHelpers,
20+
nameValidator,
21+
onChangeTrimmed,
22+
} from "utils/formUtils";
1923
import * as Yup from "yup";
2024

2125
const validationSchema = Yup.object({
22-
name: Yup.string().required().label("Name"),
26+
name: nameValidator("Name"),
2327
});
2428

2529
export type CreateGroupPageViewProps = {
@@ -69,13 +73,16 @@ export const CreateGroupPageView: FC<CreateGroupPageViewProps> = ({
6973
autoFocus
7074
fullWidth
7175
label="Name"
76+
onChange={onChangeTrimmed(form)}
77+
autoComplete="name"
7278
/>
7379
<TextField
7480
{...getFieldHelpers("display_name", {
7581
helperText: "Optional: keep empty to default to the name.",
7682
})}
7783
fullWidth
7884
label="Display Name"
85+
autoComplete="display_name"
7986
/>
8087
<IconField
8188
{...getFieldHelpers("avatar_url")}

0 commit comments

Comments
 (0)
0