Przeglądaj źródła

Merge pull request #358 from porter-dev/master

Merge to staging
abelanger5 5 lat temu
rodzic
commit
5f6246f9a4

+ 15 - 14
dashboard/src/main/Main.tsx

@@ -94,20 +94,31 @@ export default class Main extends Component<PropsType, StateType> {
           }}
           }}
         />
         />
         <Route
         <Route
-          path={`/:subroute`}
+          exact
+          path="/"
+          render={() => {
+            if (this.state.isLoggedIn) {
+              return <Redirect to="/dashboard" />;
+            } else {
+              return <Redirect to="/login" />;
+            }
+          }}
+        />
+        <Route
+          path={`/*`}
           render={(routeProps) => {
           render={(routeProps) => {
-            const urlRoute = routeProps.location.pathname.slice(1);
+            const baseRoute = routeProps.location.pathname.slice(1);
             if (
             if (
               this.state.isLoggedIn &&
               this.state.isLoggedIn &&
               this.state.initialized &&
               this.state.initialized &&
-              PorterUrls.includes(urlRoute)
+              PorterUrls.includes(baseRoute)
             ) {
             ) {
               return (
               return (
                 <Home
                 <Home
                   key="home"
                   key="home"
                   currentProject={this.context.currentProject}
                   currentProject={this.context.currentProject}
                   currentCluster={this.context.currentCluster}
                   currentCluster={this.context.currentCluster}
-                  currentRoute={urlRoute as PorterUrl}
+                  currentRoute={baseRoute as PorterUrl}
                   logOut={this.handleLogOut}
                   logOut={this.handleLogOut}
                 />
                 />
               );
               );
@@ -116,16 +127,6 @@ export default class Main extends Component<PropsType, StateType> {
             }
             }
           }}
           }}
         />
         />
-        <Route
-          path="/"
-          render={() => {
-            if (this.state.isLoggedIn) {
-              return <Redirect to="/dashboard" />;
-            } else {
-              return <Redirect to="/login" />;
-            }
-          }}
-        />
       </Switch>
       </Switch>
     );
     );
   };
   };

+ 2 - 2
dashboard/src/main/home/cluster-dashboard/expanded-chart/SettingsSection.tsx

@@ -145,7 +145,7 @@ export default class SettingsSection extends Component<PropsType, StateType> {
     </Helper>
     </Helper>
   */
   */
   renderSourceSection = () => {
   renderSourceSection = () => {
-    if (!this.props.currentChart.form.hasSource) {
+    if (!this.props.currentChart?.form?.hasSource) {
       return;
       return;
     }
     }
 
 
@@ -235,7 +235,7 @@ export default class SettingsSection extends Component<PropsType, StateType> {
   };
   };
 
 
   renderWebhookSection = () => {
   renderWebhookSection = () => {
-    if (!this.props.currentChart.form.hasSource) {
+    if (!this.props.currentChart?.form?.hasSource) {
       return;
       return;
     }
     }
 
 

+ 6 - 0
internal/repository/gorm/cluster.go

@@ -252,6 +252,12 @@ func (repo *ClusterRepository) UpdateClusterTokenCache(
 		return nil, err
 		return nil, err
 	}
 	}
 
 
+	// delete the existing token cache first
+	if err := ctxDB.Where("id = ?", tokenCache.ID).Unscoped().Delete(&cluster.TokenCache).Error; err != nil {
+		return nil, err
+	}
+
+	// set the new token cache
 	cluster.TokenCache.Token = tokenCache.Token
 	cluster.TokenCache.Token = tokenCache.Token
 	cluster.TokenCache.Expiry = tokenCache.Expiry
 	cluster.TokenCache.Expiry = tokenCache.Expiry