diff options
author | Christopher Speller <crspeller@gmail.com> | 2016-02-08 07:26:10 -0500 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-03-14 00:38:25 -0400 |
commit | d7cdcf082fab6c0cb7c2fe4bed821bd1a8000e69 (patch) | |
tree | 49a0de30cdc2ac461e72a242ae9a5593fcd6c8b9 /web/react/components/team_signup_password_page.jsx | |
parent | 08f0800adef926e8b69ebea70e4995b89f5c3f3c (diff) | |
download | chat-d7cdcf082fab6c0cb7c2fe4bed821bd1a8000e69.tar.gz chat-d7cdcf082fab6c0cb7c2fe4bed821bd1a8000e69.tar.bz2 chat-d7cdcf082fab6c0cb7c2fe4bed821bd1a8000e69.zip |
Convering client to react-router.
Diffstat (limited to 'web/react/components/team_signup_password_page.jsx')
-rw-r--r-- | web/react/components/team_signup_password_page.jsx | 214 |
1 files changed, 0 insertions, 214 deletions
diff --git a/web/react/components/team_signup_password_page.jsx b/web/react/components/team_signup_password_page.jsx deleted file mode 100644 index 06c04854f..000000000 --- a/web/react/components/team_signup_password_page.jsx +++ /dev/null @@ -1,214 +0,0 @@ -// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -import * as Client from '../utils/client.jsx'; -import BrowserStore from '../stores/browser_store.jsx'; -import UserStore from '../stores/user_store.jsx'; -import Constants from '../utils/constants.jsx'; - -import {intlShape, injectIntl, defineMessages, FormattedMessage, FormattedHTMLMessage} from 'mm-intl'; - -const holders = defineMessages({ - passwordError: { - id: 'team_signup_password.passwordError', - defaultMessage: 'Please enter at least {chars} characters' - }, - creating: { - id: 'team_signup_password.creating', - defaultMessage: 'Creating team...' - } -}); - -class TeamSignupPasswordPage extends React.Component { - constructor(props) { - super(props); - - this.submitBack = this.submitBack.bind(this); - this.submitNext = this.submitNext.bind(this); - - this.state = {}; - } - submitBack(e) { - e.preventDefault(); - this.props.state.wizard = 'username'; - this.props.updateParent(this.props.state); - } - submitNext(e) { - e.preventDefault(); - - var password = ReactDOM.findDOMNode(this.refs.password).value.trim(); - if (!password || password.length < Constants.MIN_PASSWORD_LENGTH) { - this.setState({passwordError: this.props.intl.formatMessage(holders.passwordError, {chars: Constants.MIN_PASSWORD_LENGTH})}); - return; - } - - this.setState({passwordError: null, serverError: null}); - $('#finish-button').button('loading'); - var teamSignup = JSON.parse(JSON.stringify(this.props.state)); - teamSignup.user.password = password; - teamSignup.user.allow_marketing = true; - delete teamSignup.wizard; - - Client.createTeamFromSignup(teamSignup, - () => { - Client.track('signup', 'signup_team_08_complete'); - - var props = this.props; - - Client.loginByEmail(teamSignup.team.name, teamSignup.team.email, teamSignup.user.password, - () => { - UserStore.setLastEmail(teamSignup.team.email); - if (this.props.hash > 0) { - BrowserStore.setGlobalItem(this.props.hash, JSON.stringify({wizard: 'finished'})); - } - - $('#sign-up-button').button('reset'); - props.state.wizard = 'finished'; - props.updateParent(props.state, true); - - window.location.href = '/' + teamSignup.team.name + '/channels/town-square'; - }, - (err) => { - if (err.id === 'api.user.login.not_verified.app_error') { - window.location.href = '/verify_email?email=' + encodeURIComponent(teamSignup.team.email) + '&teamname=' + encodeURIComponent(teamSignup.team.name); - } else { - this.setState({serverError: err.message}); - $('#finish-button').button('reset'); - } - } - ); - }, - (err) => { - this.setState({serverError: err.message}); - $('#finish-button').button('reset'); - } - ); - } - render() { - Client.track('signup', 'signup_team_07_password'); - - var passwordError = null; - var passwordDivStyle = 'form-group'; - if (this.state.passwordError) { - passwordError = <div className='form-group has-error'><label className='control-label'>{this.state.passwordError}</label></div>; - passwordDivStyle = ' has-error'; - } - - var serverError = null; - if (this.state.serverError) { - serverError = <div className='form-group has-error'><label className='control-label'>{this.state.serverError}</label></div>; - } - - return ( - <div> - <form> - <img - className='signup-team-logo' - src='/static/images/logo.png' - /> - <h2 className='margin--less'> - <FormattedMessage - id='team_signup_password.yourPassword' - defaultMessage='Your password' - /> - </h2> - <h5 className='color--light'> - <FormattedMessage - id='team_signup_password.selectPassword' - defaultMessage="Select a password that you'll use to login with your email address:" - /> - </h5> - <div className='inner__content margin--extra'> - <h5><strong> - <FormattedMessage - id='team_signup_password.email' - defaultMessage='Email' - /> - </strong></h5> - <div className='block--gray form-group'>{this.props.state.team.email}</div> - <div className={passwordDivStyle}> - <div className='row'> - <div className='col-sm-11'> - <h5><strong> - <FormattedMessage - id='team_signup_password.choosePwd' - defaultMessage='Choose your password' - /> - </strong></h5> - <input - autoFocus={true} - type='password' - ref='password' - className='form-control' - placeholder='' - maxLength='128' - spellCheck='false' - /> - <span className='color--light help-block'> - <FormattedMessage - id='team_signup_password.hint' - defaultMessage='Passwords must contain {min} to {max} characters. Your password will be strongest if it contains a mix of symbols, numbers, and upper and lowercase characters.' - values={{ - min: Constants.MIN_PASSWORD_LENGTH, - max: Constants.MAX_PASSWORD_LENGTH - }} - /> - </span> - </div> - </div> - {passwordError} - {serverError} - </div> - </div> - <div className='form-group'> - <button - type='submit' - className='btn btn-primary margin--extra' - id='finish-button' - data-loading-text={'<span class=\'glyphicon glyphicon-refresh glyphicon-refresh-animate\'></span> ' + this.props.intl.formatMessage(holders.creating)} - onClick={this.submitNext} - > - <FormattedMessage - id='team_signup_password.finish' - defaultMessage='Finish' - /> - </button> - </div> - <p> - <FormattedHTMLMessage - id='team_signup_password.agreement' - defaultMessage="By proceeding to create your account and use {siteName}, you agree to our <a href='/static/help/terms.html'>Terms of Service</a> and <a href='/static/help/privacy.html'>Privacy Policy</a>. If you do not agree, you cannot use {siteName}." - values={{ - siteName: global.window.mm_config.SiteName - }} - /> - </p> - <div className='margin--extra'> - <a - href='#' - onClick={this.submitBack} - > - <FormattedMessage - id='team_signup_password.back' - defaultMessage='Back to previous step' - /> - </a> - </div> - </form> - </div> - ); - } -} - -TeamSignupPasswordPage.defaultProps = { - state: {}, - hash: '' -}; -TeamSignupPasswordPage.propTypes = { - intl: intlShape.isRequired, - state: React.PropTypes.object, - hash: React.PropTypes.string, - updateParent: React.PropTypes.func -}; - -export default injectIntl(TeamSignupPasswordPage);
\ No newline at end of file |