Jelajahi Sumber

Redirects to cloud-endpoints instead of replicas when there are no connections CORWEB-29

George Vrancianu 8 tahun lalu
induk
melakukan
b71a5b63a8

+ 1 - 2
src/actions/UserActions/UserActions.js

@@ -18,7 +18,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 import Reflux from 'reflux';
 import Api from '../../components/ApiCaller';
 import { servicesUrl, defaultDomain } from '../../config';
-import Location from '../../core/Location';
+
 
 let UserAction = Reflux.createActions({
   login: { children: ["success", "failed"] },
@@ -65,7 +65,6 @@ UserAction.login.listen((userData, callback = null) => {
   })
     .then((response) => {
       UserAction.login.success(response)
-      Location.push('/replicas')
     }, () => {
       UserAction.login.failed()
       if (typeof callback == "function") {

+ 10 - 0
src/stores/ConnectionsStore/ConnectionsStore.js

@@ -25,6 +25,7 @@ import MigrationActions from '../../actions/MigrationActions';
 import Helper from '../../components/Helper';
 import Api from '../../components/ApiCaller'
 import {servicesUrl, providerType} from '../../config';
+import Location from '../../core/Location';
 
 class ConnectionsStore extends Reflux.Store
 {
@@ -194,7 +195,16 @@ class ConnectionsStore extends Reflux.Store
         })*/
       })
     }
+
     this.setState({connections: connections})
+
+    if (window.location.pathname === "/" || window.location.pathname === "/login") {
+      if (connections.length === 0) {
+        Location.push('/cloud-endpoints')
+      } else {
+        Location.push('/replicas')
+      }
+    }
     ConnectionsActions.assignConnectionProvider()
     MigrationActions.loadMigrations()
     MigrationActions.loadReplicas()

+ 0 - 4
src/stores/UserStore/UserStore.js

@@ -99,10 +99,6 @@ class UserStore extends Reflux.Store
     ConnectionsActions.loadConnections()
     UserActions.getScopedProjects()
     UserActions.getUserInfo(currentUser.id)
-
-    if (window.location.pathname == "/" || window.location.pathname == "/login") {
-      Location.push('/replicas');
-    }
   }
 
   onLoginScopeFailed(token) {