RIFT-16172: Project switch does not affect polling and socket pages.
[osm/UI.git] / skyquake / plugins / accounts / src / account / accountStore.js
index dee59f2..22e8a17 100644 (file)
@@ -21,6 +21,7 @@ import AccountSource from './accountSource.js';
 var Utils = require('utils/utils.js');
 var rw = require('utils/rw.js');
 var altImage = rw.getSearchParams(window.location).alt_image;
+var _ = require('lodash');
 
 let Params = {
     //Config Agent
@@ -115,14 +116,6 @@ let AccountMeta = {
             }, {
                 label: "Authentication URL",
                 ref: 'auth_url'
-            },{
-                label: "User Domain",
-                ref: 'user-domain',
-                optional: true
-            },{
-                label: "Project Domain",
-                ref: 'project-domain',
-                optional: true
             }, {
                 label: "Tenant",
                 ref: 'tenant'
@@ -133,6 +126,18 @@ let AccountMeta = {
                 label: 'Floating IP Pool',
                 ref: 'floating-ip-pool',
                 optional: true
+            }, {
+                label: "User Domain",
+                ref: 'user-domain',
+                optional: true
+            }, {
+                label: "Project Domain",
+                ref: 'project-domain',
+                optional: true
+            }, {
+              label: "Region",
+              ref: 'region',
+              optional: true
             }],
             "openvim": [{
                 label: "Host",
@@ -245,7 +250,7 @@ export default class AccountStore {
     }
     getResourceOrchestratorSuccess = (data) => {
         this.alt.actions.global.hideScreenLoader.defer();
-        if(data['account-type'] == 'openmano') {
+        if(data['rw-launchpad:resource-orchestrator'] && (data['rw-launchpad:resource-orchestrator']['account-type'] == 'openmano')) {
             this.setState({
                 showVIM: false
             })
@@ -287,7 +292,7 @@ export default class AccountStore {
                 if(self.currentAccount) {
                     let Account = self.getAccountFromStream(data[self.currentAccount.type].data, self.currentAccount.name);
                     newState.account = self.account;
-                    newState.account['connection-status'] = Account['connection-status']
+                    newState.account['connection-status'] = Account && Account['connection-status']
                 }
                 self.setState(newState)
             } catch(error) {
@@ -328,7 +333,7 @@ export default class AccountStore {
     }
     getAccountFromStream(data, name) {
         let result = null;
-        data.map(function(a) {
+        data && _.isArray(data) && data.map(function(a) {
             if(a.name == name) {
                 result = a;
             }
@@ -338,7 +343,7 @@ export default class AccountStore {
     viewAccount = ({type, name}) => {
         var data = null;
         var accounts = null;
-        if(this && this[type].length) {
+        if(this && this[type] && this[type].length) {
             accounts = this[type];
             data = this.getAccountFromStream(accounts, name);
             if(data) {
@@ -360,7 +365,7 @@ export default class AccountStore {
     }
     generateOptionsByName(data) {
         let results = [];
-        if (data && data.constructor.name == "Array") {
+        if (data && _.isArray(data)) {
           data.map(function(d) {
               results.push({
                   label: d.name,