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;
}
});
u.role = cleanRoles;
- cleanUsers.push(u);
+ if (u['user-name'] != self.context.userProfile.userId) {
+ cleanUsers.push(u);
+ }
});
return cleanUsers;
}
(
<ButtonGroup className="buttonGroup">
<Button label="Update" type="submit" onClick={this.updatePlatform} />
- <Button label="Delete" onClick={this.deleteProject} />
- <Button label="Cancel" onClick={this.cancelEditProject} />
+ <Button label="Cancel" onClick={this.cancelEditPlatform} />
</ButtonGroup>
)
: (
<tr key={i}>
{!state.isReadOnly ? <td><span
className="removeInput"
- onClick={self.removeUserFromProject.bind(self, u)}
+ onClick={self.removeUserFromProject.bind(self, i)}
>
<img src={imgRemove} />
}
// onClick={this.Store.update.bind(null, Account)}
PlatformRoleManagement.contextTypes = {
- router: React.PropTypes.object
+ router: React.PropTypes.object,
+ userProfile: React.PropTypes.object
};
PlatformRoleManagement.defaultProps = {