From 4c91146cb8b9524d43fb4cf09d5ba912b2701de9 Mon Sep 17 00:00:00 2001 From: Kayla Washburn Date: Wed, 30 Aug 2023 15:56:18 -0600 Subject: [PATCH] fix: hide OIDC and Github auth settings when they are disabled (#9447) --- .../DeploySettingsLayout/OptionsTable.tsx | 3 +- .../SecuritySettingsPageView.tsx | 116 +++++++++--------- .../UserAuthSettingsPageView.tsx | 99 +++++++-------- 3 files changed, 112 insertions(+), 106 deletions(-) diff --git a/site/src/components/DeploySettingsLayout/OptionsTable.tsx b/site/src/components/DeploySettingsLayout/OptionsTable.tsx index b573d41b55..aef2661071 100644 --- a/site/src/components/DeploySettingsLayout/OptionsTable.tsx +++ b/site/src/components/DeploySettingsLayout/OptionsTable.tsx @@ -12,7 +12,6 @@ import { OptionValue, } from "components/DeploySettingsLayout/Option" import { FC } from "react" -import { DisabledBadge } from "./Badges" import { intervalToDuration, formatDuration } from "date-fns" const OptionsTable: FC<{ @@ -21,7 +20,7 @@ const OptionsTable: FC<{ const styles = useStyles() if (options.length === 0) { - return + return

No options to configure

} return ( diff --git a/site/src/pages/DeploySettingsPage/SecuritySettingsPage/SecuritySettingsPageView.tsx b/site/src/pages/DeploySettingsPage/SecuritySettingsPage/SecuritySettingsPageView.tsx index 3e5da55fb9..aad2743fb2 100644 --- a/site/src/pages/DeploySettingsPage/SecuritySettingsPage/SecuritySettingsPageView.tsx +++ b/site/src/pages/DeploySettingsPage/SecuritySettingsPage/SecuritySettingsPageView.tsx @@ -23,66 +23,70 @@ export const SecuritySettingsPageView = ({ options: options, featureAuditLogEnabled, featureBrowserOnlyEnabled, -}: SecuritySettingsPageViewProps): JSX.Element => ( - <> - -
-
+}: SecuritySettingsPageViewProps): JSX.Element => { + const tlsOptions = options.filter((o) => + deploymentGroupHasParent(o.group, "TLS"), + ) - -
+ return ( + <> + +
+
-
-
+ +
- - {featureAuditLogEnabled ? : } - - -
+
+
-
-
+ + {featureAuditLogEnabled ? : } + + +
- - {featureBrowserOnlyEnabled ? : } - - -
+
+
-
-
+ + {featureBrowserOnlyEnabled ? : } + + +
- - deploymentGroupHasParent(o.group, "TLS"), - )} - /> -
-
- -) + {tlsOptions.length > 0 && ( +
+
+ + +
+ )} +
+ + ) +} diff --git a/site/src/pages/DeploySettingsPage/UserAuthSettingsPage/UserAuthSettingsPageView.tsx b/site/src/pages/DeploySettingsPage/UserAuthSettingsPage/UserAuthSettingsPageView.tsx index a1c01adefc..1bf89edea3 100644 --- a/site/src/pages/DeploySettingsPage/UserAuthSettingsPage/UserAuthSettingsPageView.tsx +++ b/site/src/pages/DeploySettingsPage/UserAuthSettingsPage/UserAuthSettingsPageView.tsx @@ -19,56 +19,59 @@ export type UserAuthSettingsPageViewProps = { export const UserAuthSettingsPageView = ({ options, -}: UserAuthSettingsPageViewProps): JSX.Element => ( - <> - -
-
+}: UserAuthSettingsPageViewProps): JSX.Element => { + const oidcEnabled = Boolean( + useDeploymentOptions(options, "OIDC Client ID")[0].value, + ) + const githubEnabled = Boolean( + useDeploymentOptions(options, "OAuth2 GitHub Client ID")[0].value, + ) -
+ return ( + <> + +
+
- - {useDeploymentOptions(options, "OIDC Client ID")[0].value ? ( - - ) : ( - +
+ + {oidcEnabled ? : } + + {oidcEnabled && ( + + deploymentGroupHasParent(o.group, "OIDC"), + )} + /> )} - +
- - deploymentGroupHasParent(o.group, "OIDC"), +
+
+ + + {githubEnabled ? : } + + + {githubEnabled && ( + + deploymentGroupHasParent(o.group, "GitHub"), + )} + /> )} - /> -
- -
-
- - - {useDeploymentOptions(options, "OAuth2 GitHub Client ID")[0].value ? ( - - ) : ( - - )} - - - - deploymentGroupHasParent(o.group, "GitHub"), - )} - /> -
-
- -) +
+
+ + ) +}