/* * 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 . */ const React = require('react') const {Toggle, Divider, TextField, RaisedButton} = require('material-ui') const {ClipboardTextField} = require('pydio').requireLib('components') let WebDAVPane = React.createClass({ componentDidMount: function(){ this.loadPrefs(); }, getMessage: function(id){ return this.props.pydio.MessageHash[id]; }, onToggleChange: function(event, newValue){ PydioApi.getClient().request({ get_action : 'webdav_preferences', activate : newValue ? "true":"false" }, function(t){ this.setState({preferences: t.responseJSON}); this.props.pydio.displayMessage("SUCCESS", this.props.pydio.MessageHash[newValue?408:409]); }.bind(this)); }, savePassword: function(event){ PydioApi.getClient().request({ get_action : 'webdav_preferences', webdav_pass: this.refs['passfield'].getValue() }, function(t){ this.setState({preferences: t.responseJSON}); this.props.pydio.displayMessage("SUCCESS", this.props.pydio.MessageHash[410]); }.bind(this)); }, loadPrefs: function(){ if(!this.isMounted()) return; PydioApi.getClient().request({ get_action:'webdav_preferences' }, function(t){ this.setState({preferences: t.responseJSON}); }.bind(this)); }, renderPasswordField: function(){ if(this.state.preferences.digest_set || !this.state.preferences.webdav_force_basic){ return null; } return (
{this.getMessage(407)}
); }, renderUrls: function(){ let base = this.state.preferences.webdav_base_url; let otherUrls = []; const toggler = !!this.state.toggler; const {pydio} = this.props; const {preferences} = this.state; if(toggler){ let userRepos = pydio.user.getRepositoriesList(); let webdavRepos = preferences.webdav_repositories; userRepos.forEach(function(repo, key){ if(!webdavRepos[key]) return; otherUrls.push(); }.bind(this)); } return (
{this.getMessage(405)}
{toggler && }
{this.setState({toggler: !toggler})}} toggled={toggler}/> {otherUrls}
); }, render: function(){ let webdavActive = this.state && this.state.preferences.webdav_active; return (
{!webdavActive &&
{this.getMessage(404)}
}
{webdavActive &&
{this.renderPasswordField()} {this.renderUrls()}
}
); } }); export {WebDAVPane as default}