User management and project management build scripts updated
authorLaurence Maultsby <laurence.maultsby@riftio.com>
Tue, 21 Mar 2017 01:08:44 +0000 (21:08 -0400)
committerLaurence Maultsby <laurence.maultsby@riftio.com>
Tue, 21 Mar 2017 01:08:44 +0000 (21:08 -0400)
Signed-off-by: Laurence Maultsby <laurence.maultsby@riftio.com>
skyquake/framework/widgets/form_controls/selectOption.jsx
skyquake/framework/widgets/skyquake_container/skyquakeContainer.jsx
skyquake/plugins/project_management/src/dashboard/dashboard.jsx
skyquake/plugins/project_management/src/dashboard/projectMgmtStore.js
skyquake/plugins/user_management/config.json

index 21d4a0a..1e02f15 100644 (file)
@@ -53,6 +53,7 @@ export default class SelectOption extends React.Component {
                   <select
                     className={this.props.className}
                     onChange={this.handleOnChange}
+                    value={JSON.stringify(this.props.value)}
                     defaultValue={JSON.stringify(defaultValue)}>
                       {
                        options
index 7a0418e..558cc62 100644 (file)
@@ -113,7 +113,7 @@ export default class skyquakeContainer extends React.Component {
                             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}
index 60e06df..cabad1e 100644 (file)
@@ -95,16 +95,16 @@ class ProjectManagementDashboard extends React.Component {
         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);
             }
            })
         })
@@ -121,16 +121,17 @@ class ProjectManagementDashboard extends React.Component {
         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);
             }
            })
         })
@@ -139,7 +140,7 @@ class ProjectManagementDashboard extends React.Component {
             'name': self.state['name'],
             'description': self.state.description,
             'project-config' : {
-                'user': projectUsers
+                'user': cleanUsers
             }
         }));
     }
@@ -160,7 +161,9 @@ class ProjectManagementDashboard extends React.Component {
         })
     }
     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);
@@ -217,6 +220,14 @@ class ProjectManagementDashboard extends React.Component {
         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 = (
@@ -312,7 +323,7 @@ class ProjectManagementDashboard extends React.Component {
                                     <tr key={i}>
                                         {!state.isReadOnly ? <td><span
                                                                     className="removeInput"
-                                                                    onClick={self.removeUserFromProject.bind(self, u)}
+                                                                    onClick={self.removeUserFromProject.bind(self, i)}
                                                                 >
                                                                     <img src={imgRemove} />
 
@@ -409,16 +420,10 @@ class ProjectManagementDashboard extends React.Component {
                                             <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
index 6ad46be..857e9a7 100644 (file)
@@ -15,7 +15,7 @@ export default class ProjectManagementStore {
         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 = [];
@@ -146,35 +146,37 @@ export default class ProjectManagementStore {
             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});
@@ -183,8 +185,9 @@ export default class ProjectManagementStore {
     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) {
@@ -192,10 +195,11 @@ export default class ProjectManagementStore {
         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
@@ -227,10 +231,14 @@ export default class ProjectManagementStore {
     }
     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,
index 930b9cf..0e66f6f 100644 (file)
         "route": "user-management",
         "component": "./dashboard/dashboard.jsx",
         "type": "internal"
+    },{
+        "label": "Platform Role Management",
+        "route": "platform",
+        "component": "./platformRoleManagement/platformRoleManagement.jsx",
+        "type": "internal"
     }]
 }