2015-10-28 15:04:17 -04:00
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
2016-03-14 08:50:46 -04:00
import UserStore from 'stores/user_store.jsx' ;
import TeamStore from 'stores/team_store.jsx' ;
import PreferenceStore from 'stores/preference_store.jsx' ;
import * as AsyncClient from 'utils/async_client.jsx' ;
2016-05-26 09:46:18 -04:00
import * as GlobalActions from 'actions/global_actions.jsx' ;
2017-02-24 17:34:21 +00:00
import { trackEvent } from 'actions/diagnostics_actions.jsx' ;
2015-10-28 15:04:17 -04:00
2016-07-22 10:53:57 -04:00
import { Constants , Preferences } from 'utils/constants.jsx' ;
2016-01-28 11:21:12 -03:00
2016-03-14 08:50:46 -04:00
import { FormattedMessage , FormattedHTMLMessage } from 'react-intl' ;
2016-06-22 10:30:01 -04:00
import { browserHistory } from 'react-router/es6' ;
2016-01-28 11:21:12 -03:00
2016-07-22 10:53:57 -04:00
import AppIcons from 'images/appIcons.png' ;
2015-10-28 15:04:17 -04:00
2015-11-05 12:20:55 -05:00
const NUM _SCREENS = 3 ;
2016-03-14 08:50:46 -04:00
import React from 'react' ;
2015-10-28 15:04:17 -04:00
export default class TutorialIntroScreens extends React . Component {
2016-04-01 09:11:27 -04:00
static get propTypes ( ) {
return {
townSquare : React . PropTypes . object ,
offTopic : React . PropTypes . object
} ;
}
2015-10-28 15:04:17 -04:00
constructor ( props ) {
super ( props ) ;
this . handleNext = this . handleNext . bind ( this ) ;
this . createScreen = this . createScreen . bind ( this ) ;
2015-11-05 12:20:55 -05:00
this . createCircles = this . createCircles . bind ( this ) ;
2017-02-24 17:34:21 +00:00
this . skipTutorial = this . skipTutorial . bind ( this ) ;
2015-10-28 15:04:17 -04:00
2015-10-30 11:35:16 -04:00
this . state = { currentScreen : 0 } ;
2015-10-28 15:04:17 -04:00
}
handleNext ( ) {
2017-02-24 17:34:21 +00:00
switch ( this . state . currentScreen ) {
case 0 :
trackEvent ( 'tutorial' , 'tutorial_screen_1_welcome_to_mattermost_next' ) ;
break ;
case 1 :
trackEvent ( 'tutorial' , 'tutorial_screen_2_how_mattermost_works_next' ) ;
break ;
case 2 :
trackEvent ( 'tutorial' , 'tutorial_screen_3_youre_all_set_next' ) ;
break ;
}
2015-10-30 11:35:16 -04:00
if ( this . state . currentScreen < 2 ) {
this . setState ( { currentScreen : this . state . currentScreen + 1 } ) ;
2015-10-28 15:04:17 -04:00
return ;
}
2016-03-24 20:04:40 -04:00
browserHistory . push ( TeamStore . getCurrentTeamUrl ( ) + '/channels/town-square' ) ;
2015-10-28 15:04:17 -04:00
2016-03-23 16:01:20 -04:00
const step = PreferenceStore . getInt ( Preferences . TUTORIAL _STEP , UserStore . getCurrentId ( ) , 0 ) ;
2015-10-30 11:35:16 -04:00
2016-03-23 13:03:12 -04:00
AsyncClient . savePreference (
Preferences . TUTORIAL _STEP ,
UserStore . getCurrentId ( ) ,
2016-03-23 16:01:20 -04:00
( step + 1 ) . toString ( )
2016-03-23 13:03:12 -04:00
) ;
2015-10-28 15:04:17 -04:00
}
2015-11-09 15:24:16 -05:00
skipTutorial ( e ) {
e . preventDefault ( ) ;
2016-03-23 13:03:12 -04:00
2017-02-24 17:34:21 +00:00
switch ( this . state . currentScreen ) {
case 0 :
trackEvent ( 'tutorial' , 'tutorial_screen_1_welcome_to_mattermost_skip' ) ;
break ;
case 1 :
trackEvent ( 'tutorial' , 'tutorial_screen_2_how_mattermost_works_skip' ) ;
break ;
case 2 :
trackEvent ( 'tutorial' , 'tutorial_screen_3_youre_all_set_skip' ) ;
break ;
}
2016-03-23 13:03:12 -04:00
AsyncClient . savePreference (
Preferences . TUTORIAL _STEP ,
UserStore . getCurrentId ( ) ,
2016-03-23 16:01:20 -04:00
'999'
2016-03-23 13:03:12 -04:00
) ;
2016-03-24 20:04:40 -04:00
browserHistory . push ( TeamStore . getCurrentTeamUrl ( ) + '/channels/town-square' ) ;
2015-11-09 15:24:16 -05:00
}
2015-10-28 15:04:17 -04:00
createScreen ( ) {
2015-10-30 11:35:16 -04:00
switch ( this . state . currentScreen ) {
2015-10-28 15:04:17 -04:00
case 0 :
return this . createScreenOne ( ) ;
case 1 :
return this . createScreenTwo ( ) ;
case 2 :
return this . createScreenThree ( ) ;
}
2016-02-22 08:31:10 -05:00
return null ;
2015-10-28 15:04:17 -04:00
}
createScreenOne ( ) {
2015-11-05 12:22:40 -05:00
const circles = this . createCircles ( ) ;
2015-11-05 12:20:55 -05:00
2015-10-28 15:04:17 -04:00
return (
< div >
2016-01-28 11:21:12 -03:00
< FormattedHTMLMessage
id = 'tutorial_intro.screenOne'
defaultMessage = ' < h3 > Welcome to : < / h3 >
< h1 > Mattermost < / h1 >
2016-08-16 10:08:11 -04:00
< p > Your team communication all in one place , instantly searchable and available anywhere . < / p >
2016-01-28 11:21:12 -03:00
< p > Keep your team connected to help them achieve what matters most . < / p > '
/ >
2015-11-05 12:20:55 -05:00
{ circles }
2015-10-28 15:04:17 -04:00
< / div >
) ;
}
createScreenTwo ( ) {
2015-11-05 12:22:40 -05:00
const circles = this . createCircles ( ) ;
2015-11-05 12:20:55 -05:00
2016-07-22 10:53:57 -04:00
let appDownloadLink = null ;
let appDownloadImage = null ;
if ( global . window . mm _config . AppDownloadLink ) {
// not using a FormattedHTMLMessage here since mm_config.AppDownloadLink is configurable and could be used
// to inject HTML if we're not careful
appDownloadLink = (
< FormattedMessage
id = 'tutorial_intro.mobileApps'
defaultMessage = 'Install the apps for {link} for easy access and notifications on the go.'
values = { {
link : (
< a
href = { global . window . mm _config . AppDownloadLink }
target = '_blank'
rel = 'noopener noreferrer'
>
< FormattedMessage
id = 'tutorial_intro.mobileAppsLinkText'
defaultMessage = 'PC, Mac, iOS and Android'
/ >
< / a >
)
} }
/ >
) ;
appDownloadImage = (
< a
href = { global . window . mm _config . AppDownloadLink }
target = '_blank'
rel = 'noopener noreferrer'
>
< img
className = 'tutorial__app-icons'
src = { AppIcons }
/ >
< / a >
) ;
}
2015-10-28 15:04:17 -04:00
return (
< div >
2016-01-28 11:21:12 -03:00
< FormattedHTMLMessage
id = 'tutorial_intro.screenTwo'
defaultMessage = ' < h3 > How Mattermost works : < / h3 >
2017-04-03 08:42:05 -04:00
< p > Communication happens in public discussion channels , private channels and direct messages . < / p >
2016-01-28 11:21:12 -03:00
< p > Everything is archived and searchable from any web - enabled desktop , laptop or phone . < / p > '
/ >
2016-07-22 10:53:57 -04:00
{ appDownloadLink }
{ appDownloadImage }
2015-11-05 12:20:55 -05:00
{ circles }
2015-10-28 15:04:17 -04:00
< / div >
) ;
}
createScreenThree ( ) {
const team = TeamStore . getCurrent ( ) ;
let inviteModalLink ;
2016-06-29 14:16:17 -04:00
let inviteText ;
2016-05-09 15:21:06 -03:00
2016-07-06 08:23:24 -04:00
if ( global . window . mm _license . IsLicensed !== 'true' || global . window . mm _config . RestrictTeamInvite === Constants . PERMISSIONS _ALL ) {
2016-06-29 14:16:17 -04:00
if ( team . type === Constants . INVITE _TEAM ) {
inviteModalLink = (
< a
className = 'intro-links'
href = '#'
onClick = { GlobalActions . showInviteMemberModal }
>
< FormattedMessage
id = 'tutorial_intro.invite'
defaultMessage = 'Invite teammates'
/ >
< / a >
) ;
} else {
inviteModalLink = (
< a
className = 'intro-links'
href = '#'
onClick = { GlobalActions . showGetTeamInviteLinkModal }
>
< FormattedMessage
id = 'tutorial_intro.teamInvite'
defaultMessage = 'Invite teammates'
/ >
< / a >
) ;
}
inviteText = (
< p >
{ inviteModalLink }
2016-01-28 11:21:12 -03:00
< FormattedMessage
2016-06-29 14:16:17 -04:00
id = 'tutorial_intro.whenReady'
defaultMessage = ' when you’ re ready.'
2016-01-28 11:21:12 -03:00
/ >
2016-06-29 14:16:17 -04:00
< / p >
2015-10-28 15:04:17 -04:00
) ;
}
2015-11-05 12:22:40 -05:00
const circles = this . createCircles ( ) ;
2015-11-05 12:20:55 -05:00
2015-12-01 11:04:24 -08:00
let supportInfo = null ;
if ( global . window . mm _config . SupportEmail ) {
supportInfo = (
2015-11-02 11:40:53 +05:00
< p >
2016-01-28 11:21:12 -03:00
< FormattedMessage
id = 'tutorial_intro.support'
defaultMessage = 'Need anything, just email us at '
/ >
2015-11-02 11:40:53 +05:00
< a
2015-12-01 11:04:24 -08:00
href = { 'mailto:' + global . window . mm _config . SupportEmail }
2015-11-02 11:40:53 +05:00
target = '_blank'
2016-05-12 07:50:53 -04:00
rel = 'noopener noreferrer'
2015-11-02 11:40:53 +05:00
>
2015-12-01 11:04:24 -08:00
{ global . window . mm _config . SupportEmail }
2015-11-02 11:40:53 +05:00
< / a >
2015-11-02 11:13:21 -05:00
{ '.' }
2015-11-02 11:40:53 +05:00
< / p >
2015-12-01 11:04:24 -08:00
) ;
}
2016-04-01 09:11:27 -04:00
let townSquareDisplayName = Constants . DEFAULT _CHANNEL _UI _NAME ;
if ( this . props . townSquare ) {
townSquareDisplayName = this . props . townSquare . display _name ;
}
2015-12-01 11:04:24 -08:00
return (
< div >
2016-01-28 11:21:12 -03:00
< h3 >
< FormattedMessage
id = 'tutorial_intro.allSet'
defaultMessage = 'You’ re all set'
/ >
< / h3 >
2016-06-29 14:16:17 -04:00
{ inviteText }
2015-12-01 11:04:24 -08:00
{ supportInfo }
2016-01-28 11:21:12 -03:00
< FormattedMessage
id = 'tutorial_intro.end'
2016-04-01 09:11:27 -04:00
defaultMessage = 'Click “Next” to enter {channel}. This is the first channel teammates see when they sign up. Use it for posting updates everyone needs to know.'
values = { {
channel : townSquareDisplayName
} }
2016-01-28 11:21:12 -03:00
/ >
2015-11-05 12:20:55 -05:00
{ circles }
< / div >
) ;
}
2015-11-05 12:22:40 -05:00
createCircles ( ) {
2015-11-05 12:20:55 -05:00
const circles = [ ] ;
for ( let i = 0 ; i < NUM _SCREENS ; i ++ ) {
let className = 'circle' ;
2015-11-05 12:22:40 -05:00
if ( i === this . state . currentScreen ) {
2015-11-05 12:20:55 -05:00
className += ' active' ;
}
circles . push (
< a
href = '#'
key = { 'circle' + i }
className = { className }
onClick = { ( e ) => { //eslint-disable-line no-loop-func
e . preventDefault ( ) ;
this . setState ( { currentScreen : i } ) ;
} }
/ >
) ;
}
return (
< div className = 'tutorial__circles' >
{ circles }
2015-10-28 15:04:17 -04:00
< / div >
) ;
}
render ( ) {
const screen = this . createScreen ( ) ;
return (
2016-06-16 22:20:43 +05:00
< div className = 'tutorial-steps__container' >
< div className = 'tutorial__content' >
< div className = 'tutorial__steps' >
{ screen }
< div className = 'tutorial__footer' >
< button
className = 'btn btn-primary'
tabIndex = '1'
onClick = { this . handleNext }
>
< FormattedMessage
id = 'tutorial_intro.next'
defaultMessage = 'Next'
/ >
< / button >
< a
className = 'tutorial-skip'
href = '#'
onClick = { this . skipTutorial }
>
< FormattedMessage
id = 'tutorial_intro.skip'
defaultMessage = 'Skip tutorial'
/ >
< / a >
2015-11-03 19:56:46 +05:00
< / div >
2015-11-02 11:40:53 +05:00
< / div >
< / div >
2015-10-28 15:04:17 -04:00
< / div >
) ;
}
}