From a70db5e18343f33d04c86455c52be80f56457e1a Mon Sep 17 00:00:00 2001 From: Laurence Maultsby Date: Tue, 25 Apr 2017 13:00:12 -0400 Subject: [PATCH] PlatformRoleManagement: removing current user from payload, as user can not edit its own role. some function name refactoring Signed-off-by: Laurence Maultsby --- .../src/dashboard/projectMgmtStore.js | 4 +- .../platformRoleManagement.jsx | 49 +++++---------- .../platformRoleManagementActions.js | 5 +- .../platformRoleManagementSource.js | 60 +------------------ .../platformRoleManagementStore.js | 41 +++++-------- 5 files changed, 35 insertions(+), 124 deletions(-) diff --git a/skyquake/plugins/project_management/src/dashboard/projectMgmtStore.js b/skyquake/plugins/project_management/src/dashboard/projectMgmtStore.js index f0a8eebf0..b3e55ad6c 100644 --- a/skyquake/plugins/project_management/src/dashboard/projectMgmtStore.js +++ b/skyquake/plugins/project_management/src/dashboard/projectMgmtStore.js @@ -79,9 +79,7 @@ export default class ProjectManagementStore { } editProject(isReadOnly) { this.viewProject([this.projects[this.activeIndex], this.activeIndex, isReadOnly]); - // this.setState({ - // isReadOnly: isEdit - // }) + } handleCloseProjectPanel() { this.setState({ diff --git a/skyquake/plugins/user_management/src/platformRoleManagement/platformRoleManagement.jsx b/skyquake/plugins/user_management/src/platformRoleManagement/platformRoleManagement.jsx index de5064bef..216bea81d 100644 --- a/skyquake/plugins/user_management/src/platformRoleManagement/platformRoleManagement.jsx +++ b/skyquake/plugins/user_management/src/platformRoleManagement/platformRoleManagement.jsx @@ -53,58 +53,35 @@ class PlatformRoleManagement extends React.Component { platformChange = (platformRole, e) => { this.actions.handlePlatformRoleUpdate(platformRole, e.currentTarget.checked); } - addProjectRole = (e) => { - this.actions.handleAddProjectItem(); - } - removeProjectRole = (i, e) => { - this.actions.handleRemoveProjectItem(i); - } - updateProjectRole = (i, e) => { - this.actions.handleUpdateProjectRole(i, e) - } - addProject = () => { - this.actions.handleAddProject(); - } - viewProject = (un, index) => { - this.actions.viewProject(un, index); - } editProject = () => { - this.actions.editProject(false); + this.actions.editPlatform(false); } - cancelEditProject = () => { - this.actions.editProject(true) + cancelEditPlatform = () => { + this.actions.editPlatform(true) } closePanel = () => { this.actions.handleCloseProjectPanel(); } - - deleteProject = (e) => { - e.preventDefault(); - e.stopPropagation(); - this.Store.deleteProject({ - 'name': this.state['name'] - }); - } updatePlatform = (e) => { let self = this; e.preventDefault(); e.stopPropagation(); let platformUsers = self.state.platformUsers; let cleanUsers = this.cleanUsers(platformUsers); - - this.Store.updatePlatform({ - 'user': JSON.stringify(platformUsers) + 'user': JSON.stringify(cleanUsers) } ); } - cleanUsers(projectUsers) { + cleanUsers(platformUsers) { + let self = this; let cleanUsers = []; //Remove null values from role - projectUsers.map((u) => { + platformUsers.map((u) => { let cleanRoles = []; u.role && u.role.map((r,i) => { let role = {}; + //Platform user can not change role of itself. if(r.role){ //removing key for rbac-platform delete r.keys; @@ -112,7 +89,9 @@ class PlatformRoleManagement extends React.Component { } }); u.role = cleanRoles; - cleanUsers.push(u); + if (u['user-name'] != self.context.userProfile.userId) { + cleanUsers.push(u); + } }); return cleanUsers; } @@ -195,8 +174,7 @@ class PlatformRoleManagement extends React.Component { (