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=30ee04d0fcfaf1204314a853081d3521aae1c054;hp=a3b6a6398420a0b24e868406c7a66950202ea829;hb=bc747990c2dc8bbdb262ad81da7b6741a4000677;hpb=2da8b7a246ba17396c5bc218a0b7f1685fb8d304 diff --git a/skyquake/plugins/user_management/src/dashboard/dashboard.jsx b/skyquake/plugins/user_management/src/dashboard/dashboard.jsx index a3b6a6398..30ee04d0f 100644 --- a/skyquake/plugins/user_management/src/dashboard/dashboard.jsx +++ b/skyquake/plugins/user_management/src/dashboard/dashboard.jsx @@ -19,6 +19,7 @@ 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; @@ -81,7 +82,7 @@ class UserManagementDashboard extends React.Component { cancelEditUser = () => { this.actions.editUser(true) } - osePanel = () => { + closePanel = () => { this.actions.handleCloseUserPanel(); } // updateUser = (e) => { @@ -107,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) => { @@ -121,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; } @@ -168,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; @@ -276,6 +295,15 @@ class UserManagementDashboard extends React.Component { : } +