Skip to content

Commit 1f6e39c

Browse files
authored
fix: hide groups in account page if not enabled (coder#10898)
1 parent a4d74b8 commit 1f6e39c

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

site/src/pages/UserSettingsPage/AccountPage/AccountPage.tsx

+17-9
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,25 @@ import { useQuery } from "react-query";
55
import { groupsForUser } from "api/queries/groups";
66
import { useOrganizationId } from "hooks";
77
import { useAuth } from "components/AuthProvider/AuthProvider";
8+
import { useDashboard } from "components/Dashboard/DashboardProvider";
89

910
import { Stack } from "@mui/system";
1011
import { AccountUserGroups } from "./AccountUserGroups";
1112
import { AccountForm } from "./AccountForm";
1213
import { Section } from "components/SettingsLayout/Section";
1314

1415
export const AccountPage: FC = () => {
15-
const { updateProfile, updateProfileError, isUpdatingProfile } = useAuth();
16-
const permissions = usePermissions();
17-
1816
const me = useMe();
17+
const permissions = usePermissions();
1918
const organizationId = useOrganizationId();
20-
const groupsQuery = useQuery(groupsForUser(organizationId, me.id));
19+
const { updateProfile, updateProfileError, isUpdatingProfile } = useAuth();
20+
const { entitlements } = useDashboard();
21+
22+
const hasGroupsFeature = entitlements.features.user_role_management.enabled;
23+
const groupsQuery = useQuery({
24+
...groupsForUser(organizationId, me.id),
25+
enabled: hasGroupsFeature,
26+
});
2127

2228
return (
2329
<Stack spacing={6}>
@@ -33,11 +39,13 @@ export const AccountPage: FC = () => {
3339
</Section>
3440

3541
{/* Has <Section> embedded inside because its description is dynamic */}
36-
<AccountUserGroups
37-
groups={groupsQuery.data}
38-
loading={groupsQuery.isLoading}
39-
error={groupsQuery.error}
40-
/>
42+
{hasGroupsFeature && (
43+
<AccountUserGroups
44+
groups={groupsQuery.data}
45+
loading={groupsQuery.isLoading}
46+
error={groupsQuery.error}
47+
/>
48+
)}
4149
</Stack>
4250
);
4351
};

0 commit comments

Comments
 (0)