Files
mattermost/webapp/components/tutorial/tutorial_intro_screens.jsx

304 lines
10 KiB
React
Raw Normal View History

// 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';
import * as GlobalActions from 'actions/global_actions.jsx';
import {Constants, Preferences} from 'utils/constants.jsx';
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';
import AppIcons from 'images/appIcons.png';
const NUM_SCREENS = 3;
2016-03-14 08:50:46 -04:00
import React from 'react';
export default class TutorialIntroScreens extends React.Component {
static get propTypes() {
return {
townSquare: React.PropTypes.object,
offTopic: React.PropTypes.object
};
}
constructor(props) {
super(props);
this.handleNext = this.handleNext.bind(this);
this.createScreen = this.createScreen.bind(this);
this.createCircles = this.createCircles.bind(this);
2015-10-30 11:35:16 -04:00
this.state = {currentScreen: 0};
}
handleNext() {
2015-10-30 11:35:16 -04:00
if (this.state.currentScreen < 2) {
this.setState({currentScreen: this.state.currentScreen + 1});
return;
}
browserHistory.push(TeamStore.getCurrentTeamUrl() + '/channels/town-square');
const step = PreferenceStore.getInt(Preferences.TUTORIAL_STEP, UserStore.getCurrentId(), 0);
2015-10-30 11:35:16 -04:00
AsyncClient.savePreference(
Preferences.TUTORIAL_STEP,
UserStore.getCurrentId(),
(step + 1).toString()
);
}
skipTutorial(e) {
e.preventDefault();
AsyncClient.savePreference(
Preferences.TUTORIAL_STEP,
UserStore.getCurrentId(),
'999'
);
browserHistory.push(TeamStore.getCurrentTeamUrl() + '/channels/town-square');
}
createScreen() {
2015-10-30 11:35:16 -04:00
switch (this.state.currentScreen) {
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;
}
createScreenOne() {
const circles = this.createCircles();
return (
<div>
<FormattedHTMLMessage
id='tutorial_intro.screenOne'
defaultMessage='<h3>Welcome to:</h3>
<h1>Mattermost</h1>
<p>Your team communication all in one place, instantly searchable and available anywhere.</p>
<p>Keep your team connected to help them achieve what matters most.</p>'
/>
{circles}
</div>
);
}
createScreenTwo() {
const circles = this.createCircles();
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>
);
}
return (
<div>
<FormattedHTMLMessage
id='tutorial_intro.screenTwo'
defaultMessage='<h3>How Mattermost works:</h3>
<p>Communication happens in public discussion channels, private groups and direct messages.</p>
<p>Everything is archived and searchable from any web-enabled desktop, laptop or phone.</p>'
/>
{appDownloadLink}
{appDownloadImage}
{circles}
</div>
);
}
createScreenThree() {
const team = TeamStore.getCurrent();
let inviteModalLink;
let inviteText;
if (global.window.mm_license.IsLicensed !== 'true' || global.window.mm_config.RestrictTeamInvite === Constants.PERMISSIONS_ALL) {
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}
<FormattedMessage
id='tutorial_intro.whenReady'
defaultMessage=' when youre ready.'
/>
</p>
);
}
const circles = this.createCircles();
let supportInfo = null;
if (global.window.mm_config.SupportEmail) {
supportInfo = (
2015-11-02 11:40:53 +05:00
<p>
<FormattedMessage
id='tutorial_intro.support'
defaultMessage='Need anything, just email us at '
/>
2015-11-02 11:40:53 +05:00
<a
href={'mailto:' + global.window.mm_config.SupportEmail}
2015-11-02 11:40:53 +05:00
target='_blank'
rel='noopener noreferrer'
2015-11-02 11:40:53 +05: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>
);
}
let townSquareDisplayName = Constants.DEFAULT_CHANNEL_UI_NAME;
if (this.props.townSquare) {
townSquareDisplayName = this.props.townSquare.display_name;
}
return (
<div>
<h3>
<FormattedMessage
id='tutorial_intro.allSet'
defaultMessage='Youre all set'
/>
</h3>
{inviteText}
{supportInfo}
<FormattedMessage
id='tutorial_intro.end'
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
}}
/>
{circles}
</div>
);
}
createCircles() {
const circles = [];
for (let i = 0; i < NUM_SCREENS; i++) {
let className = 'circle';
if (i === this.state.currentScreen) {
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}
</div>
);
}
render() {
const screen = this.createScreen();
return (
<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>
</div>
);
}
}