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
}
}
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]) {
}
});
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;
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,
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});