Jo Chuang 5 лет назад
Родитель
Сommit
5d8df11e3d

+ 9 - 7
dashboard/src/main/Main.tsx

@@ -11,7 +11,7 @@ import Register from './Register';
 import CurrentError from './CurrentError';
 import Home from './home/Home';
 import Loading from 'components/Loading';
-import PorterUrls from 'shared/urls';
+import {PorterUrls} from 'shared/urls';
 
 type PropsType = {
 };
@@ -92,14 +92,16 @@ export default class Main extends Component<PropsType, StateType> {
         }} />
 
         // TODO: Possible template this into a map from url to routed home
-        {...authedUrls.map(route =>
-            <Route key={route} path={`/${route}`} render={() => {
-            if (this.state.isLoggedIn && this.state.initialized) {
+        {/* {...authedUrls.map(route => */}
+            <Route path={`/:subroute`} render={routeProps => {
+            const urlRoute = routeProps.location.pathname.slice(1);
+            if (this.state.isLoggedIn && this.state.initialized && PorterUrls.includes(urlRoute)) {
               return (
-                <Home 
+                <Home
+                  key="home"
                   currentProject={this.context.currentProject}
                   currentCluster={this.context.currentCluster} 
-                  currentRoute={route}
+                  currentRoute={urlRoute as PorterUrls}
                   logOut={this.handleLogOut} 
                 />
               );
@@ -107,7 +109,7 @@ export default class Main extends Component<PropsType, StateType> {
               return <Redirect to='/' />
             }
           }}/>
-        )}
+        {/* )} */}
         
 
         <Route path='/' render={() => {

+ 4 - 4
dashboard/src/main/home/Home.tsx

@@ -25,7 +25,7 @@ import ConfirmOverlay from 'components/ConfirmOverlay';
 import Modal from './modals/Modal';
 import * as FullStory from '@fullstory/browser';
 import { Redirect, RouteComponentProps, withRouter } from 'react-router';
-import PorterUrls from 'shared/urls';
+import {PorterUrls} from 'shared/urls';
 
 type PropsType = RouteComponentProps & {
   logOut: () => void,
@@ -216,7 +216,7 @@ class Home extends Component<PropsType, StateType> {
     this.setState({ ghRedirect: urlParams.get('gh_oauth') !== null });
     urlParams.delete('gh_oauth');
     
-    window.location.href.indexOf('127.0.0.1') === -1 && posthog.init(process.env.POSTHOG_API_KEY || 'placeholder', {
+    window.location.href.indexOf('localhost') === -1 && posthog.init(process.env.POSTHOG_API_KEY || 'placeholder', {
       api_host: process.env.POSTHOG_HOST || 'placeholder',
       loaded: function(posthog: any) { 
         posthog.identify(user.userId) 
@@ -278,7 +278,6 @@ class Home extends Component<PropsType, StateType> {
   }
 
   renderContents = () => {
-    // let { handleDO } = this.state;
     let currentView = this.props.currentRoute;
     if (this.context.currentProject && currentView !== 'new-project') {
       if (currentView === 'cluster-dashboard') {
@@ -322,6 +321,7 @@ class Home extends Component<PropsType, StateType> {
       } else {
         return (
           <Sidebar
+            key="sidebar"
             forceSidebar={this.state.forceSidebar}
             setWelcome={(x: boolean) => this.setState({ showWelcome: x })}
             currentView={this.props.currentRoute}
@@ -418,7 +418,7 @@ class Home extends Component<PropsType, StateType> {
         }
       }
     });
-    setCurrentModal(null, null)
+    setCurrentModal(null, null);
     this.props.history.push("dashboard");
   }
 

+ 1 - 1
dashboard/src/main/home/dashboard/Dashboard.tsx

@@ -98,7 +98,7 @@ class Dashboard extends Component<PropsType, StateType> {
                 <>
                   <Banner>
                     <i className="material-icons">error_outline</i>
-                    This project currently has no clusters conncted.
+                    This project currently has no clusters connected.
                     </Banner>
                   <ProvisionerSettings 
                     infras={infras}

+ 1 - 1
dashboard/src/main/home/sidebar/ClusterSection.tsx

@@ -77,7 +77,7 @@ class ClusterSection extends Component<PropsType, StateType> {
           ) {
             this.setState({ clusters: [] });
             setCurrentCluster(null);
-            this.props.history.push('dashboard');
+            // this.props.history.push("dashboard");
           }
         }
       }

+ 10 - 10
dashboard/src/shared/urls.tsx

@@ -1,11 +1,11 @@
-type PorterUrls =
-  | "dashboard"
-  | "templates"
-  | "integrations"
-  | "new-project"
-  | "cluster-dashboard"
-  | "provisioner"
-  | "project-settings";
+export const PorterUrls = [
+  "dashboard",
+  "templates",
+  "integrations",
+  "new-project",
+  "cluster-dashboard",
+  "provisioner",
+  "project-settings",
+];
 
-
-export default PorterUrls;
+export type PorterUrls = typeof PorterUrls[number];