Created an env var for disabling sockets
authorLaurence Maultsby <laurence.maultsby@riftio.com>
Fri, 28 Apr 2017 19:09:27 +0000 (15:09 -0400)
committerLaurence Maultsby <laurence.maultsby@riftio.com>
Fri, 28 Apr 2017 19:09:27 +0000 (15:09 -0400)
Signed-off-by: Laurence Maultsby <laurence.maultsby@riftio.com>
skyquake/framework/core/api_utils/sockets.js
skyquake/framework/core/modules/api/userManagementAPI.js
skyquake/framework/utils/roleConstants.js
skyquake/plugins/project_management/src/dashboard/dashboard.jsx
skyquake/plugins/project_management/src/dashboard/projectMgmtStore.js

index e2e4447..e8ae2eb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 
+ *
  *   Copyright 2016 RIFT.IO Inc
  *
  *   Licensed under the Apache License, Version 2.0 (the "License");
@@ -295,7 +295,11 @@ function PollingSocket(url, req, interval, config) {
         console.log('Error polling: ' + url);
       } else {
         if (!self.isClosed) {
-          self.poll = setTimeout(pollServer, 1000 || interval);
+          if(process.env.DISABLE_POLLING != "TRUE") {
+            self.poll = setTimeout(pollServer, 1000 || interval);
+          } else {
+            console.log('Polling is disabled. Finishing request.')
+          }
           var data = response.body;
           if (self.onmessage) {
             self.onmessage(data);
index b2f55c3..c05c2b3 100644 (file)
@@ -141,6 +141,9 @@ UserManagement.getUserInfo = function(req, userId, domain) {
                             u.role && u.role.map(function(r) {
                                 userData.project[p.name].role[r.role] = true
                             });
+                            u["rw-project-mano:mano-role"] && u["rw-project-mano:mano-role"] .map(function(r) {
+                                userData.project[p.name].role[r.role] = true
+                            });
                         }
                     })
                 });
index e04c43e..5ac4e64 100644 (file)
@@ -7,6 +7,16 @@ c.PLATFORM = {
 }
 
 c.PROJECT = {
+    TYPE: {
+      "rw-project-mano:catalog-oper": "rw-project-mano",
+      "rw-project-mano:catalog-admin": "rw-project-mano",
+      "rw-project-mano:lcm-oper": "rw-project-mano",
+      "rw-project-mano:lcm-admin": "rw-project-mano",
+      "rw-project-mano:account-oper": "rw-project-mano",
+      "rw-project-mano:account-admin": "rw-project-mano",
+      "rw-project:project-oper": "rw-project",
+      "rw-project:project-admin": "rw-project"
+    },
     CATALOG_OPER: "rw-project-mano:catalog-oper",
     CATALOG_ADMIN: "rw-project-mano:catalog-admin",
     LCM_OPER: "rw-project-mano:lcm-oper",
@@ -15,6 +25,7 @@ c.PROJECT = {
     ACCOUNT_ADMIN: "rw-project-mano:account-admin",
     PROJECT_OPER: "rw-project:project-oper",
     PROJECT_ADMIN: "rw-project:project-admin"
+
 }
 
 module.exports = c;
index 02b9384..843301d 100644 (file)
@@ -136,17 +136,21 @@ class ProjectManagementDashboard extends React.Component {
         //Remove null values from role
         projectUsers.map((u) => {
             let cleanRoles = [];
+            let cleanManoRoles = [];
            u.role && u.role.map((r,i) => {
              let role = {};
              //you may add a user without a role or a keys, but if one is present then the other must be as well.
-            if(!r.role ) {
-            } else {
+            if(r.role ) {
                 delete r.keys;
-                    // r.keys = projectName;
-                    cleanRoles.push(r)
+                // r.keys = projectName;
+                switch(ROLES.PROJECT.TYPE[r.role]) {
+                    case 'rw-project-mano' : cleanManoRoles.push(r); break;
+                    case 'rw-project' : cleanRoles.push(r); break;
+                }
             }
            });
            u.role = cleanRoles;
+           u["rw-project-mano:mano-role"] = cleanManoRoles
            cleanUsers.push(u);
         });
         return cleanUsers;
@@ -175,13 +179,6 @@ class ProjectManagementDashboard extends React.Component {
     removeUserFromProject = (userIndex, e) => {
         this.actions.handleRemoveUserFromProject(userIndex);
     }
-    updateUserRoleInProject = (userIndex, roleIndex, e) => {
-        this.actions.handleUpdateUserRoleInProject({
-            userIndex,
-            roleIndex,
-            value: JSON.parse(e.target.value)
-        })
-    }
     toggleUserRoleInProject = (userIndex, roleIndex, e) => {
         this.actions.handleToggleUserRoleInProject({
             userIndex,
index b3e55ad..70f5f2f 100644 (file)
@@ -16,7 +16,9 @@ export default class ProjectManagementStore {
         this.projectUsers = [];
         this.selectedUser = null;
         this.selectedRole = null;
-        this.roles = Object.keys(ROLES.PROJECT).map((p) => {
+        this.roles = Object.keys(ROLES.PROJECT).filter((p) => {
+            return p != "TYPE";
+        }).map((p) => {
             return ROLES.PROJECT[p];
         })
         // this.roles = ['rw-project:project-admin', 'rw-project:project-oper', 'rw-project:project-create'];
@@ -172,9 +174,26 @@ export default class ProjectManagementStore {
         let projectUsers = this.projectUsers;
         let selectedRole = self.roles[roleIndex];
         if(checked) {
-            if(!projectUsers[userIndex].role) projectUsers[userIndex].role = [];
+            if (!projectUsers[userIndex].role) {
+                projectUsers[userIndex].role = [];
+            }
+            if (!projectUsers[userIndex]['rw-project-mano:mano-role']) {
+                projectUsers[userIndex]['rw-project-mano:mano-role'] = [];
+            }
+            switch (ROLES.PROJECT.TYPE[self.roles[roleIndex]]) {
+                case 'rw-project' :
+                    projectUsers[userIndex].role.push({
+                        role: selectedRole
+                    });
+                    break;
+                case 'rw-project-mano' :
+                    projectUsers[userIndex]["rw-project-mano:mano-role"].push({
+                        role: selectedRole
+                    });
+                    break;
+            }
             projectUsers[userIndex].role.push({
-                role: self.roles[roleIndex]
+                role: selectedRole
             })
         } else {
             let role = projectUsers[userIndex].role;