From 12896bd23eeba79884245c1c29fdc568cf21a7fa Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Mon, 14 Mar 2016 08:50:46 -0400 Subject: Converting to Webpack. Stage 1. --- .../components/tutorial/tutorial_intro_screens.jsx | 241 +++++++++++++++++++++ webapp/components/tutorial/tutorial_tip.jsx | 160 ++++++++++++++ 2 files changed, 401 insertions(+) create mode 100644 webapp/components/tutorial/tutorial_intro_screens.jsx create mode 100644 webapp/components/tutorial/tutorial_tip.jsx (limited to 'webapp/components/tutorial') diff --git a/webapp/components/tutorial/tutorial_intro_screens.jsx b/webapp/components/tutorial/tutorial_intro_screens.jsx new file mode 100644 index 000000000..5db45523e --- /dev/null +++ b/webapp/components/tutorial/tutorial_intro_screens.jsx @@ -0,0 +1,241 @@ +// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import UserStore from 'stores/user_store.jsx'; +import ChannelStore from 'stores/channel_store.jsx'; +import TeamStore from 'stores/team_store.jsx'; +import PreferenceStore from 'stores/preference_store.jsx'; +import * as Utils from 'utils/utils.jsx'; +import * as AsyncClient from 'utils/async_client.jsx'; + +import Constants from 'utils/constants.jsx'; + +import {FormattedMessage, FormattedHTMLMessage} from 'react-intl'; + +const Preferences = Constants.Preferences; + +const NUM_SCREENS = 3; + +import React from 'react'; + +export default class TutorialIntroScreens extends React.Component { + constructor(props) { + super(props); + + this.handleNext = this.handleNext.bind(this); + this.createScreen = this.createScreen.bind(this); + this.createCircles = this.createCircles.bind(this); + + this.state = {currentScreen: 0}; + } + handleNext() { + if (this.state.currentScreen < 2) { + this.setState({currentScreen: this.state.currentScreen + 1}); + return; + } + + Utils.switchChannel(ChannelStore.getByName(Constants.DEFAULT_CHANNEL)); + + let preference = PreferenceStore.getPreference(Preferences.TUTORIAL_STEP, UserStore.getCurrentId(), {value: '0'}); + + const newValue = (parseInt(preference.value, 10) + 1).toString(); + + preference = PreferenceStore.setPreference(Preferences.TUTORIAL_STEP, UserStore.getCurrentId(), newValue); + AsyncClient.savePreferences([preference]); + } + skipTutorial(e) { + e.preventDefault(); + const preference = PreferenceStore.setPreference(Preferences.TUTORIAL_STEP, UserStore.getCurrentId(), '999'); + AsyncClient.savePreferences([preference]); + } + createScreen() { + switch (this.state.currentScreen) { + case 0: + return this.createScreenOne(); + case 1: + return this.createScreenTwo(); + case 2: + return this.createScreenThree(); + } + return null; + } + createScreenOne() { + const circles = this.createCircles(); + + return ( +
+ + {circles} +
+ ); + } + createScreenTwo() { + const circles = this.createCircles(); + + return ( +
+ + {circles} +
+ ); + } + createScreenThree() { + const team = TeamStore.getCurrent(); + let inviteModalLink; + if (team.type === Constants.INVITE_TEAM) { + inviteModalLink = ( + + + + ); + } else { + inviteModalLink = ( + + + ); + } + + const circles = this.createCircles(); + + let supportInfo = null; + if (global.window.mm_config.SupportEmail) { + supportInfo = ( +

+ + + {global.window.mm_config.SupportEmail} + + {'.'} +

+ ); + } + + return ( +
+

+ +

+

+ {inviteModalLink} + +

+ {supportInfo} + + {circles} +
+ ); + } + createCircles() { + const circles = []; + for (let i = 0; i < NUM_SCREENS; i++) { + let className = 'circle'; + if (i === this.state.currentScreen) { + className += ' active'; + } + + circles.push( + { //eslint-disable-line no-loop-func + e.preventDefault(); + this.setState({currentScreen: i}); + }} + /> + ); + } + + return ( +
+ {circles} +
+ ); + } + render() { + const height = Utils.windowHeight() - 100; + const screen = this.createScreen(); + + return ( +
+
+
+
+ {screen} + +
+
+
+
+ ); + } +} diff --git a/webapp/components/tutorial/tutorial_tip.jsx b/webapp/components/tutorial/tutorial_tip.jsx new file mode 100644 index 000000000..ab49d4b04 --- /dev/null +++ b/webapp/components/tutorial/tutorial_tip.jsx @@ -0,0 +1,160 @@ +// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import UserStore from 'stores/user_store.jsx'; +import PreferenceStore from 'stores/preference_store.jsx'; +import * as AsyncClient from 'utils/async_client.jsx'; + +import Constants from 'utils/constants.jsx'; + +import {FormattedMessage} from 'react-intl'; + +const Preferences = Constants.Preferences; + +import {Overlay} from 'react-bootstrap'; + +import React from 'react'; + +export default class TutorialTip extends React.Component { + constructor(props) { + super(props); + + this.handleNext = this.handleNext.bind(this); + this.toggle = this.toggle.bind(this); + + this.state = {currentScreen: 0, show: false}; + } + toggle() { + const show = !this.state.show; + this.setState({show}); + + if (!show && this.state.currentScreen >= this.props.screens.length - 1) { + let preference = PreferenceStore.getPreference(Preferences.TUTORIAL_STEP, UserStore.getCurrentId(), {value: '0'}); + + const newValue = (parseInt(preference.value, 10) + 1).toString(); + + preference = PreferenceStore.setPreference(Preferences.TUTORIAL_STEP, UserStore.getCurrentId(), newValue); + AsyncClient.savePreferences([preference]); + } + } + handleNext() { + if (this.state.currentScreen < this.props.screens.length - 1) { + this.setState({currentScreen: this.state.currentScreen + 1}); + return; + } + + this.toggle(); + } + skipTutorial(e) { + e.preventDefault(); + const preference = PreferenceStore.setPreference(Preferences.TUTORIAL_STEP, UserStore.getCurrentId(), '999'); + AsyncClient.savePreferences([preference]); + } + render() { + const buttonText = this.state.currentScreen === this.props.screens.length - 1 ? ( + + ) : ( + + ); + + const dots = []; + if (this.props.screens.length > 1) { + for (let i = 0; i < this.props.screens.length; i++) { + let className = 'circle'; + if (i === this.state.currentScreen) { + className += ' active'; + } + + dots.push( + { //eslint-disable-line no-loop-func + e.preventDefault(); + this.setState({currentScreen: i}); + }} + /> + ); + } + } + + var tipColor = ''; + if (this.props.overlayClass === 'tip-overlay--header' || this.props.overlayClass === 'tip-overlay--sidebar') { + tipColor = 'White'; + } + + return ( +
+ + + +
+ + + this.refs.target} + > + + +
+ ); + } +} + +TutorialTip.defaultProps = { + overlayClass: '' +}; + +TutorialTip.propTypes = { + screens: React.PropTypes.array.isRequired, + placement: React.PropTypes.string.isRequired, + overlayClass: React.PropTypes.string +}; -- cgit v1.2.3-1-g7c22