X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FUI.git;a=blobdiff_plain;f=skyquake%2Fplugins%2Fuser_management%2Fsrc%2Fdashboard%2Fdashboard.jsx;h=70386c7ac3644618122f657dbdc038a6eedb66a5;hp=0275831a602b1fe6059a6e2f94618c36499ddde8;hb=refs%2Fheads%2Fprojects;hpb=3d39b18290b9cb3e10c1a80d91ac4819e7c58474 diff --git a/skyquake/plugins/user_management/src/dashboard/dashboard.jsx b/skyquake/plugins/user_management/src/dashboard/dashboard.jsx index 0275831a6..70386c7ac 100644 --- a/skyquake/plugins/user_management/src/dashboard/dashboard.jsx +++ b/skyquake/plugins/user_management/src/dashboard/dashboard.jsx @@ -10,7 +10,7 @@ import SkyquakeComponent from 'widgets/skyquake_container/skyquakeComponent.jsx' import 'style/layout.scss'; import './userMgmt.scss'; import {Panel, PanelWrapper} from 'widgets/panel/panel'; - +import SkyquakeRBAC from 'widgets/skyquake_rbac/skyquakeRBAC.jsx'; import TextInput from 'widgets/form_controls/textInput.jsx'; import Input from 'widgets/form_controls/input.jsx'; @@ -19,6 +19,10 @@ 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'; +import {merge} from 'lodash'; + +import ROLES from 'utils/roleConstants.js'; +const PLATFORM = ROLES.PLATFORM; class UserManagementDashboard extends React.Component { constructor(props) { @@ -26,7 +30,6 @@ class UserManagementDashboard extends React.Component { this.Store = this.props.flux.stores.hasOwnProperty('UserManagementStore') ? this.props.flux.stores.UserManagementStore : this.props.flux.createStore(UserManagementStore); this.state = this.Store.getState(); this.actions = this.state.actions; - } componentDidUpdate() { let self = this; @@ -91,10 +94,13 @@ class UserManagementDashboard extends React.Component { deleteUser = (e) => { e.preventDefault(); e.stopPropagation(); - this.Store.deleteUser({ + if (confirm('Are you sure you want to delete this user?')) { + this.Store.deleteUser({ 'user-name': this.state['user-name'], 'user-domain': this.state['user-domain'] }); + } + } createUser = (e) => { e.preventDefault(); @@ -102,12 +108,18 @@ class UserManagementDashboard extends React.Component { if(this.state['new-password'] != this.state['confirm-password']) { this.props.actions.showNotification('Passwords do not match') } else { - this.Store.createUser({ - 'user-name': this.state['user-name'], - 'user-domain': this.state['user-domain'], - 'password': this.state['new-password'] - // 'confirm-password': this.state['confirm-password'] - }); + let isDisabled = {}; + if (this.state.disabled == "TRUE") { + let isDisabled = { + disabled: [null] + } + } + this.Store.createUser(_.merge({ + 'user-name': this.state['user-name'], + 'user-domain': this.state['user-domain'], + 'password': this.state['new-password'] + // 'confirm-password': this.state['confirm-password'] + }, isDisabled)); } } updateUser = (e) => { @@ -116,18 +128,35 @@ class UserManagementDashboard extends React.Component { e.stopPropagation(); let validatedPasswords = validatePasswordFields(this.state); if(validatedPasswords) { + let isDisabled = {}; + let password = {}; + if (self.state.disabled == "TRUE") { + isDisabled = { + disabled: [null] + } + } + if (this.state['new-password'] != '') { + password = {'password': this.state['new-password']} + } else { + password = { + 'password': this.state.currentPassword + } + } this.Store.updateUser(_.merge({ 'user-name': this.state['user-name'], - 'user-domain': this.state['user-domain'], - 'password': this.state['new-password'] - })); + 'user-domain': this.state['user-domain'] + }, _.merge(isDisabled, password))); } function validatePasswordFields(state) { let oldOne = state['old-password']; let newOne = state['new-password']; let confirmOne = state['confirm-password']; if(true) { - if(oldOne == newOne) { + // if(!oldOne || !newOne) { + // self.props.actions.showNotification('Please fill in all fields.'); + // return false; + // } + if((oldOne || newOne) && (oldOne == newOne)) { self.props.actions.showNotification('Your new password must not match your old one'); return false; } @@ -163,12 +192,7 @@ class UserManagementDashboard extends React.Component { disableChange = (e) => { let value = e.target.value; value = value.toUpperCase(); - if (value=="TRUE") { - value = true; - } else { - value = false; - } - console.log(value) + this.actions.handleDisabledChange(value); } render() { let self = this; @@ -200,22 +224,24 @@ class UserManagementDashboard extends React.Component { state.isEdit ? ( -