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;
if(this.state['new-password'] != this.state['confirm-password']) {
this.props.actions.showNotification('Passwords do not match')
} else {
+ let isDisabled = {};
+ if (this.state.disabled == "TRUE") {
+ let isDisabled = {
+ disabled: [null]
+ }
+ }
this.Store.createUser({
'user-name': this.state['user-name'],
'user-domain': this.state['user-domain'],
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) {
- self.props.actions.showNotification('Please fill in all fields.');
- return false;
- }
- 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;
}
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;
: <Input readonly={state.isReadOnly} label="Username" value={state['user-name']} onChange={this.updateInput.bind(null, 'user-name')} />
}
<Input readonly={true} label="Domain" value={state['user-domain']} onChange={this.updateInput.bind(null, 'user-domain')}></Input>
+ <Input
+ type="radiogroup"
+ onChange={this.disableChange}
+ label="Disabled"
+ value={this.state.disabled}
+ options={["TRUE","FALSE"]}
+ readonly={state.isReadOnly} />
</FormSection>
<FormSection title="PLATFORM ROLES" style={{display:'none'}}>
<Input label="Super Admin" onChange={this.platformChange.bind(null, 'super_admin')} checked={state.platformRoles.super_admin} type="checkbox" />
this.users = [];
this['user-name'] = '';
this['user-domain'] = 'system';
- this.disabled = false;
+ this.disabled = "FALSE";
this.platformRoles = {
super_admin: false,
platform_admin: false,
'user-name': user['user-name'],
'user-domain': user['user-domain'],
platformRoles: user.platformRoles || this.platformRoles,
- disabled: user.disabled || this.disabled,
- projectRoles: user.projectRoles || this.projectRoles
+ disabled: user.hasOwnProperty('disabled').toString().toUpperCase(),
+ projectRoles: user.projectRoles || this.projectRoles,
+ currentPassword: user.password
}
let state = _.merge({
activeIndex: userIndex,
}
handleCreateUser() {
+ }
+ handleDisabledChange(value) {
+ this.disabled = value;
}
handleUpdateUser() {