Skip to content

Commit f8e4e66

Browse files
committed
fix: hide OIDC and Github auth settings when they are disabled
1 parent c6f4f0f commit f8e4e66

File tree

2 files changed

+49
-46
lines changed

2 files changed

+49
-46
lines changed

site/src/components/DeploySettingsLayout/OptionsTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const OptionsTable: FC<{
2121
const styles = useStyles()
2222

2323
if (options.length === 0) {
24-
return <DisabledBadge></DisabledBadge>
24+
return <p>No options to configure</p>
2525
}
2626

2727
return (

site/src/pages/DeploySettingsPage/UserAuthSettingsPage/UserAuthSettingsPageView.tsx

Lines changed: 48 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -19,56 +19,59 @@ export type UserAuthSettingsPageViewProps = {
1919

2020
export const UserAuthSettingsPageView = ({
2121
options,
22-
}: UserAuthSettingsPageViewProps): JSX.Element => (
23-
<>
24-
<Stack direction="column" spacing={6}>
25-
<div>
26-
<Header title="User Authentication" />
22+
}: UserAuthSettingsPageViewProps): JSX.Element => {
23+
const oidcEnabled = Boolean(
24+
useDeploymentOptions(options, "OIDC Client ID")[0].value,
25+
)
26+
const githubEnabled = Boolean(
27+
useDeploymentOptions(options, "OAuth2 GitHub Client ID")[0].value,
28+
)
2729

28-
<Header
29-
title="Login with OpenID Connect"
30-
secondary
31-
description="Set up authentication to login with OpenID Connect."
32-
docsHref={docs("/admin/auth#openid-connect-with-google")}
33-
/>
30+
return (
31+
<>
32+
<Stack direction="column" spacing={6}>
33+
<div>
34+
<Header title="User Authentication" />
3435

35-
<Badges>
36-
{useDeploymentOptions(options, "OIDC Client ID")[0].value ? (
37-
<EnabledBadge />
38-
) : (
39-
<DisabledBadge />
40-
)}
41-
</Badges>
36+
<Header
37+
title="Login with OpenID Connect"
38+
secondary
39+
description="Set up authentication to login with OpenID Connect."
40+
docsHref={docs("/admin/auth#openid-connect-with-google")}
41+
/>
42+
43+
<Badges>{oidcEnabled ? <EnabledBadge /> : <DisabledBadge />}</Badges>
4244

43-
<OptionsTable
44-
options={options.filter((o) =>
45-
deploymentGroupHasParent(o.group, "OIDC"),
45+
{oidcEnabled && (
46+
<OptionsTable
47+
options={options.filter((o) =>
48+
deploymentGroupHasParent(o.group, "OIDC"),
49+
)}
50+
/>
4651
)}
47-
/>
48-
</div>
52+
</div>
4953

50-
<div>
51-
<Header
52-
title="Login with GitHub"
53-
secondary
54-
description="Set up authentication to login with GitHub."
55-
docsHref={docs("/admin/auth#github")}
56-
/>
54+
<div>
55+
<Header
56+
title="Login with GitHub"
57+
secondary
58+
description="Set up authentication to login with GitHub."
59+
docsHref={docs("/admin/auth#github")}
60+
/>
5761

58-
<Badges>
59-
{useDeploymentOptions(options, "OAuth2 GitHub Client ID")[0].value ? (
60-
<EnabledBadge />
61-
) : (
62-
<DisabledBadge />
63-
)}
64-
</Badges>
62+
<Badges>
63+
{githubEnabled ? <EnabledBadge /> : <DisabledBadge />}
64+
</Badges>
6565

66-
<OptionsTable
67-
options={options.filter((o) =>
68-
deploymentGroupHasParent(o.group, "GitHub"),
66+
{githubEnabled && (
67+
<OptionsTable
68+
options={options.filter((o) =>
69+
deploymentGroupHasParent(o.group, "GitHub"),
70+
)}
71+
/>
6972
)}
70-
/>
71-
</div>
72-
</Stack>
73-
</>
74-
)
73+
</div>
74+
</Stack>
75+
</>
76+
)
77+
}

0 commit comments

Comments
 (0)