Skip to content

feat(site): add descriptions for each auth method to the selection menu #9252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 23, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
refactor to a map
  • Loading branch information
aslilac committed Aug 23, 2023
commit 0a5c7d39355669f08eabca35a74fc7c93e99f215
46 changes: 19 additions & 27 deletions site/src/components/CreateUserForm/CreateUserForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,33 +105,13 @@ export const CreateUserForm: FC<
)

const styles = useStyles()
// This, unfortunately, cannot be an actual component because mui requires
// that all `MenuItem`s must be direct children of the `Select` they belong to
const authMethodSelect = (value: keyof typeof authMethodLanguage) => {
const language = authMethodLanguage[value]
return (
<MenuItem key={value} id={"item-" + value} value={value}>
<Stack spacing={0} maxWidth={400}>
{language.displayName}
<span className={styles.labelDescription}>
{language.description}
</span>
</Stack>
</MenuItem>
)
}

const methods = []
if (authMethods?.password.enabled) {
methods.push(authMethodSelect("password"))
}
if (authMethods?.oidc.enabled) {
methods.push(authMethodSelect("oidc"))
}
if (authMethods?.github.enabled) {
methods.push(authMethodSelect("github"))
}
methods.push(authMethodSelect("none"))
const methods = [
authMethods?.password.enabled && "password",
authMethods?.oidc.enabled && "oidc",
authMethods?.github.enabled && "github",
"none",
].filter(Boolean) as Array<keyof typeof authMethodLanguage>

return (
<FullPageForm title="Create user">
Expand Down Expand Up @@ -177,7 +157,19 @@ export const CreateUserForm: FC<
?.displayName ?? "",
}}
>
{methods}
{methods.map((value) => {
const language = authMethodLanguage[value]
return (
<MenuItem key={value} id={"item-" + value} value={value}>
<Stack spacing={0} maxWidth={400}>
{language.displayName}
<span className={styles.labelDescription}>
{language.description}
</span>
</Stack>
</MenuItem>
)
})}
</TextField>
<TextField
{...getFieldHelpers(
Expand Down