Skip to content

Commit 90d900c

Browse files
committed
Fix Prettier and Go test and TS compile error
1 parent 0f4a40e commit 90d900c

File tree

3 files changed

+71
-59
lines changed

3 files changed

+71
-59
lines changed

coderd/userauth_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ func TestUserAuthMethods(t *testing.T) {
7777

7878
methods, err := client.AuthMethods(ctx)
7979
require.NoError(t, err)
80-
require.True(t, methods.Password)
81-
require.False(t, methods.Github)
80+
require.True(t, methods.Password.Enabled)
81+
require.False(t, methods.Github.Enabled)
8282
})
8383
t.Run("Github", func(t *testing.T) {
8484
t.Parallel()
@@ -91,8 +91,8 @@ func TestUserAuthMethods(t *testing.T) {
9191

9292
methods, err := client.AuthMethods(ctx)
9393
require.NoError(t, err)
94-
require.True(t, methods.Password)
95-
require.True(t, methods.Github)
94+
require.True(t, methods.Password.Enabled)
95+
require.True(t, methods.Github.Enabled)
9696
})
9797
}
9898

site/src/components/SignInForm/SignInForm.tsx

+64-52
Original file line numberDiff line numberDiff line change
@@ -131,57 +131,60 @@ export const SignInForm: FC<React.PropsWithChildren<SignInFormProps>> = ({
131131
return (
132132
<>
133133
<Welcome />
134-
{!authMethods?.password.hidden && (<form onSubmit={form.handleSubmit}>
135-
<Stack>
136-
{Object.keys(loginErrors).map(
137-
(errorKey: string) =>
138-
Boolean(loginErrors[errorKey as LoginErrors]) && (
139-
<AlertBanner
140-
key={errorKey}
141-
severity="error"
142-
error={loginErrors[errorKey as LoginErrors]}
143-
text={Language.errorMessages[errorKey as LoginErrors]}
144-
/>
145-
),
146-
)}
147-
<TextField
148-
{...getFieldHelpers("email")}
149-
onChange={onChangeTrimmed(form)}
150-
autoFocus
151-
autoComplete="email"
152-
fullWidth
153-
label={Language.emailLabel}
154-
type="email"
155-
variant="outlined"
156-
/>
157-
<TextField
158-
{...getFieldHelpers("password")}
159-
autoComplete="current-password"
160-
fullWidth
161-
id="password"
162-
label={Language.passwordLabel}
163-
type="password"
164-
variant="outlined"
165-
/>
166-
<div>
167-
<LoadingButton
168-
loading={isLoading}
134+
{!authMethods?.password.hidden && (
135+
<form onSubmit={form.handleSubmit}>
136+
<Stack>
137+
{Object.keys(loginErrors).map(
138+
(errorKey: string) =>
139+
Boolean(loginErrors[errorKey as LoginErrors]) && (
140+
<AlertBanner
141+
key={errorKey}
142+
severity="error"
143+
error={loginErrors[errorKey as LoginErrors]}
144+
text={Language.errorMessages[errorKey as LoginErrors]}
145+
/>
146+
),
147+
)}
148+
<TextField
149+
{...getFieldHelpers("email")}
150+
onChange={onChangeTrimmed(form)}
151+
autoFocus
152+
autoComplete="email"
169153
fullWidth
170-
type="submit"
171-
variant="contained"
172-
>
173-
{isLoading ? "" : Language.passwordSignIn}
174-
</LoadingButton>
175-
</div>
176-
</Stack>
177-
</form>)}
178-
{(!authMethods?.password.hidden && (authMethods?.github.enabled || authMethods?.oidc.enabled)) && (
179-
<div className={styles.divider}>
180-
<div className={styles.dividerLine}/>
181-
<div className={styles.dividerLabel}>Or</div>
182-
<div className={styles.dividerLine}/>
183-
</div>
154+
label={Language.emailLabel}
155+
type="email"
156+
variant="outlined"
157+
/>
158+
<TextField
159+
{...getFieldHelpers("password")}
160+
autoComplete="current-password"
161+
fullWidth
162+
id="password"
163+
label={Language.passwordLabel}
164+
type="password"
165+
variant="outlined"
166+
/>
167+
<div>
168+
<LoadingButton
169+
loading={isLoading}
170+
fullWidth
171+
type="submit"
172+
variant="contained"
173+
>
174+
{isLoading ? "" : Language.passwordSignIn}
175+
</LoadingButton>
176+
</div>
177+
</Stack>
178+
</form>
184179
)}
180+
{!authMethods?.password.hidden &&
181+
(authMethods?.github.enabled || authMethods?.oidc.enabled) && (
182+
<div className={styles.divider}>
183+
<div className={styles.dividerLine} />
184+
<div className={styles.dividerLabel}>Or</div>
185+
<div className={styles.dividerLine} />
186+
</div>
187+
)}
185188
{(authMethods?.github.enabled || authMethods?.oidc.enabled) && (
186189
<Box display="grid" gridGap="16px">
187190
{authMethods.github.enabled && (
@@ -211,9 +214,18 @@ export const SignInForm: FC<React.PropsWithChildren<SignInFormProps>> = ({
211214
)}`}
212215
>
213216
<Button
214-
startIcon={authMethods.oidc.iconUrl
215-
? <img alt="Open ID Connect icon" src={authMethods.oidc.iconUrl} width="24" height="24"/>
216-
: <KeyIcon className={styles.buttonIcon} />}
217+
startIcon={
218+
authMethods.oidc.iconUrl ? (
219+
<img
220+
alt="Open ID Connect icon"
221+
src={authMethods.oidc.iconUrl}
222+
width="24"
223+
height="24"
224+
/>
225+
) : (
226+
<KeyIcon className={styles.buttonIcon} />
227+
)
228+
}
217229
disabled={isLoading}
218230
fullWidth
219231
type="submit"

site/src/testHelpers/entities.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,9 @@ export const MockUserAgent: Types.UserAgent = {
551551
}
552552

553553
export const MockAuthMethods: TypesGen.AuthMethods = {
554-
password: true,
555-
github: false,
556-
oidc: false,
554+
password: { enabled: true, hidden: false },
555+
github: { enabled: false },
556+
oidc: { enabled: false, signInText: "", iconUrl: "" },
557557
}
558558

559559
export const MockGitSSHKey: TypesGen.GitSSHKey = {

0 commit comments

Comments
 (0)