From e6f8fa0fa7b49be202c5143f361432d597f5fd61 Mon Sep 17 00:00:00 2001 From: hmhealey Date: Wed, 5 Aug 2015 15:41:12 -0400 Subject: Reformat signup_user_complete to match style guide --- web/react/components/signup_user_complete.jsx | 197 ++++++++++++++++---------- 1 file changed, 121 insertions(+), 76 deletions(-) diff --git a/web/react/components/signup_user_complete.jsx b/web/react/components/signup_user_complete.jsx index 03808e821..a296345b1 100644 --- a/web/react/components/signup_user_complete.jsx +++ b/web/react/components/signup_user_complete.jsx @@ -1,7 +1,6 @@ // Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. // See License.txt for license information. - var utils = require('../utils/utils.jsx'); var client = require('../utils/client.jsx'); var UserStore = require('../stores/user_store.jsx'); @@ -9,36 +8,41 @@ var BrowserStore = require('../stores/browser_store.jsx'); module.exports = React.createClass({ handleSubmit: function(e) { - e.preventDefault(); + e.preventDefault(); this.state.user.username = this.refs.name.getDOMNode().value.trim(); if (!this.state.user.username) { - this.setState({name_error: "This field is required", email_error: "", password_error: "", server_error: ""}); + this.setState({nameError: 'This field is required', emailError: '', passwordError: '', serverError: ''}); return; } - var username_error = utils.isValidUsername(this.state.user.username); - if (username_error === "Cannot use a reserved word as a username.") { - this.setState({name_error: "This username is reserved, please choose a new one.", email_error: "", password_error: "", server_error: ""}); + var usernameError = utils.isValidUsername(this.state.user.username); + if (usernameError === 'Cannot use a reserved word as a username.') { + this.setState({nameError: 'This username is reserved, please choose a new one.', emailError: '', passwordError: '', serverError: ''}); return; - } else if (username_error) { - this.setState({name_error: "Username must begin with a letter, and contain between 3 to 15 lowercase characters made up of numbers, letters, and the symbols '.', '-' and '_'.", email_error: "", password_error: "", server_error: ""}); + } else if (usernameError) { + this.setState({ + nameError: 'Username must begin with a letter, and contain between 3 to 15 lowercase characters made up of numbers, letters, and the symbols \'.\', \'-\' and \'_\'.', + emailError: '', + passwordError: '', + serverError: '' + }); return; } this.state.user.email = this.refs.email.getDOMNode().value.trim(); if (!this.state.user.email) { - this.setState({name_error: "", email_error: "This field is required", password_error: ""}); + this.setState({nameError: '', emailError: 'This field is required', passwordError: ''}); return; } this.state.user.password = this.refs.password.getDOMNode().value.trim(); if (!this.state.user.password || this.state.user.password .length < 5) { - this.setState({name_error: "", email_error: "", password_error: "Please enter at least 5 characters", server_error: ""}); + this.setState({nameError: '', emailError: '', passwordError: 'Please enter at least 5 characters', serverError: ''}); return; } - this.setState({name_error: "", email_error: "", password_error: "", server_error: ""}); + this.setState({nameError: '', emailError: '', passwordError: '', serverError: ''}); this.state.user.allow_marketing = true; @@ -50,108 +54,149 @@ module.exports = React.createClass({ function(data) { UserStore.setLastEmail(this.state.user.email); UserStore.setCurrentUser(data); - if (this.props.hash > 0) - { - BrowserStore.setGlobalItem(this.props.hash, JSON.stringify({wizard: "finished"})); + if (this.props.hash > 0) { + BrowserStore.setGlobalItem(this.props.hash, JSON.stringify({wizard: 'finished'})); } window.location.href = '/'; }.bind(this), function(err) { - if (err.message == "Login failed because email address has not been verified") { - window.location.href = "/verify_email?email="+ encodeURIComponent(this.state.user.email) + "&teamname=" + encodeURIComponent(this.props.teamName); + if (err.message === 'Login failed because email address has not been verified') { + window.location.href = '/verify_email?email=' + encodeURIComponent(this.state.user.email) + '&teamname=' + encodeURIComponent(this.props.teamName); } else { - this.state.server_error = err.message; - this.setState(this.state); + this.setState({serverError: err.message}); } }.bind(this) ); }.bind(this), function(err) { - this.state.server_error = err.message; - this.setState(this.state); + this.setState({serverError: err.message}); }.bind(this) ); }, getInitialState: function() { - var props = BrowserStore.getGlobalItem(this.props.hash); - - if (!props) { - props = {}; - props.wizard = "welcome"; - props.user = {}; - props.user.team_id = this.props.teamId; - props.user.email = this.props.email; - props.hash = this.props.hash; - props.data = this.props.data; - props.original_email = this.props.email; + var state = BrowserStore.getGlobalItem(this.props.hash); + + if (!state) { + state = {}; + state.wizard = 'welcome'; + state.user = {}; + state.user.team_id = this.props.teamId; + state.user.email = this.props.email; + state.hash = this.props.hash; + state.data = this.props.data; + state.original_email = this.props.email; } - return props; + return state; }, render: function() { - client.track('signup', 'signup_user_01_welcome'); - if (this.state.wizard == "finished") { - return (
You've already completed the signup process for this invitation or this invitation has expired.
); + if (this.state.wizard === 'finished') { + return
You've already completed the signup process for this invitation or this invitation has expired.
; + } + + // set up error labels + var emailError = null; + var emailDivStyle = 'form-group'; + if (this.state.emailError) { + emailError = ; + emailDivStyle += ' has-error'; + } + + var nameError = null; + var nameDivStyle = 'form-group'; + if (this.state.nameError) { + nameError = ; + nameDivStyle += ' has-error'; + } + + var passwordError = null; + var passwordDivStyle = 'form-group'; + if (this.state.passwordError) { + passwordError = ; + passwordDivStyle += ' has-error'; + } + + var serverError = null; + if (this.state.serverError) { + serverError = ( +
+ +
+ ); } - var email_error = this.state.email_error ? : null; - var name_error = this.state.name_error ? : null; - var password_error = this.state.password_error ? : null; - var server_error = this.state.server_error ?
: null; + // set up the email entry and hide it if an email was provided + var yourEmailIs = ''; + if (this.state.user.email) { + yourEmailIs = Your email address is {this.state.user.email}. You'll use this address to sign in to {config.SiteName}.; + } - var yourEmailIs = this.state.user.email == "" ? "" : Your email address is { this.state.user.email }. + var emailContainerStyle = "margin--extra"; + if (this.state.original_email) { + emailContainerStyle = "hidden"; + } var email = ( -
+
What's your email address?
-
- - { email_error } -
+
+ + {emailError}
+
); - var auth_services = JSON.parse(this.props.authServices); - - var signup_message; - if (auth_services.indexOf("gitlab") >= 0) { - signup_message =
{"with GitLab"} -
or
; + // add options to log in using another service + var authServices = JSON.parse(this.props.authServices); + + var signupMessage = null; + if (authServices.indexOf('gitlab') >= 0) { + signupMessage = ( +
+ + + with GitLab + +
+ or +
+
+ ); } return (
- -
Welcome to:
-

{ this.props.teamDisplayName }

-

on { config.SiteName }

-

Let's create your account

- { signup_message } -
- { email } -

{ yourEmailIs } You’ll use this address to sign in to {config.SiteName}.

-
-
Choose your username
-
- - { name_error } -

Username must begin with a letter, and contain between 3 to 15 lowercase characters made up of numbers, letters, and the symbols '.', '-' and '_'"

+ +
Welcome to:
+

{this.props.teamDisplayName}

+

on {config.SiteName}

+

Let's create your account

+ {signupMessage} +
+ {email} + {yourEmailIs} +
+
Choose your username
+
+ + {nameError} +

Username must begin with a letter, and contain between 3 to 15 lowercase characters made up of numbers, letters, and the symbols '.', '-' and '_'

+
+
+
+
Choose your password
+
+ + {passwordError}
-
-
-
Choose your password
-
- - { password_error }
-
-

- { server_error } -

By creating an account and using Mattermost you are agreeing to our Terms of Service. If you do not agree, you cannot use this service.

+

+ {serverError} +

By creating an account and using Mattermost you are agreeing to our Terms of Service. If you do not agree, you cannot use this service.

); -- cgit v1.2.3-1-g7c22 From 7d40748d01c931cc29abf47ede2457376a007930 Mon Sep 17 00:00:00 2001 From: hmhealey Date: Wed, 5 Aug 2015 16:07:20 -0400 Subject: Added ShowTermsDuringSignup config option on the client which toggles the Terms of Service disclaimer on signup --- web/react/components/signup_user_complete.jsx | 7 ++++++- web/static/config/config.js | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/web/react/components/signup_user_complete.jsx b/web/react/components/signup_user_complete.jsx index a296345b1..b21553d8a 100644 --- a/web/react/components/signup_user_complete.jsx +++ b/web/react/components/signup_user_complete.jsx @@ -166,6 +166,11 @@ module.exports = React.createClass({ ); } + var termsDisclaimer = null; + if (config.ShowTermsDuringSignup) { + termsDisclaimer =

By creating an account and using Mattermost you are agreeing to our Terms of Service. If you do not agree, you cannot use this service.

; + } + return (
@@ -196,7 +201,7 @@ module.exports = React.createClass({

{serverError} -

By creating an account and using Mattermost you are agreeing to our Terms of Service. If you do not agree, you cannot use this service.

+ {termsDisclaimer}
); diff --git a/web/static/config/config.js b/web/static/config/config.js index 0d564b77e..00cae7ab2 100644 --- a/web/static/config/config.js +++ b/web/static/config/config.js @@ -31,6 +31,9 @@ var config = { ReportProblemLink: "/static/help/configure_links.html", HomeLink: "", + // Toggle whether or not users are shown a message about agreeing to the Terms of Service during the signup process + ShowTermsDuringSignup: false, + ThemeColors: ["#2389d7", "#008a17", "#dc4fad", "#ac193d", "#0072c6", "#d24726", "#ff8f32", "#82ba00", "#03b3b2", "#008299", "#4617b4", "#8c0095", "#004b8b", "#004b8b", "#570000", "#380000", "#585858", "#000000"] }; -- cgit v1.2.3-1-g7c22