Jelajahi Sumber

feat: enable infratab overrides

Soham Parekh 3 tahun lalu
induk
melakukan
dcbbfbef61

+ 5 - 1
dashboard/src/main/home/Home.tsx

@@ -27,6 +27,7 @@ import Onboarding from "./onboarding/Onboarding";
 import ModalHandler from "./ModalHandler";
 import { NewProjectFC } from "./new-project/NewProject";
 import InfrastructureRouter from "./infrastructure/InfrastructureRouter";
+import { overrideInfraTabEnabled } from "utils/infrastructure";
 
 // Guarded components
 const GuardedProjectSettings = fakeGuardedRoute("settings", "", [
@@ -434,7 +435,10 @@ class Home extends Component<PropsType, StateType> {
                 return <Onboarding />;
               }}
             />
-            {this.context.user.isPorterUser ? (
+            {this.context.user.isPorterUser ||
+            overrideInfraTabEnabled({
+              projectID: this.context.currentProject.id,
+            }) ? (
               <Route
                 path="/infrastructure"
                 render={() => {

+ 3 - 1
dashboard/src/main/home/sidebar/Sidebar.tsx

@@ -13,6 +13,7 @@ import { RouteComponentProps, withRouter } from "react-router";
 import { getQueryParam, pushFiltered } from "shared/routing";
 import { withAuth, WithAuthProps } from "shared/auth/AuthorizationHoc";
 import SidebarLink from "./SidebarLink";
+import { overrideInfraTabEnabled } from "utils/infrastructure";
 
 type PropsType = RouteComponentProps &
   WithAuthProps & {
@@ -116,7 +117,8 @@ class Sidebar extends Component<PropsType, StateType> {
           </NavButton>
           {currentProject &&
             currentProject.managed_infra_enabled &&
-            user?.isPorterUser && (
+            (user?.isPorterUser ||
+              overrideInfraTabEnabled({ projectID: currentProject.id })) && (
               <NavButton path={"/infrastructure"}>
                 <i className="material-icons">build_circle</i>
                 Infrastructure

+ 11 - 0
dashboard/src/utils/infrastructure.tsx

@@ -0,0 +1,11 @@
+interface OverrideInfraTabEnabledProps {
+  projectID: number;
+}
+
+export const overrideInfraTabEnabled = ({
+  projectID,
+}: OverrideInfraTabEnabledProps) => {
+  const ALLOWED_PROJECTS = [6638];
+
+  return ALLOWED_PROJECTS.some((id) => id === projectID);
+};