From 532a49092de558d3b1240e10d285d7e1b546f1c5 Mon Sep 17 00:00:00 2001 From: Parkreiner Date: Mon, 27 Nov 2023 18:18:02 +0000 Subject: [PATCH] fix: hide groups in account page if not enabled --- .../AccountPage/AccountPage.tsx | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/site/src/pages/UserSettingsPage/AccountPage/AccountPage.tsx b/site/src/pages/UserSettingsPage/AccountPage/AccountPage.tsx index 4a38df0a1852e..e7b46df07d86f 100644 --- a/site/src/pages/UserSettingsPage/AccountPage/AccountPage.tsx +++ b/site/src/pages/UserSettingsPage/AccountPage/AccountPage.tsx @@ -5,6 +5,7 @@ import { useQuery } from "react-query"; import { groupsForUser } from "api/queries/groups"; import { useOrganizationId } from "hooks"; import { useAuth } from "components/AuthProvider/AuthProvider"; +import { useDashboard } from "components/Dashboard/DashboardProvider"; import { Stack } from "@mui/system"; import { AccountUserGroups } from "./AccountUserGroups"; @@ -12,12 +13,17 @@ import { AccountForm } from "./AccountForm"; import { Section } from "components/SettingsLayout/Section"; export const AccountPage: FC = () => { - const { updateProfile, updateProfileError, isUpdatingProfile } = useAuth(); - const permissions = usePermissions(); - const me = useMe(); + const permissions = usePermissions(); const organizationId = useOrganizationId(); - const groupsQuery = useQuery(groupsForUser(organizationId, me.id)); + const { updateProfile, updateProfileError, isUpdatingProfile } = useAuth(); + const { entitlements } = useDashboard(); + + const hasGroupsFeature = entitlements.features.user_role_management.enabled; + const groupsQuery = useQuery({ + ...groupsForUser(organizationId, me.id), + enabled: hasGroupsFeature, + }); return ( @@ -33,11 +39,13 @@ export const AccountPage: FC = () => { {/* Has
embedded inside because its description is dynamic */} - + {hasGroupsFeature && ( + + )} ); };