Project page rw-mano fix
authorLaurence Maultsby <laurence.maultsby@riftio.com>
Tue, 2 May 2017 16:22:44 +0000 (12:22 -0400)
committerLaurence Maultsby <laurence.maultsby@riftio.com>
Tue, 2 May 2017 16:22:44 +0000 (12:22 -0400)
Signed-off-by: Laurence Maultsby <laurence.maultsby@riftio.com>
skyquake/framework/widgets/skyquake_rbac/skyquakeRBAC.jsx
skyquake/plugins/project_management/src/dashboard/dashboard.jsx
skyquake/plugins/project_management/src/dashboard/projectMgmtStore.js

index 0245e23..c1d3b01 100644 (file)
@@ -65,7 +65,7 @@ SkyquakeRBAC.contextTypes = {
 function checkForRoleAccess(project, PlatformRole, allow) {
     if (allow.indexOf('*') > -1) return true;
     for (let i = 0; i<allow.length; i++) {
-      if((project && project.role[allow[i]] )|| PlatformRole[allow[i]]) {
+      if((project && project.role[allow[i]])|| PlatformRole[allow[i]]) {
         return true
       }
     }
index f8018d5..8ddc365 100644 (file)
@@ -140,7 +140,7 @@ class ProjectManagementDashboard extends React.Component {
            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 ) {
+            if(r.role) {
                 delete r.keys;
                 // r.keys = projectName;
                 switch(ROLES.PROJECT.TYPE[r.role]) {
@@ -150,7 +150,8 @@ class ProjectManagementDashboard extends React.Component {
             }
            });
            u.role = cleanRoles;
-           u["rw-project-mano:mano-role"] = cleanManoRoles
+           u["rw-project-mano:mano-role"] = u["rw-project-mano:mano-role"] || [];
+           u["rw-project-mano:mano-role"] = u["rw-project-mano:mano-role"].concat(cleanManoRoles);
            cleanUsers.push(u);
         });
         return cleanUsers;
index 0c14dd9..e112bb6 100644 (file)
@@ -69,7 +69,7 @@ export default class ProjectManagementStore {
         let ProjectData = {
             'name': project['name'],
             'description': project['description'],
-            'projectUsers': project['project-config'] && project['project-config']['user'] || []
+            'projectUsers': (project['project-config'] && project['project-config']['user'] || [])
         }
         let state = _.merge({
             activeIndex: projectIndex,
@@ -173,17 +173,19 @@ export default class ProjectManagementStore {
         let {userIndex, roleIndex, checked} = data;
         let projectUsers = this.projectUsers;
         let selectedRole = self.roles[roleIndex];
+        let roleType = (ROLES.PROJECT.TYPE[selectedRole] == 'rw-project-mano') ? "rw-project-mano:mano-role" : "role";
+        //
         if(checked) {
-            if (!projectUsers[userIndex].role) {
-                projectUsers[userIndex].role = [];
+            if (!projectUsers[userIndex][roleType]) {
+                projectUsers[userIndex][roleType] = [];
             }
-            projectUsers[userIndex].role.push({
+            projectUsers[userIndex][roleType].push({
                 role: self.roles[roleIndex]
             })
         } else {
-            let role = projectUsers[userIndex].role;
+            let role = projectUsers[userIndex][roleType];
             let roleIndex = _.findIndex(role, {role:selectedRole})
-            projectUsers[userIndex].role.splice(roleIndex, 1)
+            projectUsers[userIndex][roleType].splice(roleIndex, 1)
         }
        self.setState({projectUsers});