/* * 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 React from 'react' import {RaisedButton} from 'material-ui' import Workspace from '../model/Workspace' export default React.createClass({ mixins:[AdminComponents.MessagesConsumerMixin], propTypes:{ onSelectionChange:React.PropTypes.func.isRequired, driverLabel:React.PropTypes.string, driverDescription:React.PropTypes.string, currentSelection:React.PropTypes.string, wizardType:React.PropTypes.string, driversLoaded:React.PropTypes.bool, additionalComponents:React.PropTypes.object, disableCreateButton:React.PropTypes.bool }, getInitialState:function(){ return { edit:this.props.wizardType == 'workspace'?'template':'general', step:1, subStep1:'template' }; }, componentWillReceiveProps:function(newProps){ if(newProps.currentSelection){ this.setState({edit:newProps.currentSelection}); } }, setEditState:function(key){ this.props.onSelectionChange(key); this.setState({edit:key}); }, closeCurrent:function(event){ event.stopPropagation(); }, dropDownChange: function(item){ if(item.payload.name){ this.setState({step:3}); } this.setState({edit:'driver', selectedDriver:item.payload.name}); this.props.onSelectionChange('driver', item.payload.name); }, dropChangeDriverOrTemplate:function(event, item){ if(item == 'template'){ this.setState({step:1,subStep1:item}); }else{ this.setState({step:2, subStep1:'driver'}); this.setEditState('general'); } }, dropDownChangeTpl: function(item){ if(item.payload != -1){ var tpl = item.payload == "0" ? "0" : item.payload.name; this.setState({ edit:'general', selectedTemplate:tpl == "0"? null: tpl, step:2 }); this.props.onSelectionChange('general', null, tpl); } }, render: function(){ var step1, step2, step3; if(this.props.wizardType == 'workspace'){ // TEMPLATES SELECTOR var driverOrTemplate = (
); var templateSelector = null; if(this.state.step == 1 && this.state.subStep1 == "template"){ templateSelector = ( ); } step1 = (
{driverOrTemplate} {templateSelector}
); } // DRIVER SELECTOR STEP if(this.state.step > 1 || this.props.wizardType == 'template'){ if(this.props.wizardType == 'workspace' && this.state.selectedTemplate){ // Display remaining template options instead of generic + driver var tplLabel = Workspace.TEMPLATES.get(this.state.selectedTemplate).label; step2 = (
); }else{ step2 =
; } } // SAVE / CANCEL BUTTONS if(this.state.step > 2 || (this.state.step > 1 && this.props.wizardType == 'workspace' && this.state.selectedTemplate) ){ var stepNumber = 4; if(this.state.selectedTemplate) stepNumber = 3; step3 =
   
; }else{ step3 =
; } return (
{step1} {step2} {this.props.additionalComponents} {step3}
); } });