/* * 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 {Component} from 'react' import {Divider} from 'material-ui' import Pydio from 'pydio' import TourGuide from './TourGuide' const {PydioContextConsumer} = Pydio.requireLib('boot') const DOMUtils = require('pydio/util/dom') class Scheme extends Component { render(){ let style = { position:'relative', fontSize: 24, width: this.props.dimension || 100, height: this.props.dimension || 100, backgroundColor: '#ECEFF1', color: '#607d8b', borderRadius: '50%', margin: '0 auto' }; return (
{this.props.children}
); } } class IconScheme extends Component { constructor(props){ super(props); this.state = {icon: props.icon || props.icons[0], index: 0}; } componentDidMount(){ this.componentWillReceiveProps(this.props); } componentWillReceiveProps(nextProps){ const {icon, icons} = nextProps; if(this._interval) clearInterval(this._interval); let state; if(icon) { state = {icon: icon}; } else if(icons){ state = {icon: icons[0], index: 0}; this._interval = setInterval(()=>{ this.nextIcon(); }, 1700); } this.setState(state); } nextIcon(){ const {icons} = this.props; let next = this.state.index + 1 ; if(next > icons.length - 1 ) next = 0; this.setState({index: next, icon:icons[next]}); } componentWillUnmount(){ if(this._interval) clearInterval(this._interval); } render(){ const {icon} = this.state; return ( ); } } class CreateMenuCard extends Component{ componentDidMount(){ setTimeout(() => { this.props.pydio.notify('tutorial-open-create-menu'); }, 950); } render(){ return (

{this.props.message('create-menu')}

); } } class InfoPanelCard extends Component{ componentDidMount(){ this._int = setInterval(() => { this.setState({closed:!(this.state && this.state.closed)}); }, 1500) } componentWillUnmount(){ if(this._int) clearInterval(this._int); } render(){ let leftStyle = {width: 24, transition:DOMUtils.getBeziersTransition(), transform:'scaleX(1)', transformOrigin:'right'}; if(this.state && this.state.closed){ leftStyle = {...leftStyle, width: 0, transform:'scaleX(0)'}; } return (

{this.props.message('infopanel.1')}

{this.props.message('infopanel.folder')} 1
{this.props.message('infopanel.folder')} 2
{this.props.message('infopanel.file')} 3
{this.props.message('infopanel.file')} 4

{this.props.message('infopanel.2')} ().

); } } class UserWidgetCard extends Component{ render(){ const iconStyle = { display: 'inline-block', textAlign: 'center', fontSize: 17, lineHeight: '20px', backgroundColor: '#ECEFF1', color: '#607D8B', borderRadius: '50%', padding: '5px 6px', width: 30, height: 30, marginRight: 5 }; return (

{this.props.message('uwidget.addressbook')}

{this.props.message('uwidget.alerts')}

{this.props.message('uwidget.menu')}

{this.props.message('uwidget.home')}

); } } class WelcomeTour extends Component{ constructor(props, context){ super(props, context); this.state = {started: !(props.pydio.user && !props.pydio.user.getPreference('gui_preferences', true)['UserAccount.WelcomeModal.Shown'])}; } discard(pref='WelcomeComponent.Pydio8.TourGuide.FSTemplate'){ const {user} = this.props.pydio; let guiPrefs = user.getPreference('gui_preferences', true); guiPrefs[pref] = true; user.setPreference('gui_preferences', guiPrefs, true); user.savePreference('gui_preferences'); } componentDidMount(){ if(!this.state.started){ pydio.UI.openComponentInModal('UserAccount', 'WelcomeModal', { onRequestStart:(skip) => { this.discard('UserAccount.WelcomeModal.Shown'); if(skip) this.discard(); this.setState({started: true, skip: skip}); } }); } } render(){ if(!this.state.started || this.state.skip){ return null; } const {getMessage} = this.props; const message = (id) => getMessage('ajax_gui.tour.' + id); let tourguideSteps = []; if(pydio.user && pydio.user.activeRepository && pydio.user.write){ tourguideSteps.push({ title:message('create-menu.title'), text : , selector:'#create-button-menu', position:'left', style:{width:220} }); } tourguideSteps = tourguideSteps.concat([ { title:message('display-bar.title'), text :

{message('display-bar')}

, selector:'#display-toolbar', position:'left' }, { title:message('infopanel.title'), text : , selector:'#info_panel', position:'left' }, { title:message('uwidget.title'), text : , selector:'.user-widget', position:'right', style:{width: 320} } ]); const callback = (data) => { if(data.type === 'step:after' && data.index === tourguideSteps.length - 1 ){ this.discard(); } }; return ( ); } } WelcomeTour = PydioContextConsumer(WelcomeTour) export {WelcomeTour as default}