const React = require('react'); const {TextField, IconButton, Paper} = require('material-ui') import ShareContextConsumer from '../ShareContextConsumer' import RemoteUserEntry from './RemoteUserEntry' import Card from '../main/Card' const Pydio = require('pydio') const {ReactModelShare} = Pydio.requireLib('ReactModelShare') const {AddressBook} = Pydio.requireLib('components') import ActionButton from '../main/ActionButton' let RemoteUsers = React.createClass({ propTypes:{ shareModel: React.PropTypes.instanceOf(ReactModelShare), onUserUpdate:React.PropTypes.func.isRequired, pydio: React.PropTypes.instanceOf(Pydio) }, getInitialState: function(){ return {addDisabled: true, showUserForm: false}; }, addUser:function(){ const h = this.refs["host"].getValue(); const u = this.refs["user"].getValue(); this.props.shareModel.createRemoteLink(h, u); }, removeUser: function(linkId){ this.props.shareModel.removeRemoteLink(linkId); }, monitorInput:function(){ const h = this.refs["host"].getValue(); const u = this.refs["user"].getValue(); this.setState({addDisabled:!(h && u)}); }, onAddressBookItemSelected: function(uObject, parent){ const {trustedServerId} = uObject; const userId = uObject.getId(); this.props.shareModel.createRemoteLink('trusted://' + trustedServerId, userId); }, getActions: function () { const ocsRemotes = this.props.pydio.getPluginConfigs('core.ocs').get('TRUSTED_SERVERS'); const hasTrusted = ocsRemotes && ocsRemotes.length; return [ {this.setState({showUserForm:true})}}/>, } /> ]; }, renderUserForm: function(){ if(this.props.isReadonly()){ return null; } return (
{this.setState({showUserForm: false})}}/>
); }, render: function() { var ocsLinks = this.props.shareModel.getOcsLinksByStatus(), inv, rwHeader, hasActiveOcsLink = false; inv = ocsLinks.map(function(link){ hasActiveOcsLink = (!hasActiveOcsLink && link && link.invitation && link.invitation.STATUS == 2) ? true : hasActiveOcsLink; return ( ); }.bind(this)); if(hasActiveOcsLink){ rwHeader = (
{this.props.getMessage('361', '')} {this.props.getMessage('181')}
); } return ( {!ocsLinks.length &&
{this.props.getMessage('208')}
}
{rwHeader} {inv}
{this.state.showUserForm && this.renderUserForm()}
); } }); RemoteUsers = ShareContextConsumer(RemoteUsers); export {RemoteUsers as default}