Skip to content

fix: hide groups in account page if not enabled #10898

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions site/src/pages/UserSettingsPage/AccountPage/AccountPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,25 @@ 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";
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 (
<Stack spacing={6}>
Expand All @@ -33,11 +39,13 @@ export const AccountPage: FC = () => {
</Section>

{/* Has <Section> embedded inside because its description is dynamic */}
<AccountUserGroups
groups={groupsQuery.data}
loading={groupsQuery.isLoading}
error={groupsQuery.error}
/>
{hasGroupsFeature && (
<AccountUserGroups
groups={groupsQuery.data}
loading={groupsQuery.isLoading}
error={groupsQuery.error}
/>
)}
</Stack>
);
};
Expand Down