Skip to content

Commit 365611d

Browse files
committed
feat: - hide custom roles tab if experiment is not enabled
1 parent 0af1ae8 commit 365611d

File tree

2 files changed

+14
-23
lines changed

2 files changed

+14
-23
lines changed

site/src/pages/ManagementSettingsPage/CustomRolesPage/CustomRolesPage.tsx

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,21 @@ import Button from "@mui/material/Button";
33
import { type FC, useEffect } from "react";
44
import { Helmet } from "react-helmet-async";
55
import { useQuery } from "react-query";
6-
import { Link as RouterLink, useLocation, useParams } from "react-router-dom";
6+
import { Link as RouterLink, useParams } from "react-router-dom";
77
import { getErrorMessage } from "api/errors";
88
import { organizationRoles } from "api/queries/roles";
99
import { displayError } from "components/GlobalSnackbar/utils";
1010
import { PageHeader, PageHeaderTitle } from "components/PageHeader/PageHeader";
1111
import { useAuthenticated } from "contexts/auth/RequireAuth";
12-
import { useDashboard } from "modules/dashboard/useDashboard";
1312
import { useFeatureVisibility } from "modules/dashboard/useFeatureVisibility";
1413
import { pageTitle } from "utils/page";
1514
import CustomRolesPageView from "./CustomRolesPageView";
1615

1716
export const CustomRolesPage: FC = () => {
1817
const { permissions } = useAuthenticated();
1918
const { assignOrgRole: canAssignOrgRole } = permissions;
20-
const {
21-
multiple_organizations: organizationsEnabled,
22-
custom_roles: isCustomRolesEnabled,
23-
} = useFeatureVisibility();
24-
const { experiments } = useDashboard();
25-
const location = useLocation();
19+
const { custom_roles: isCustomRolesEnabled } = useFeatureVisibility();
20+
2621
const { organization = "default" } = useParams() as { organization: string };
2722
const organizationRolesQuery = useQuery(organizationRoles(organization));
2823
const filteredRoleData = organizationRolesQuery.data?.filter(
@@ -40,16 +35,6 @@ export const CustomRolesPage: FC = () => {
4035
}
4136
}, [organizationRolesQuery.error]);
4237

43-
// if (
44-
// organizationsEnabled &&
45-
// experiments.includes("multi-organization") &&
46-
// location.pathname === "/deployment/groups"
47-
// ) {
48-
// const defaultName =
49-
// getOrganizationNameByDefault(organizations) ?? "default";
50-
// return <Navigate to={`/organizations/${defaultName}/groups`} replace />;
51-
// }
52-
5338
return (
5439
<>
5540
<Helmet>

site/src/pages/ManagementSettingsPage/Sidebar.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@ import AddIcon from "@mui/icons-material/Add";
44
import SettingsIcon from "@mui/icons-material/Settings";
55
import type { FC, ReactNode } from "react";
66
import { Link, NavLink, useLocation, useParams } from "react-router-dom";
7-
import type { Organization } from "api/typesGenerated";
7+
import type { Experiments, Organization } from "api/typesGenerated";
88
import { Sidebar as BaseSidebar } from "components/Sidebar/Sidebar";
99
import { Stack } from "components/Stack/Stack";
1010
import { UserAvatar } from "components/UserAvatar/UserAvatar";
1111
import { type ClassName, useClassName } from "hooks/useClassName";
12+
import { useDashboard } from "modules/dashboard/useDashboard";
1213
import { useFeatureVisibility } from "modules/dashboard/useFeatureVisibility";
1314
import { linkToAuditing, linkToUsers, withFilter } from "modules/navigation";
1415
import { useOrganizationSettings } from "./ManagementSettingsLayout";
1516

1617
export const Sidebar: FC = () => {
18+
const { experiments } = useDashboard();
1719
const { organizations } = useOrganizationSettings();
1820
const { organization } = useParams() as { organization?: string };
1921
const { multiple_organizations: organizationsEnabled } =
@@ -49,6 +51,7 @@ export const Sidebar: FC = () => {
4951
key={org.id}
5052
organization={org}
5153
active={org.name === organizationName}
54+
experiments={experiments}
5255
/>
5356
))}
5457
</>
@@ -123,11 +126,12 @@ function urlForSubpage(organizationName: string, subpage: string = ""): string {
123126
interface OrganizationSettingsNavigationProps {
124127
organization: Organization;
125128
active: boolean;
129+
experiments: Experiments;
126130
}
127131

128132
export const OrganizationSettingsNavigation: FC<
129133
OrganizationSettingsNavigationProps
130-
> = ({ organization, active }) => {
134+
> = ({ organization, active, experiments }) => {
131135
return (
132136
<>
133137
<SidebarNavItem
@@ -155,9 +159,11 @@ export const OrganizationSettingsNavigation: FC<
155159
<SidebarNavSubItem href={urlForSubpage(organization.name, "groups")}>
156160
Groups
157161
</SidebarNavSubItem>
158-
<SidebarNavSubItem href={urlForSubpage(organization.name, "roles")}>
159-
Roles
160-
</SidebarNavSubItem>
162+
{experiments.includes("custom-roles") && (
163+
<SidebarNavSubItem href={urlForSubpage(organization.name, "roles")}>
164+
Roles
165+
</SidebarNavSubItem>
166+
)}
161167
{/* For now redirect to the site-wide audit page with the organization
162168
pre-filled into the filter. Based on user feedback we might want
163169
to serve a copy of the audit page or even delete this link. */}

0 commit comments

Comments
 (0)