cloneDeep on projectUsers to prevent data mutation
authorLaurence Maultsby <laurence.maultsby@riftio.com>
Fri, 28 Apr 2017 19:42:20 +0000 (15:42 -0400)
committerLaurence Maultsby <laurence.maultsby@riftio.com>
Fri, 28 Apr 2017 19:42:20 +0000 (15:42 -0400)
Signed-off-by: Laurence Maultsby <laurence.maultsby@riftio.com>
skyquake/plugins/project_management/src/dashboard/dashboard.jsx
skyquake/plugins/project_management/src/dashboard/projectMgmtStore.js

index 843301d..e9847e5 100644 (file)
@@ -20,7 +20,7 @@ import SelectOption from 'widgets/form_controls/selectOption.jsx';
 import 'widgets/form_controls/formControls.scss';
 import imgAdd from '../../node_modules/open-iconic/svg/plus.svg'
 import imgRemove from '../../node_modules/open-iconic/svg/trash.svg'
-
+import _  from 'lodash';
 import ROLES from 'utils/roleConstants.js';
 const PROJECT_ROLES = ROLES.PROJECT;
 const PLATFORM = ROLES.PLATFORM;
@@ -118,18 +118,18 @@ class ProjectManagementDashboard extends React.Component {
         let self = this;
         e.preventDefault();
         e.stopPropagation();
-         let projectName = self.state['name'];
-        let projectUsers = self.state.projectUsers;
+        let projectName = self.state['name'];
+        let projectUsers = _.cloneDeep(self.state.projectUsers);
         let cleanUsers = this.cleanUsers(projectUsers, projectName);
 
 
-        this.Store.updateProject(_.merge({
+        this.Store.updateProject({
             'name': projectName,
             'description': self.state.description,
             'project-config' : {
                 'user': cleanUsers
             }
-        }));
+        });
     }
     cleanUsers(projectUsers, projectName) {
         let cleanUsers = [];
index 70f5f2f..0c14dd9 100644 (file)
@@ -177,23 +177,8 @@ export default class ProjectManagementStore {
             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: selectedRole
+                role: self.roles[roleIndex]
             })
         } else {
             let role = projectUsers[userIndex].role;