<select
className={this.props.className}
onChange={this.handleOnChange}
+ value={JSON.stringify(this.props.value)}
defaultValue={JSON.stringify(defaultValue)}>
{
options
currentPlugin={this.state.currentPlugin}
store={SkyquakeContainerStore} />
<div className="titleBar">
- <h1>{(this.state.nav.name ? this.state.nav.name : this.state.currentPlugin) + tag}</h1>
+ <h1>{(this.state.nav.name ? this.state.nav.name.replace('_', ' ').replace('-', ' ') : this.state.currentPlugin && this.state.currentPlugin.replace('_', ' ').replace('-', ' ')) + tag}</h1>
</div>
<div className={"application " + routeName}>
{this.props.children}
e.preventDefault();
e.stopPropagation();
let projectUsers = self.state.projectUsers;
-
+ let cleanUsers = [];
//Remove null values from role
projectUsers.map((u) => {
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 || ((r.role || r['keys']) && (!r.role || !r['keys']))) {
- projectUsers.splice(i, 1);
+ // projectUsers.splice(i, 1);
} else {
- return u;
+ cleanUsers.push(u);
}
})
})
e.preventDefault();
e.stopPropagation();
let projectUsers = self.state.projectUsers;
-
+ let cleanUsers = [];
//Remove null values from role
projectUsers.map((u) => {
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 || ((r.role || r['keys']) && (!r.role || !r['keys']))) {
if(!r || ((r.role || r['keys']) && (!r.role || !r['keys']))) {
- projectUsers.splice(i, 1);
+ // projectUsers.splice(i, 1);
} else {
- return u;
+ cleanUsers.push(u);
}
})
})
'name': self.state['name'],
'description': self.state.description,
'project-config' : {
- 'user': projectUsers
+ 'user': cleanUsers
}
}));
}
})
}
addUserToProject = (e) => {
- this.actions.handleAddUser();
+ let selectUserList = this.selectUserList;
+ console.log(ReactDOM.findDOMNode(selectUserList))
+ this.actions.handleAddUser(e);
}
removeUserFromProject = (userIndex, e) => {
this.actions.handleRemoveUserFromProject(userIndex);
self.state.projectUsers.map((u) => {
projectUsers.push(u['user-name']);
});
+ let availableUsers = state.users && state.users.filter((u) => {
+ return projectUsers.indexOf(u['user-name']) == -1
+ }).map((u) => {
+ return {
+ label: u['user-name'],
+ value: u
+ }
+ });
if(!this.state.isReadOnly) {
formButtonsHTML = (
<tr key={i}>
{!state.isReadOnly ? <td><span
className="removeInput"
- onClick={self.removeUserFromProject.bind(self, u)}
+ onClick={self.removeUserFromProject.bind(self, i)}
>
<img src={imgRemove} />
<div className="addUser">
<SelectOption
onChange={this.actions.handleSelectedUser}
- defaultValue={state.selectedUser}
+ value={state.selectedUser}
initial={true}
- options={state.users && state.users.filter((u) => {
- return projectUsers.indexOf(u['user-name']) == -1
- }).map((u) => {
- return {
- label: u['user-name'],
- value: u
- }
- })}
+ options={availableUsers}
+ ref={(el) => self.selectUserList = el}
/>
<span className="addInput" onClick={this.addUserToProject}><img src={imgAdd} />
Add User
this.projectUsers = [];
this.selectedUser = null;
this.selectedRole = null;
- this.roles = ['super_admin', 'operator_role'
+ this.roles = ['rw-rbac-platform:super-admin', 'operator_role'
// 'some_other_role', 'yet_another_role', 'operator_role', 'some_other_role', 'yet_another_role'
];
this.users = [];
selectedUser: JSON.parse(user)
});
}
- handleAddUser() {
+ handleAddUser(e) {
let u = JSON.parse(this.selectedUser);
let r = this.selectedRole;
let projectUsers = this.projectUsers;
+ let keys = ',';
console.log('adding user')
projectUsers.push({
'user-name': u['user-name'],
'user-domain': u['user-domain'],
"role":[{
"role": r,
- "keys": r
+ "keys": keys
}
]
})
- this.setState({projectUsers, selectedUser: null})
+ this.setState({projectUsers, selectedUser: JSON.stringify(null)})
}
handleToggleUserRoleInProject(data) {
let self = this;
let {userIndex, roleIndex, checked} = data;
let projectUsers = this.projectUsers;
let selectedRole = self.roles[roleIndex];
+ let keys = ',';
if(checked) {
projectUsers[userIndex].role.push({
role: self.roles[roleIndex],
- keys: self.roles[roleIndex]
+ keys: keys
})
} else {
let role = projectUsers[userIndex].role;
- let roleIndex = _.findIndex(role, {role:selectedRole, keys: selectedRole})
+ let roleIndex = _.findIndex(role, {role:selectedRole, keys: keys})
projectUsers[userIndex].role.splice(roleIndex, 1)
}
self.setState({projectUsers});
handleUpdateUserRoleInProject(data) {
let {userIndex, roleIndex, value} = data;
let projectUsers = this.projectUsers;
+ let keys = ',';
projectUsers[userIndex].role[roleIndex].role = value;
- projectUsers[userIndex].role[roleIndex]['keys'] = value;
+ projectUsers[userIndex].role[roleIndex]['keys'] = keys;
}
addRoleToUserInProject(userIndex) {
if(!projectUsers[userIndex].role) {
projectUsers[userIndex].role = [];
}
+ let keys = ',';
projectUsers[userIndex].role.push({
'role': null,
//temp until we get actual keys
- 'keys' : 'some key'
+ 'keys' : keys
});
this.setState({
projectUsers
}
updateProjectSuccess() {
this.alt.actions.global.hideScreenLoader.defer();
+ let self = this;
let projects = this.projects || [];
projects[this.activeIndex] = {
'name': this['name'],
- 'description': this['description']
+ 'description': this['description'],
+ 'project-config': {
+ 'user': self.projectUsers
+ }
}
this.setState({
projects,
"route": "user-management",
"component": "./dashboard/dashboard.jsx",
"type": "internal"
+ },{
+ "label": "Platform Role Management",
+ "route": "platform",
+ "component": "./platformRoleManagement/platformRoleManagement.jsx",
+ "type": "internal"
}]
}