/* * Copyright 2007-2017 Charles du Jeu - Abstrium SAS * This file is part of Pydio. * * Pydio is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Pydio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with Pydio. If not, see . * * The latest code can be found at . */ import FormMixin from '../mixins/FormMixin' const PassUtils = require('pydio/util/pass') const React = require('react') const {TextField} = require('material-ui') export default React.createClass({ mixins:[FormMixin], isValid:function(){ return this.state.valid; }, checkMinLength:function(value){ const minLength = parseInt(global.pydio.getPluginConfigs("core.auth").get("PASSWORD_MINLENGTH")); return !(value && value.length < minLength); }, getMessage:function(messageId){ if(this.context && this.context.getMessage){ return this.context.getMessage(messageId, ''); }else if(global.pydio && global.pydio.MessageHash){ return global.pydio.MessageHash[messageId]; } }, updatePassState: function(){ const prevStateValid = this.state.valid; const newState = PassUtils.getState(this.refs.pass.getValue(), this.refs.confirm ? this.refs.confirm.getValue() : ''); this.setState(newState); if(prevStateValid !== newState.valid && this.props.onValidStatusChange){ this.props.onValidStatusChange(newState.valid); } }, onPasswordChange: function(event){ this.updatePassState(); this.onChange(event, event.target.value); }, onConfirmChange:function(event){ this.setState({confirmValue:event.target.value}); this.updatePassState(); this.onChange(event, this.state.value); }, render:function(){ if(this.isDisplayGrid() && !this.state.editMode){ const value = this.state.value; return
{!value?'Empty':value}
; }else{ const overflow = {overflow:'hidden', whiteSpace:'nowrap', textOverflow:'ellipsis', width:'100%'}; let className = this.state.valid ? '' : 'mui-error-as-hint' ; if(this.props.className){ className = this.props.className + ' ' + className; } let confirm; if(this.state.value && !this.props.disabled){ confirm = [
, ]; } return(
{confirm}
); } } });