From: Laurence Maultsby Date: Tue, 21 Mar 2017 18:56:10 +0000 (-0400) Subject: Project management bug fixes. Platform Role assignment init X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=de8cda680ce17b1555789bf2f4d3145c0d4d4849;p=osm%2FUI.git Project management bug fixes. Platform Role assignment init Signed-off-by: Laurence Maultsby --- diff --git a/skyquake/plugins/project_management/src/dashboard/dashboard.jsx b/skyquake/plugins/project_management/src/dashboard/dashboard.jsx index cabad1e3d..4cbb1ef83 100644 --- a/skyquake/plugins/project_management/src/dashboard/dashboard.jsx +++ b/skyquake/plugins/project_management/src/dashboard/dashboard.jsx @@ -95,24 +95,13 @@ 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); - } else { - cleanUsers.push(u); - } - }) - }) + let cleanUsers = this.cleanUsers(projectUsers); + this.Store.createProject({ 'name': self.state['name'], 'description': self.state.description, 'project-config' : { - 'user': projectUsers + 'user': cleanUsers } }); } @@ -121,20 +110,7 @@ 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); - } else { - cleanUsers.push(u); - } - }) - }) + let cleanUsers = this.cleanUsers(projectUsers); this.Store.updateProject(_.merge({ 'name': self.state['name'], @@ -143,6 +119,24 @@ class ProjectManagementDashboard extends React.Component { 'user': cleanUsers } })); + } + cleanUsers(projectUsers) { + let cleanUsers = []; + //Remove null values from role + projectUsers.map((u) => { + let cleanRoles = []; + 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 || ( !r || ((r.role || r['keys']) && (!r.role || !r['keys'])))) { + } else { + cleanRoles.push(r) + } + }); + u.role = cleanRoles; + cleanUsers.push(u); + }); + return cleanUsers; } evaluateSubmit = (e) => { if (e.keyCode == 13) { @@ -299,7 +293,7 @@ class ProjectManagementDashboard extends React.Component { } - + @@ -333,7 +327,7 @@ class ProjectManagementDashboard extends React.Component { { state.roles.map((r,j) => { - return + return }) } @@ -343,76 +337,6 @@ class ProjectManagementDashboard extends React.Component {
-1)} /> -1)} checked={(userRoles.indexOf(r) > -1)} />
- - { false ? -
-
-
- User Name -
-
- Role -
-
- { - state.projectUsers && state.projectUsers.map((u, k) => { - return ( -
this[`project-ref-${k}`] = el} className={`tableRow tableRow--data projectUsers`} key={k}> -
{u['user-name']}
-
- { - u.role && u.role.map((r, l) => { - return ( -
-
- - {!state.isReadOnly ? - - - Remove Role - - : null - } - -
-
- ) - }) - } - {!state.isReadOnly ? -
- - Add Role - - { - (!(u.role && u.role.length)) ? - - - Remove User - : null - } -
- : null - } -
-
- ) - }) - } -
- : null - } { !state.isReadOnly ?
diff --git a/skyquake/plugins/project_management/src/dashboard/projectMgmt.scss b/skyquake/plugins/project_management/src/dashboard/projectMgmt.scss index dc8fcce60..0d76a291e 100644 --- a/skyquake/plugins/project_management/src/dashboard/projectMgmt.scss +++ b/skyquake/plugins/project_management/src/dashboard/projectMgmt.scss @@ -133,6 +133,7 @@ } table { + font-size: 0.8rem; thead { border-bottom:1px solid #d3d3d3; td{ @@ -148,6 +149,12 @@ } } } + .userTable { + .FormSection-body { + max-width: 652px; + overflow-x: scroll; + } + } } diff --git a/skyquake/plugins/project_management/src/dashboard/projectMgmtStore.js b/skyquake/plugins/project_management/src/dashboard/projectMgmtStore.js index 857e9a748..d7d76b859 100644 --- a/skyquake/plugins/project_management/src/dashboard/projectMgmtStore.js +++ b/skyquake/plugins/project_management/src/dashboard/projectMgmtStore.js @@ -15,8 +15,8 @@ export default class ProjectManagementStore { this.projectUsers = []; this.selectedUser = null; this.selectedRole = null; - this.roles = ['rw-rbac-platform:super-admin', 'operator_role' - // 'some_other_role', 'yet_another_role', 'operator_role', 'some_other_role', 'yet_another_role' + this.roles = ['rw-rbac-platform:platform-admin', 'rw-rbac-platform:platform-oper', 'rw-rbac-platform:super-admin' + // ,'some_other_role', 'yet_another_role', 'operator_role', 'some_other_role', 'yet_another_role' ]; this.users = []; this.activeIndex = null; diff --git a/skyquake/plugins/user_management/src/platformRoleManagement/platformRoleManagement.jsx b/skyquake/plugins/user_management/src/platformRoleManagement/platformRoleManagement.jsx new file mode 100644 index 000000000..49efb8217 --- /dev/null +++ b/skyquake/plugins/user_management/src/platformRoleManagement/platformRoleManagement.jsx @@ -0,0 +1,436 @@ +/* + * STANDARD_RIFT_IO_COPYRIGHT + */ + +import React from 'react'; +import ReactDOM from 'react-dom'; +import AppHeader from 'widgets/header/header.jsx'; +import ProjectManagementStore from './platformRoleManagementStore.js'; +import SkyquakeComponent from 'widgets/skyquake_container/skyquakeComponent.jsx'; +import 'style/layout.scss'; +import './platformRoleManagement.scss'; +import {Panel, PanelWrapper} from 'widgets/panel/panel'; +import {InputCollection, FormSection} from 'widgets/form_controls/formControls.jsx'; + +import TextInput from 'widgets/form_controls/textInput.jsx'; +import Input from 'widgets/form_controls/input.jsx'; +import Button, {ButtonGroup} from 'widgets/button/sq-button.jsx'; +import SelectOption from 'widgets/form_controls/selectOption.jsx'; +import 'widgets/form_controls/formControls.scss'; +import imgAdd from '../../node_modules/open-iconic/svg/plus.svg' +import imgRemove from '../../node_modules/open-iconic/svg/trash.svg' + +class PlatformRoleManagement extends React.Component { + constructor(props) { + super(props); + this.Store = this.props.flux.stores.hasOwnProperty('ProjectManagementStore') ? this.props.flux.stores.ProjectManagementStore : this.props.flux.createStore(ProjectManagementStore); + this.Store.getProjects(); + this.Store.getUsers(); + this.state = this.Store.getState(); + this.actions = this.state.actions; + } + componentDidUpdate() { + let self = this; + ReactDOM.findDOMNode(this.projectList).addEventListener('transitionend', this.onTransitionEnd, false); + } + componentWillMount() { + this.Store.listen(this.updateState); + } + componentWillUnmount() { + this.Store.unlisten(this.updateState); + } + updateState = (state) => { + this.setState(state); + } + updateInput = (key, e) => { + let property = key; + this.actions.handleUpdateInput({ + [property]:e.target.value + }) + } + disabledChange = (e) => { + this.actions.handleDisabledChange(e.target.checked); + } + 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); + } + cancelEditProject = () => { + this.actions.editProject(true) + } + closePanel = () => { + this.actions.handleCloseProjectPanel(); + } + + deleteProject = (e) => { + e.preventDefault(); + e.stopPropagation(); + this.Store.deleteProject({ + 'name': this.state['name'] + }); + } + createProject = (e) => { + let self = this; + e.preventDefault(); + e.stopPropagation(); + let projectUsers = self.state.projectUsers; + let selectedUsers = []; + //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); + } else { + return u; + } + }) + }) + this.Store.createProject({ + 'name': self.state['name'], + 'description': self.state.description, + 'project-config' : { + 'user': projectUsers + } + }); + } + updateProject = (e) => { + let self = this; + e.preventDefault(); + e.stopPropagation(); + let projectUsers = self.state.projectUsers; + + //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); + } else { + return u; + } + }) + }) + + this.Store.updateProject(_.merge({ + 'name': self.state['name'], + 'description': self.state.description, + 'project-config' : { + 'user': projectUsers + } + })); + } + evaluateSubmit = (e) => { + if (e.keyCode == 13) { + if (this.props.isEdit) { + this.updateProject(e); + } else { + this.createProject(e); + } + e.preventDefault(); + e.stopPropagation(); + } + } + updateSelectedUser = (e) => { + this.setState({ + selected + }) + } + addUserToProject = (e) => { + this.actions.handleAddUser(); + } + removeUserFromProject = (userIndex, e) => { + this.actions.handleRemoveUserFromProject(userIndex); + } + updateUserRoleInProject = (userIndex, roleIndex, e) => { + this.actions.handleUpdateUserRoleInProject({ + userIndex, + roleIndex, + value: JSON.parse(e.target.value) + }) + } + toggleUserRoleInProject = (userIndex, roleIndex, e) => { + this.actions.handleToggleUserRoleInProject({ + userIndex, + roleIndex, + checked: JSON.parse(e.currentTarget.checked) + }) + } + removeRoleFromUserInProject = (userIndex, roleIndex, e) => { + this.actions.handleRemoveRoleFromUserInProject({ + userIndex, + roleIndex + }) + } + addRoleToUserInProject = (userIndex, e) => { + this.actions.addRoleToUserInProject(userIndex); + } + onTransitionEnd = (e) => { + this.actions.handleHideColumns(e); + console.log('transition end') + } + disableChange = (e) => { + let value = e.target.value; + value = value.toUpperCase(); + if (value=="TRUE") { + value = true; + } else { + value = false; + } + console.log(value) + } + render() { + let self = this; + let html; + let props = this.props; + let state = this.state; + let passwordSectionHTML = null; + let formButtonsHTML = ( + +