From f8e4e667d5a8237b280d408230cb6821ec51e4a5 Mon Sep 17 00:00:00 2001 From: McKayla Washburn Date: Wed, 30 Aug 2023 19:28:40 +0000 Subject: [PATCH 1/3] fix: hide OIDC and Github auth settings when they are disabled --- .../DeploySettingsLayout/OptionsTable.tsx | 2 +- .../UserAuthSettingsPageView.tsx | 93 ++++++++++--------- 2 files changed, 49 insertions(+), 46 deletions(-) diff --git a/site/src/components/DeploySettingsLayout/OptionsTable.tsx b/site/src/components/DeploySettingsLayout/OptionsTable.tsx index b573d41b5505b..98efc5a768d97 100644 --- a/site/src/components/DeploySettingsLayout/OptionsTable.tsx +++ b/site/src/components/DeploySettingsLayout/OptionsTable.tsx @@ -21,7 +21,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/UserAuthSettingsPage/UserAuthSettingsPageView.tsx b/site/src/pages/DeploySettingsPage/UserAuthSettingsPage/UserAuthSettingsPageView.tsx index a1c01adefcd28..1bf89edea3c2b 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 ? : } - - deploymentGroupHasParent(o.group, "OIDC"), + {oidcEnabled && ( + + deploymentGroupHasParent(o.group, "OIDC"), + )} + /> )} - /> -
+
-
-
+
+
- - {useDeploymentOptions(options, "OAuth2 GitHub Client ID")[0].value ? ( - - ) : ( - - )} - + + {githubEnabled ? : } + - - deploymentGroupHasParent(o.group, "GitHub"), + {githubEnabled && ( + + deploymentGroupHasParent(o.group, "GitHub"), + )} + /> )} - /> -
- - -) +
+
+ + ) +} From d37e6cf58040e03670bc291918a53c85d93bce40 Mon Sep 17 00:00:00 2001 From: McKayla Washburn Date: Wed, 30 Aug 2023 19:41:33 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=A7=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- site/src/components/DeploySettingsLayout/OptionsTable.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/site/src/components/DeploySettingsLayout/OptionsTable.tsx b/site/src/components/DeploySettingsLayout/OptionsTable.tsx index 98efc5a768d97..aef26610712ab 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<{ From bbd1341db6b6fe042487fd6ac5f097333c3c04cb Mon Sep 17 00:00:00 2001 From: McKayla Washburn Date: Wed, 30 Aug 2023 20:59:54 +0000 Subject: [PATCH 3/3] tweak security settings too --- .../SecuritySettingsPageView.tsx | 116 +++++++++--------- 1 file changed, 60 insertions(+), 56 deletions(-) diff --git a/site/src/pages/DeploySettingsPage/SecuritySettingsPage/SecuritySettingsPageView.tsx b/site/src/pages/DeploySettingsPage/SecuritySettingsPage/SecuritySettingsPageView.tsx index 3e5da55fb9f78..aad2743fb206a 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 && ( +
+
+ + +
+ )} +
+ + ) +}