Skip to content

Commit 5dca493

Browse files
committed
fix selector onchange
1 parent 3f08b16 commit 5dca493

File tree

1 file changed

+42
-7
lines changed

1 file changed

+42
-7
lines changed

site/src/components/CreateUserForm/CreateUserForm.tsx

+42-7
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,17 @@ const validationSchema = Yup.object({
4545
username: nameValidator(Language.usernameLabel),
4646
})
4747

48-
const authMethodSelect = (title: string, value: string) => {
49-
return <MenuItem value={value}>{title}</MenuItem>
48+
const authMethodSelect = (
49+
title: string,
50+
value: string,
51+
description: string,
52+
) => {
53+
return (
54+
<MenuItem id={value} value={value}>
55+
{title}
56+
{/* TODO: Add description */}
57+
</MenuItem>
58+
)
5059
}
5160

5261
export const CreateUserForm: FC<
@@ -72,15 +81,39 @@ export const CreateUserForm: FC<
7281

7382
const methods = []
7483
if (authMethods?.password.enabled) {
75-
methods.push(authMethodSelect("Password", "password"))
84+
methods.push(
85+
authMethodSelect(
86+
"Password",
87+
"password",
88+
"User can provide their email and password to login.",
89+
),
90+
)
7691
}
7792
if (authMethods?.oidc.enabled) {
78-
methods.push(authMethodSelect("OIDC", "oidc"))
93+
methods.push(
94+
authMethodSelect(
95+
"OIDC",
96+
"oidc",
97+
"Uses an OIDC provider to authenticate the user.",
98+
),
99+
)
79100
}
80101
if (authMethods?.github.enabled) {
81-
methods.push(authMethodSelect("Github", "github"))
102+
methods.push(
103+
authMethodSelect(
104+
"Github",
105+
"github",
106+
"Uses github oauth to authenticate the user.",
107+
),
108+
)
82109
}
83-
methods.push(authMethodSelect("None", "none"))
110+
methods.push(
111+
authMethodSelect(
112+
"None",
113+
"none",
114+
"User authentication is disabled. This user an only be used if an api token is created for them.",
115+
),
116+
)
84117

85118
return (
86119
<FullPageForm title="Create user">
@@ -118,7 +151,9 @@ export const CreateUserForm: FC<
118151
id="login_type"
119152
value={form.values.login_type}
120153
label="Login Type"
121-
onChange={form.handleChange}
154+
onChange={async (e) => {
155+
await form.setFieldValue("login_type", e.target.value)
156+
}}
122157
>
123158
{methods}
124159
</Select>

0 commit comments

Comments
 (0)