Просмотр исходного кода

chore: disable infratab for non porter users

Soham Parekh 3 лет назад
Родитель
Сommit
2c575bb1b8

+ 12 - 10
dashboard/src/main/home/Home.tsx

@@ -435,16 +435,18 @@ class Home extends Component<PropsType, StateType> {
                 return <Onboarding />;
               }}
             />
-            <Route
-              path="/infrastructure"
-              render={() => {
-                return (
-                  <DashboardWrapper>
-                    <InfrastructureRouter />
-                  </DashboardWrapper>
-                );
-              }}
-            />
+            {this.context.user.isPorterUser ? (
+              <Route
+                path="/infrastructure"
+                render={() => {
+                  return (
+                    <DashboardWrapper>
+                      <InfrastructureRouter />
+                    </DashboardWrapper>
+                  );
+                }}
+              />
+            ) : null}
             <Route
               path="/dashboard"
               render={() => {

+ 9 - 7
dashboard/src/main/home/sidebar/Sidebar.tsx

@@ -101,7 +101,7 @@ class Sidebar extends Component<PropsType, StateType> {
 
   renderProjectContents = () => {
     let { currentView } = this.props;
-    let { currentProject } = this.context;
+    let { currentProject, user } = this.context;
     if (currentProject) {
       return (
         <ScrollWrapper>
@@ -114,12 +114,14 @@ class Sidebar extends Component<PropsType, StateType> {
             <Img src={rocket} />
             Launch
           </NavButton>
-          {currentProject && currentProject.managed_infra_enabled && (
-            <NavButton path={"/infrastructure"}>
-              <i className="material-icons">build_circle</i>
-              Infrastructure
-            </NavButton>
-          )}
+          {currentProject &&
+            currentProject.managed_infra_enabled &&
+            user.isPorterUser && (
+              <NavButton path={"/infrastructure"}>
+                <i className="material-icons">build_circle</i>
+                Infrastructure
+              </NavButton>
+            )}
           {this.props.isAuthorized("integrations", "", [
             "get",
             "create",

+ 3 - 1
dashboard/src/shared/Context.tsx

@@ -129,7 +129,9 @@ class ContextProvider extends Component<PropsType, StateType> {
     },
     user: null,
     setUser: (userId: number, email: string) => {
-      this.setState({ user: { userId, email } });
+      this.setState({
+        user: { userId, email, isPorterUser: email.endsWith("@porter.run") },
+      });
     },
     devOpsMode: true,
     setDevOpsMode: (devOpsMode: boolean) => {