Reformatted code to match the style guide

Этот коммит содержится в:
hmhealey
2015-08-11 16:52:36 -04:00
родитель 37909f52ad
Коммит d35065d6fd
3 изменённых файлов: 306 добавлений и 262 удалений

Просмотреть файл

@@ -1,7 +1,6 @@
// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. // Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
// See License.txt for license information. // See License.txt for license information.
var utils = require('../utils/utils.jsx'); var utils = require('../utils/utils.jsx');
var client = require('../utils/client.jsx'); var client = require('../utils/client.jsx');
var UserStore = require('../stores/user_store.jsx'); var UserStore = require('../stores/user_store.jsx');
@@ -11,111 +10,132 @@ var constants = require('../utils/constants.jsx');
WelcomePage = React.createClass({ WelcomePage = React.createClass({
submitNext: function (e) { submitNext: function (e) {
if (!BrowserStore.isLocalStorageSupported()) { if (!BrowserStore.isLocalStorageSupported()) {
this.setState({ storage_error: "This service requires local storage to be enabled. Please enable it or exit private browsing."} ); this.setState({storageError: 'This service requires local storage to be enabled. Please enable it or exit private browsing.'});
return; return;
} }
e.preventDefault(); e.preventDefault();
this.props.state.wizard = "team_display_name"; this.props.state.wizard = 'team_display_name';
this.props.updateParent(this.props.state); this.props.updateParent(this.props.state);
}, },
handleDiffEmail: function (e) { handleDiffEmail: function (e) {
e.preventDefault(); e.preventDefault();
this.setState({ use_diff: true }); this.setState({useDiff: true});
}, },
handleDiffSubmit: function (e) { handleDiffSubmit: function (e) {
e.preventDefault(); e.preventDefault();
var state = { use_diff: true, server_error: "" }; var state = {useDiff: true, serverError: ''};
var email = this.refs.email.getDOMNode().value.trim().toLowerCase(); var email = this.refs.email.getDOMNode().value.trim().toLowerCase();
if (!email || !utils.isEmail(email)) { if (!email || !utils.isEmail(email)) {
state.email_error = "Please enter a valid email address"; state.emailError = 'Please enter a valid email address';
this.setState(state); this.setState(state);
return; return;
} } else if (!BrowserStore.isLocalStorageSupported()) {
else if (!BrowserStore.isLocalStorageSupported()) { state.emailError = 'This service requires local storage to be enabled. Please enable it or exit private browsing.';
state.email_error = "This service requires local storage to be enabled. Please enable it or exit private browsing.";
this.setState(state); this.setState(state);
return; return;
} } else {
else { state.emailError = '';
state.email_error = "";
} }
client.signupTeam(email, client.signupTeam(email,
function(data) { function(data) {
if (data["follow_link"]) { if (data['follow_link']) {
window.location.href = data["follow_link"]; window.location.href = data['follow_link'];
} else { } else {
this.props.state.wizard = "finished"; this.props.state.wizard = 'finished';
this.props.updateParent(this.props.state); this.props.updateParent(this.props.state);
window.location.href = "/signup_team_confirm/?email=" + encodeURIComponent(team.email); window.location.href = '/signup_team_confirm/?email=' + encodeURIComponent(team.email);
} }
}.bind(this), }.bind(this),
function(err) { function(err) {
this.state.server_error = err.message; this.state.serverError = err.message;
this.setState(this.state); this.setState(this.state);
}.bind(this) }.bind(this)
); );
}, },
getInitialState: function() { getInitialState: function() {
return { use_diff: false }; return {useDiff: false};
}, },
handleKeyPress: function(event) { handleKeyPress: function(event) {
if (event.keyCode == 13) { if (event.keyCode === 13) {
this.submitNext(event); this.submitNext(event);
} }
}, },
componentWillMount: function() { componentWillMount: function() {
document.addEventListener("keyup", this.handleKeyPress, false); document.addEventListener('keyup', this.handleKeyPress, false);
}, },
componentWillUnmount: function() { componentWillUnmount: function() {
document.removeEventListener("keyup", this.handleKeyPress, false); document.removeEventListener('keyup', this.handleKeyPress, false);
}, },
render: function() { render: function() {
client.track('signup', 'signup_team_01_welcome'); client.track('signup', 'signup_team_01_welcome');
var storage_error = this.state.storage_error ? <label className="control-label">{ this.state.storage_error }</label> : null; var storageError = null;
var email_error = this.state.email_error ? <label className="control-label">{ this.state.email_error }</label> : null; if (this.state.storageError) {
var server_error = this.state.server_error ? <div className={ "form-group has-error" }><label className="control-label">{ this.state.server_error }</label></div> : null; storageError = <label className='control-label'>{this.state.storageError}</label>;
}
var emailError = null;
var emailDivClass = 'form-group';
if (this.state.emailError) {
emailError = <label className='control-label'>{this.state.emailError}</label>;
emailDivClass += ' 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>
);
}
var differentEmailLinkClass = '';
var emailDivContainerClass = 'hidden';
if (this.state.useDiff) {
differentEmailLinkClass = 'hidden';
emailDivContainerClass = '';
}
return ( return (
<div> <div>
<p> <p>
<img className="signup-team-logo" src="/static/images/logo.png" /> <img className='signup-team-logo' src='/static/images/logo.png' />
<h3 className="sub-heading">Welcome to:</h3> <h3 className='sub-heading'>Welcome to:</h3>
<h1 className="margin--top-none">{config.SiteName}</h1> <h1 className='margin--top-none'>{config.SiteName}</h1>
</p> </p>
<p className="margin--less">Let's set up your new team</p> <p className='margin--less'>Let's set up your new team</p>
<p> <p>
Please confirm your email address:<br /> Please confirm your email address:<br />
<div className="inner__content"> <div className='inner__content'>
<div className="block--gray">{ this.props.state.team.email }</div> <div className='block--gray'>{this.props.state.team.email}</div>
</div> </div>
</p> </p>
<p className="margin--extra color--light"> <p className='margin--extra color--light'>
Your account will administer the new team site. <br /> Your account will administer the new team site. <br />
You can add other administrators later. You can add other administrators later.
</p> </p>
<div className="form-group"> <div className='form-group'>
<button className="btn-primary btn form-group" type="submit" onClick={this.submitNext}><i className="glyphicon glyphicon-ok"></i>Yes, this address is correct</button> <button className='btn-primary btn form-group' type='submit' onClick={this.submitNext}><i className='glyphicon glyphicon-ok'></i>Yes, this address is correct</button>
{ storage_error } {storageError}
</div> </div>
<hr /> <hr />
<div className={ this.state.use_diff ? "" : "hidden" }> <div className={emailDivContainerClass}>
<div className={ email_error ? "form-group has-error" : "form-group" }> <div className={emailDivClass}>
<div className="row"> <div className='row'>
<div className="col-sm-9"> <div className='col-sm-9'>
<input type="email" ref="email" className="form-control" placeholder="Email Address" maxLength="128" /> <input type='email' ref='email' className='form-control' placeholder='Email Address' maxLength='128' />
</div> </div>
</div> </div>
{ email_error } {emailError}
</div> </div>
{ server_error } {serverError}
<button className="btn btn-md btn-primary" type="button" onClick={this.handleDiffSubmit} type="submit">Use this instead</button> <button className='btn btn-md btn-primary' type='button' onClick={this.handleDiffSubmit} type='submit'>Use this instead</button>
</div> </div>
<a href="#" onClick={this.handleDiffEmail} className={ this.state.use_diff ? "hidden" : "" }>Use a different email</a> <a href='#' onClick={this.handleDiffEmail} className={differentEmailLinkClass}>Use a different email</a>
</div> </div>
); );
} }
@@ -124,7 +144,7 @@ WelcomePage = React.createClass({
TeamDisplayNamePage = React.createClass({ TeamDisplayNamePage = React.createClass({
submitBack: function (e) { submitBack: function (e) {
e.preventDefault(); e.preventDefault();
this.props.state.wizard = "welcome"; this.props.state.wizard = 'welcome';
this.props.updateParent(this.props.state); this.props.updateParent(this.props.state);
}, },
submitNext: function (e) { submitNext: function (e) {
@@ -132,17 +152,17 @@ TeamDisplayNamePage = React.createClass({
var display_name = this.refs.name.getDOMNode().value.trim(); var display_name = this.refs.name.getDOMNode().value.trim();
if (!display_name) { if (!display_name) {
this.setState({name_error: "This field is required"}); this.setState({nameError: 'This field is required'});
return; return;
} }
this.props.state.wizard = "team_url"; this.props.state.wizard = 'team_url';
this.props.state.team.display_name = display_name; this.props.state.team.display_name = display_name;
this.props.state.team.name = utils.cleanUpUrlable(display_name); this.props.state.team.name = utils.cleanUpUrlable(display_name);
this.props.updateParent(this.props.state); this.props.updateParent(this.props.state);
}, },
getInitialState: function() { getInitialState: function() {
return { }; return {};
}, },
handleFocus: function(e) { handleFocus: function(e) {
e.preventDefault(); e.preventDefault();
@@ -150,31 +170,35 @@ TeamDisplayNamePage = React.createClass({
e.currentTarget.select(); e.currentTarget.select();
}, },
render: function() { render: function() {
client.track('signup', 'signup_team_02_name'); client.track('signup', 'signup_team_02_name');
var name_error = this.state.name_error ? <label className="control-label">{ this.state.name_error }</label> : null; var nameError = null;
var nameDivClass = 'form-group';
if (this.state.nameError) {
nameError = <label className='control-label'>{this.state.nameError}</label>;
nameDivClass += ' has-error';
}
return ( return (
<div> <div>
<form> <form>
<img className="signup-team-logo" src="/static/images/logo.png" /> <img className='signup-team-logo' src='/static/images/logo.png' />
<h2>{utils.toTitleCase(strings.Team) + " Name"}</h2> <h2>{utils.toTitleCase(strings.Team) + ' Name'}</h2>
<div className={ name_error ? "form-group has-error" : "form-group" }> <div className={nameDivClass}>
<div className="row"> <div className='row'>
<div className="col-sm-9"> <div className='col-sm-9'>
<input type="text" ref="name" className="form-control" placeholder="" maxLength="128" defaultValue={this.props.state.team.display_name} autoFocus={true} onFocus={this.handleFocus} /> <input type='text' ref='name' className='form-control' placeholder='' maxLength='128' defaultValue={this.props.state.team.display_name} autoFocus={true} onFocus={this.handleFocus} />
</div>
</div>
{nameError}
</div> </div>
</div> <div>{'Name your ' + strings.Team + ' in any language. Your ' + strings.Team + ' name shows in menus and headings.'}</div>
{ name_error } <button type='submit' className='btn btn-primary margin--extra' onClick={this.submitNext}>Next<i className='glyphicon glyphicon-chevron-right'></i></button>
</div> <div className='margin--extra'>
<div>{"Name your " + strings.Team + " in any language. Your " + strings.Team + " name shows in menus and headings."}</div> <a href='#' onClick={this.submitBack}>Back to previous step</a>
<button type="submit" className="btn btn-primary margin--extra" onClick={this.submitNext}>Next<i className="glyphicon glyphicon-chevron-right"></i></button> </div>
<div className="margin--extra"> </form>
<a href="#" onClick={this.submitBack}>Back to previous step</a>
</div>
</form>
</div> </div>
); );
} }
@@ -183,7 +207,7 @@ TeamDisplayNamePage = React.createClass({
TeamURLPage = React.createClass({ TeamURLPage = React.createClass({
submitBack: function (e) { submitBack: function (e) {
e.preventDefault(); e.preventDefault();
this.props.state.wizard = "team_display_name"; this.props.state.wizard = 'team_display_name';
this.props.updateParent(this.props.state); this.props.updateParent(this.props.state);
}, },
submitNext: function (e) { submitNext: function (e) {
@@ -191,25 +215,24 @@ TeamURLPage = React.createClass({
var name = this.refs.name.getDOMNode().value.trim(); var name = this.refs.name.getDOMNode().value.trim();
if (!name) { if (!name) {
this.setState({name_error: "This field is required"}); this.setState({nameError: 'This field is required'});
return; return;
} }
var cleaned_name = utils.cleanUpUrlable(name); var cleanedName = utils.cleanUpUrlable(name);
var urlRegex = /^[a-z0-9]+([a-z\-0-9]+|(__)?)[a-z0-9]+$/g; var urlRegex = /^[a-z0-9]+([a-z\-0-9]+|(__)?)[a-z0-9]+$/g;
if (cleaned_name != name || !urlRegex.test(name)) { if (cleanedName !== name || !urlRegex.test(name)) {
this.setState({name_error: "Must be lowercase alphanumeric characters"}); this.setState({nameError: 'Must be lowercase alphanumeric characters'});
return; return;
} } else if (cleanedName.length <= 3 || cleanedName.length > 15) {
else if (cleaned_name.length <= 3 || cleaned_name.length > 15) { this.setState({nameError: 'Name must be 4 or more characters up to a maximum of 15'});
this.setState({name_error: "Name must be 4 or more characters up to a maximum of 15"})
return; return;
} }
for (var index = 0; index < constants.RESERVED_TEAM_NAMES.length; index++) { for (var index = 0; index < constants.RESERVED_TEAM_NAMES.length; index++) {
if (cleaned_name.indexOf(constants.RESERVED_TEAM_NAMES[index]) == 0) { if (cleanedName.indexOf(constants.RESERVED_TEAM_NAMES[index]) === 0) {
this.setState({name_error: "This team name is unavailable"}) this.setState({nameError: 'This team name is unavailable'});
return; return;
} }
} }
@@ -218,28 +241,27 @@ TeamURLPage = React.createClass({
function(data) { function(data) {
if (!data) { if (!data) {
if (config.AllowSignupDomainsWizard) { if (config.AllowSignupDomainsWizard) {
this.props.state.wizard = "allowed_domains"; this.props.state.wizard = 'allowed_domains';
} else { } else {
this.props.state.wizard = "send_invites"; this.props.state.wizard = 'send_invites';
this.props.state.team.type = 'O'; this.props.state.team.type = 'O';
} }
this.props.state.team.name = name; this.props.state.team.name = name;
this.props.updateParent(this.props.state); this.props.updateParent(this.props.state);
} } else {
else { this.state.nameError = 'This URL is unavailable. Please try another.';
this.state.name_error = "This URL is unavailable. Please try another.";
this.setState(this.state); this.setState(this.state);
} }
}.bind(this), }.bind(this),
function(err) { function(err) {
this.state.name_error = err.message; this.state.nameError = err.message;
this.setState(this.state); this.setState(this.state);
}.bind(this) }.bind(this)
); );
}, },
getInitialState: function() { getInitialState: function() {
return { }; return {};
}, },
handleFocus: function(e) { handleFocus: function(e) {
e.preventDefault(); e.preventDefault();
@@ -247,40 +269,44 @@ TeamURLPage = React.createClass({
e.currentTarget.select(); e.currentTarget.select();
}, },
render: function() { render: function() {
$('body').tooltip( {selector: '[data-toggle=tooltip]', trigger: 'hover click'} ); $('body').tooltip( {selector: '[data-toggle=tooltip]', trigger: 'hover click'} );
client.track('signup', 'signup_team_03_url'); client.track('signup', 'signup_team_03_url');
var name_error = this.state.name_error ? <label className="control-label">{ this.state.name_error }</label> : null; var nameError = null;
var nameDivClass = 'form-group';
if (this.state.nameError) {
nameError = <label className='control-label'>{this.state.nameError}</label>;
nameDivClass += ' has-error';
}
return ( return (
<div> <div>
<form> <form>
<img className="signup-team-logo" src="/static/images/logo.png" /> <img className='signup-team-logo' src='/static/images/logo.png' />
<h2>{utils.toTitleCase(strings.Team) + " URL"}</h2> <h2>{utils.toTitleCase(strings.Team) + ' URL'}</h2>
<div className={ name_error ? "form-group has-error" : "form-group" }> <div className={nameDivClass}>
<div className="row"> <div className='row'>
<div className="col-sm-11"> <div className='col-sm-11'>
<div className="input-group input-group--limit"> <div className='input-group input-group--limit'>
<span data-toggle="tooltip" title={ utils.getWindowLocationOrigin() + "/" } className="input-group-addon">{ utils.getWindowLocationOrigin() + "/" }</span> <span data-toggle='tooltip' title={utils.getWindowLocationOrigin() + '/'} className='input-group-addon'>{utils.getWindowLocationOrigin() + '/'}</span>
<input type="text" ref="name" className="form-control" placeholder="" maxLength="128" defaultValue={this.props.state.team.name} autoFocus={true} onFocus={this.handleFocus}/> <input type='text' ref='name' className='form-control' placeholder='' maxLength='128' defaultValue={this.props.state.team.name} autoFocus={true} onFocus={this.handleFocus}/>
</div>
</div>
</div> </div>
{nameError}
</div> </div>
</div> <p>{'Choose the web address of your new ' + strings.Team + ':'}</p>
{ name_error } <ul className='color--light'>
</div> <li>Short and memorable is best</li>
<p>{"Choose the web address of your new " + strings.Team + ":"}</p> <li>Use lowercase letters, numbers and dashes</li>
<ul className="color--light"> <li>Must start with a letter and can't end in a dash</li>
<li>Short and memorable is best</li> </ul>
<li>Use lowercase letters, numbers and dashes</li> <button type='submit' className='btn btn-primary margin--extra' onClick={this.submitNext}>Next<i className='glyphicon glyphicon-chevron-right'></i></button>
<li>Must start with a letter and can't end in a dash</li> <div className='margin--extra'>
</ul> <a href='#' onClick={this.submitBack}>Back to previous step</a>
<button type="submit" className="btn btn-primary margin--extra" onClick={this.submitNext}>Next<i className="glyphicon glyphicon-chevron-right"></i></button> </div>
<div className="margin--extra"> </form>
<a href="#" onClick={this.submitBack}>Back to previous step</a>
</div>
</form>
</div> </div>
); );
} }
@@ -289,14 +315,14 @@ TeamURLPage = React.createClass({
AllowedDomainsPage = React.createClass({ AllowedDomainsPage = React.createClass({
submitBack: function (e) { submitBack: function (e) {
e.preventDefault(); e.preventDefault();
this.props.state.wizard = "team_url"; this.props.state.wizard = 'team_url';
this.props.updateParent(this.props.state); this.props.updateParent(this.props.state);
}, },
submitNext: function (e) { submitNext: function (e) {
e.preventDefault(); e.preventDefault();
if (this.refs.open_network.getDOMNode().checked) { if (this.refs.open_network.getDOMNode().checked) {
this.props.state.wizard = "send_invites"; this.props.state.wizard = 'send_invites';
this.props.state.team.type = 'O'; this.props.state.team.type = 'O';
this.props.updateParent(this.props.state); this.props.updateParent(this.props.state);
return; return;
@@ -304,65 +330,72 @@ AllowedDomainsPage = React.createClass({
if (this.refs.allow.getDOMNode().checked) { if (this.refs.allow.getDOMNode().checked) {
var name = this.refs.name.getDOMNode().value.trim(); var name = this.refs.name.getDOMNode().value.trim();
var domainRegex = /^\w+\.\w+$/ var domainRegex = /^\w+\.\w+$/;
if (!name) { if (!name) {
this.setState({name_error: "This field is required"}); this.setState({nameError: 'This field is required'});
return; return;
} }
if(!name.trim().match(domainRegex)) { if (!name.trim().match(domainRegex)) {
this.setState({name_error: "The domain doesn't appear valid"}); this.setState({nameError: 'The domain doesn\'t appear valid'});
return; return;
} }
this.props.state.wizard = "send_invites"; this.props.state.wizard = 'send_invites';
this.props.state.team.allowed_domains = name; this.props.state.team.allowed_domains = name;
this.props.state.team.type = 'I'; this.props.state.team.type = 'I';
this.props.updateParent(this.props.state); this.props.updateParent(this.props.state);
} } else {
else { this.props.state.wizard = 'send_invites';
this.props.state.wizard = "send_invites";
this.props.state.team.type = 'I'; this.props.state.team.type = 'I';
this.props.updateParent(this.props.state); this.props.updateParent(this.props.state);
} }
}, },
getInitialState: function() { getInitialState: function() {
return { }; return {};
}, },
render: function() { render: function() {
client.track('signup', 'signup_team_04_allow_domains'); client.track('signup', 'signup_team_04_allow_domains');
var name_error = this.state.name_error ? <label className="control-label">{ this.state.name_error }</label> : null; var nameError = null;
var nameDivClass = 'form-group';
if (this.state.nameError) {
nameError = <label className='control-label'>{this.state.nameError}</label>;
nameDivClass += ' has-error';
}
return ( return (
<div> <div>
<form> <form>
<img className="signup-team-logo" src="/static/images/logo.png" /> <img className='signup-team-logo' src='/static/images/logo.png' />
<h2>Email Domain</h2> <h2>Email Domain</h2>
<p> <p>
<div className="checkbox"><label><input type="checkbox" ref="allow" defaultChecked />{" Allow sign up and " + strings.Team + " discovery with a " + strings.Company + " email address."}</label></div> <div className='checkbox'>
</p> <label><input type='checkbox' ref='allow' defaultChecked />{' Allow sign up and ' + strings.Team + ' discovery with a ' + strings.Company + ' email address.'}</label>
<p>{"Check this box to allow your " + strings.Team + " members to sign up using their " + strings.Company + " email addresses if you share the same domain--otherwise, you need to invite everyone yourself."}</p>
<h4>{"Your " + strings.Team + "'s domain for emails"}</h4>
<div className={ name_error ? "form-group has-error" : "form-group" }>
<div className="row">
<div className="col-sm-9">
<div className="input-group">
<span className="input-group-addon">@</span>
<input type="text" ref="name" className="form-control" placeholder="" maxLength="128" defaultValue={this.props.state.team.allowed_domains} autoFocus={true} onFocus={this.handleFocus}/>
</div> </div>
</p>
<p>{'Check this box to allow your ' + strings.Team + ' members to sign up using their ' + strings.Company + ' email addresses if you share the same domain--otherwise, you need to invite everyone yourself.'}</p>
<h4>{'Your ' + strings.Team + '\'s domain for emails'}</h4>
<div className={nameDivClass}>
<div className='row'>
<div className='col-sm-9'>
<div className='input-group'>
<span className='input-group-addon'>@</span>
<input type='text' ref='name' className='form-control' placeholder='' maxLength='128' defaultValue={this.props.state.team.allowed_domains} autoFocus={true} onFocus={this.handleFocus}/>
</div>
</div>
</div>
{nameError}
</div> </div>
</div> <p>To allow signups from multiple domains, separate each with a comma.</p>
{ name_error } <p>
</div> <div className='checkbox'>
<p>To allow signups from multiple domains, separate each with a comma.</p> <label><input type='checkbox' ref='open_network' defaultChecked={this.props.state.team.type === 'O'} /> Allow anyone to signup to this domain without an invitation.</label>
<p> </div>
<div className="checkbox"><label><input type="checkbox" ref="open_network" defaultChecked={this.props.state.team.type == 'O'} /> Allow anyone to signup to this domain without an invitation.</label></div> </p>
</p> <button type='button' className='btn btn-default' onClick={this.submitBack}><i className='glyphicon glyphicon-chevron-left'></i> Back</button>&nbsp;
<button type="button" className="btn btn-default" onClick={this.submitBack}><i className="glyphicon glyphicon-chevron-left"></i> Back</button>&nbsp; <button type='submit' className='btn-primary btn' onClick={this.submitNext}>Next<i className='glyphicon glyphicon-chevron-right'></i></button>
<button type="submit" className="btn-primary btn" onClick={this.submitNext}>Next<i className="glyphicon glyphicon-chevron-right"></i></button> </form>
</form>
</div> </div>
); );
} }
@@ -370,10 +403,10 @@ AllowedDomainsPage = React.createClass({
EmailItem = React.createClass({ EmailItem = React.createClass({
getInitialState: function() { getInitialState: function() {
return { }; return {};
}, },
getValue: function() { getValue: function() {
return this.refs.email.getDOMNode().value.trim() return this.refs.email.getDOMNode().value.trim();
}, },
validate: function(teamEmail) { validate: function(teamEmail) {
var email = this.refs.email.getDOMNode().value.trim().toLowerCase(); var email = this.refs.email.getDOMNode().value.trim().toLowerCase();
@@ -383,43 +416,44 @@ EmailItem = React.createClass({
} }
if (!utils.isEmail(email)) { if (!utils.isEmail(email)) {
this.state.email_error = "Please enter a valid email address"; this.state.emailError = 'Please enter a valid email address';
this.setState(this.state); this.setState(this.state);
return false; return false;
} } else if (email === teamEmail) {
else if (email === teamEmail) { this.state.emailError = 'Please use a different email than the one used at signup';
this.state.email_error = "Please use a different email than the one used at signup";
this.setState(this.state); this.setState(this.state);
return false; return false;
} } else {
else { this.state.emailError = '';
this.state.email_error = "";
this.setState(this.state); this.setState(this.state);
return true; return true;
} }
}, },
render: function() { render: function() {
var emailError = null;
var email_error = this.state.email_error ? <label className="control-label">{ this.state.email_error }</label> : null; var emailDivClass = 'form-group';
if (this.state.emailError) {
emailError = <label className='control-label'>{ this.state.emailError }</label>;
emailDivClass += ' has-error';
}
return ( return (
<div className={ email_error ? "form-group has-error" : "form-group" }> <div className={emailDivClass}>
<input autoFocus={this.props.focus} type="email" ref="email" className="form-control" placeholder="Email Address" defaultValue={this.props.email} maxLength="128" /> <input autoFocus={this.props.focus} type='email' ref='email' className='form-control' placeholder='Email Address' defaultValue={this.props.email} maxLength='128' />
{ email_error } {emailError}
</div> </div>
); );
} }
}); });
SendInivtesPage = React.createClass({ SendInivtesPage = React.createClass({
submitBack: function (e) { submitBack: function (e) {
e.preventDefault(); e.preventDefault();
if (config.AllowSignupDomainsWizard) { if (config.AllowSignupDomainsWizard) {
this.props.state.wizard = "allowed_domains"; this.props.state.wizard = 'allowed_domains';
} else { } else {
this.props.state.wizard = "team_url"; this.props.state.wizard = 'team_url';
} }
this.props.updateParent(this.props.state); this.props.updateParent(this.props.state);
@@ -446,22 +480,22 @@ SendInivtesPage = React.createClass({
} }
if (valid) { if (valid) {
this.props.state.wizard = "username"; this.props.state.wizard = 'username';
this.props.updateParent(this.props.state); this.props.updateParent(this.props.state);
} }
}, },
submitAddInvite: function (e) { submitAddInvite: function (e) {
e.preventDefault(); e.preventDefault();
this.props.state.wizard = "send_invites"; this.props.state.wizard = 'send_invites';
if (this.props.state.invites == null || this.props.state.invites.length == 0) { if (!this.props.state.invites) {
this.props.state.invites = []; this.props.state.invites = [];
} }
this.props.state.invites.push(""); this.props.state.invites.push('');
this.props.updateParent(this.props.state); this.props.updateParent(this.props.state);
}, },
submitSkip: function (e) { submitSkip: function (e) {
e.preventDefault(); e.preventDefault();
this.props.state.wizard = "username"; this.props.state.wizard = 'username';
this.props.updateParent(this.props.state); this.props.updateParent(this.props.state);
}, },
getInitialState: function() { getInitialState: function() {
@@ -472,8 +506,6 @@ SendInivtesPage = React.createClass({
render: function() { render: function() {
client.track('signup', 'signup_team_05_send_invites'); client.track('signup', 'signup_team_05_send_invites');
var name_error = this.state.name_error ? <label className="control-label">{ this.state.name_error }</label> : null;
var content = null; var content = null;
var bottomContent = null; var bottomContent = null;
@@ -481,7 +513,7 @@ SendInivtesPage = React.createClass({
var emails = []; var emails = [];
for (var i = 0; i < this.props.state.invites.length; i++) { for (var i = 0; i < this.props.state.invites.length; i++) {
if (i == 0) { if (i === 0) {
emails.push(<EmailItem focus={true} key={i} ref={'email_' + i} email={this.props.state.invites[i]} />); emails.push(<EmailItem focus={true} key={i} ref={'email_' + i} email={this.props.state.invites[i]} />);
} else { } else {
emails.push(<EmailItem focus={false} key={i} ref={'email_' + i} email={this.props.state.invites[i]} />); emails.push(<EmailItem focus={false} key={i} ref={'email_' + i} email={this.props.state.invites[i]} />);
@@ -491,12 +523,12 @@ SendInivtesPage = React.createClass({
content = ( content = (
<div> <div>
{emails} {emails}
<div className="form-group text-right"><a href="#" onClick={this.submitAddInvite}>Add Invitation</a></div> <div className='form-group text-right'><a href='#' onClick={this.submitAddInvite}>Add Invitation</a></div>
</div> </div>
); );
bottomContent = ( bottomContent = (
<p className="color--light">{"if you prefer, you can invite " + strings.Team + " members later"}<br /> and <a href="#" onClick={this.submitSkip}>skip this step</a> for now.</p> <p className='color--light'>{'if you prefer, you can invite ' + strings.Team + ' members later'}<br /> and <a href='#' onClick={this.submitSkip}>skip this step</a> for now.</p>
); );
} else { } else {
content = ( content = (
@@ -507,14 +539,16 @@ SendInivtesPage = React.createClass({
return ( return (
<div> <div>
<form> <form>
<img className="signup-team-logo" src="/static/images/logo.png" /> <img className='signup-team-logo' src='/static/images/logo.png' />
<h2>{"Invite " + utils.toTitleCase(strings.Team) + " Members"}</h2> <h2>{'Invite ' + utils.toTitleCase(strings.Team) + ' Members'}</h2>
{content} {content}
<div className="form-group"><button type="submit" className="btn-primary btn" onClick={this.submitNext}>Next<i className="glyphicon glyphicon-chevron-right"></i></button></div> <div className='form-group'>
<button type='submit' className='btn-primary btn' onClick={this.submitNext}>Next<i className='glyphicon glyphicon-chevron-right'></i></button>
</div>
</form> </form>
{bottomContent} {bottomContent}
<div className="margin--extra"> <div className='margin--extra'>
<a href="#" onClick={this.submitBack}>Back to previous step</a> <a href='#' onClick={this.submitBack}>Back to previous step</a>
</div> </div>
</div> </div>
); );
@@ -532,12 +566,12 @@ UsernamePage = React.createClass({
var name = this.refs.name.getDOMNode().value.trim(); var name = this.refs.name.getDOMNode().value.trim();
var username_error = utils.isValidUsername(name); var usernameError = utils.isValidUsername(name);
if (username_error === 'Cannot use a reserved word as a username.') { if (usernameError === 'Cannot use a reserved word as a username.') {
this.setState({name_error: 'This username is reserved, please choose a new one.'}); this.setState({nameError: 'This username is reserved, please choose a new one.'});
return; return;
} else if (username_error) { } else if (usernameError) {
this.setState({name_error: "Username must begin with a letter, and contain 3 to 15 characters in total, which may be numbers, lowercase letters, or any of the symbols '.', '-', or '_'"}); this.setState({nameError: 'Username must begin with a letter, and contain 3 to 15 characters in total, which may be numbers, lowercase letters, or any of the symbols \'.\', \'-\', or \'_\''});
return; return;
} }
@@ -551,31 +585,36 @@ UsernamePage = React.createClass({
render: function() { render: function() {
client.track('signup', 'signup_team_06_username'); client.track('signup', 'signup_team_06_username');
var name_error = this.state.name_error ? <label className='control-label'>{this.state.name_error}</label> : null; var nameError = null;
var nameDivClass = 'form-group';
if (this.state.nameError) {
nameError = <label className='control-label'>{this.state.nameError}</label>;
nameDivClass += ' has-error';
}
return ( return (
<div> <div>
<form> <form>
<img className='signup-team-logo' src='/static/images/logo.png' /> <img className='signup-team-logo' src='/static/images/logo.png' />
<h2 className='margin--less'>Your username</h2> <h2 className='margin--less'>Your username</h2>
<h5 className='color--light'>{'Select a memorable username that makes it easy for ' + strings.Team + 'mates to identify you:'}</h5> <h5 className='color--light'>{'Select a memorable username that makes it easy for ' + strings.Team + 'mates to identify you:'}</h5>
<div className='inner__content margin--extra'> <div className='inner__content margin--extra'>
<div className={name_error ? 'form-group has-error' : 'form-group'}> <div className={nameDivClass}>
<div className='row'> <div className='row'>
<div className='col-sm-11'> <div className='col-sm-11'>
<h5><strong>Choose your username</strong></h5> <h5><strong>Choose your username</strong></h5>
<input autoFocus={true} type='text' ref='name' className='form-control' placeholder='' defaultValue={this.props.state.user.username} maxLength='128' /> <input autoFocus={true} type='text' ref='name' className='form-control' placeholder='' defaultValue={this.props.state.user.username} maxLength='128' />
<div className='color--light form__hint'>Usernames must begin with a letter and contain 3 to 15 characters made up of lowercase letters, numbers, and the symbols '.', '-' and '_'</div> <div className='color--light form__hint'>Usernames must begin with a letter and contain 3 to 15 characters made up of lowercase letters, numbers, and the symbols '.', '-' and '_'</div>
</div>
</div>
{nameError}
</div> </div>
</div> </div>
{name_error} <button type='submit' className='btn btn-primary margin--extra' onClick={this.submitNext}>Next<i className='glyphicon glyphicon-chevron-right'></i></button>
<div className='margin--extra'>
<a href='#' onClick={this.submitBack}>Back to previous step</a>
</div> </div>
</div> </form>
<button type='submit' className='btn btn-primary margin--extra' onClick={this.submitNext}>Next<i className='glyphicon glyphicon-chevron-right'></i></button>
<div className='margin--extra'>
<a href='#' onClick={this.submitBack}>Back to previous step</a>
</div>
</form>
</div> </div>
); );
} }
@@ -584,7 +623,7 @@ UsernamePage = React.createClass({
PasswordPage = React.createClass({ PasswordPage = React.createClass({
submitBack: function (e) { submitBack: function (e) {
e.preventDefault(); e.preventDefault();
this.props.state.wizard = "username"; this.props.state.wizard = 'username';
this.props.updateParent(this.props.state); this.props.updateParent(this.props.state);
}, },
submitNext: function (e) { submitNext: function (e) {
@@ -592,11 +631,11 @@ PasswordPage = React.createClass({
var password = this.refs.password.getDOMNode().value.trim(); var password = this.refs.password.getDOMNode().value.trim();
if (!password || password.length < 5) { if (!password || password.length < 5) {
this.setState({password_error: "Please enter at least 5 characters"}); this.setState({passwordError: 'Please enter at least 5 characters'});
return; return;
} }
this.setState({password_error: null, server_error: null}); this.setState({passwordError: null, serverError: null});
$('#finish-button').button('loading'); $('#finish-button').button('loading');
var teamSignup = JSON.parse(JSON.stringify(this.props.state)); var teamSignup = JSON.parse(JSON.stringify(this.props.state));
teamSignup.user.password = password; teamSignup.user.password = password;
@@ -606,13 +645,12 @@ PasswordPage = React.createClass({
client.createTeamFromSignup(teamSignup, client.createTeamFromSignup(teamSignup,
function(data) { function(data) {
client.track('signup', 'signup_team_08_complete'); client.track('signup', 'signup_team_08_complete');
var props = this.props; var props = this.props;
$('#sign-up-button').button('reset'); $('#sign-up-button').button('reset');
props.state.wizard = "finished"; props.state.wizard = 'finished';
props.updateParent(props.state, true); props.updateParent(props.state, true);
window.location.href = utils.getWindowLocationOrigin() + '/' + props.state.team.name + '/login?email=' + encodeURIComponent(teamSignup.team.email); window.location.href = utils.getWindowLocationOrigin() + '/' + props.state.team.name + '/login?email=' + encodeURIComponent(teamSignup.team.email);
@@ -625,55 +663,63 @@ PasswordPage = React.createClass({
// window.location.href = '/channels/town-square'; // window.location.href = '/channels/town-square';
// }.bind(ctl), // }.bind(ctl),
// function(err) { // function(err) {
// this.setState({name_error: err.message}); // this.setState({nameError: err.message});
// }.bind(ctl) // }.bind(ctl)
// ); // );
}.bind(this), }.bind(this),
function(err) { function(err) {
this.setState({server_error: err.message}); this.setState({serverError: err.message});
$('#sign-up-button').button('reset'); $('#sign-up-button').button('reset');
}.bind(this) }.bind(this)
); );
}, },
getInitialState: function() { getInitialState: function() {
return { }; return {};
}, },
render: function() { render: function() {
client.track('signup', 'signup_team_07_password'); client.track('signup', 'signup_team_07_password');
var password_error = this.state.password_error ? <div className="form-group has-error"><label className="control-label">{ this.state.password_error }</label></div> : null; var passwordError = null;
var server_error = this.state.server_error ? <div className="form-group has-error"><label className="control-label">{ this.state.server_error }</label></div> : 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 ( return (
<div> <div>
<form> <form>
<img className="signup-team-logo" src="/static/images/logo.png" /> <img className='signup-team-logo' src='/static/images/logo.png' />
<h2 className="margin--less">Your password</h2> <h2 className='margin--less'>Your password</h2>
<h5 className="color--light">Select a password that you'll use to login with your email address:</h5> <h5 className='color--light'>Select a password that you'll use to login with your email address:</h5>
<div className="inner__content margin--extra"> <div className='inner__content margin--extra'>
<h5><strong>Email</strong></h5> <h5><strong>Email</strong></h5>
<div className="block--gray form-group">{this.props.state.team.email}</div> <div className='block--gray form-group'>{this.props.state.team.email}</div>
<div className={ password_error ? "form-group has-error" : "form-group" }> <div className={passwordDivStyle}>
<div className="row"> <div className='row'>
<div className="col-sm-11"> <div className='col-sm-11'>
<h5><strong>Choose your password</strong></h5> <h5><strong>Choose your password</strong></h5>
<input autoFocus={true} type="password" ref="password" className="form-control" placeholder="" maxLength="128" /> <input autoFocus={true} type='password' ref='password' className='form-control' placeholder='' maxLength='128' />
<div className="color--light form__hint">Passwords must contain 5 to 50 characters. Your password will be strongest if it contains a mix of symbols, numbers, and upper and lowercase characters.</div> <div className='color--light form__hint'>Passwords must contain 5 to 50 characters. Your password will be strongest if it contains a mix of symbols, numbers, and upper and lowercase characters.</div>
</div>
</div>
{passwordError}
{serverError}
</div> </div>
</div> </div>
{ password_error } <div className='form-group'>
{ server_error } <button type='submit' className='btn btn-primary margin--extra' id='finish-button' data-loading-text={'<span class=\'glyphicon glyphicon-refresh glyphicon-refresh-animate\'></span> Creating ' + strings.Team + '...'} onClick={this.submitNext}>Finish</button>
</div> </div>
</div> <p>By proceeding to create your account and use {config.SiteName}, you agree to our <a href={config.TermsLink}>Terms of Service</a> and <a href={config.PrivacyLink}>Privacy Policy</a>. If you do not agree, you cannot use {config.SiteName}.</p>
<div className="form-group"> <div className='margin--extra'>
<button type="submit" className="btn btn-primary margin--extra" id="finish-button" data-loading-text={"<span class='glyphicon glyphicon-refresh glyphicon-refresh-animate'></span> Creating "+strings.Team+"..."} onClick={this.submitNext}>Finish</button> <a href='#' onClick={this.submitBack}>Back to previous step</a>
</div> </div>
<p>By proceeding to create your account and use { config.SiteName }, you agree to our <a href={ config.TermsLink }>Terms of Service</a> and <a href={ config.PrivacyLink }>Privacy Policy</a>. If you do not agree, you cannot use {config.SiteName}.</p> </form>
<div className="margin--extra">
<a href="#" onClick={this.submitBack}>Back to previous step</a>
</div>
</form>
</div> </div>
); );
} }
@@ -692,14 +738,14 @@ module.exports = React.createClass({
if (!props) { if (!props) {
props = {}; props = {};
props.wizard = "welcome"; props.wizard = 'welcome';
props.team = {}; props.team = {};
props.team.email = this.props.email; props.team.email = this.props.email;
props.team.allowed_domains = ""; props.team.allowed_domains = '';
props.invites = []; props.invites = [];
props.invites.push(""); props.invites.push('');
props.invites.push(""); props.invites.push('');
props.invites.push(""); props.invites.push('');
props.user = {}; props.user = {};
props.hash = this.props.hash; props.hash = this.props.hash;
props.data = this.props.data; props.data = this.props.data;
@@ -708,36 +754,34 @@ module.exports = React.createClass({
return props; return props;
}, },
render: function() { render: function() {
if (this.state.wizard == "welcome") { if (this.state.wizard === 'welcome') {
return <WelcomePage state={this.state} updateParent={this.updateParent} /> return <WelcomePage state={this.state} updateParent={this.updateParent} />;
} }
if (this.state.wizard == "team_display_name") { if (this.state.wizard === 'team_display_name') {
return <TeamDisplayNamePage state={this.state} updateParent={this.updateParent} /> return <TeamDisplayNamePage state={this.state} updateParent={this.updateParent} />;
} }
if (this.state.wizard == "team_url") { if (this.state.wizard === 'team_url') {
return <TeamURLPage state={this.state} updateParent={this.updateParent} /> return <TeamURLPage state={this.state} updateParent={this.updateParent} />;
} }
if (this.state.wizard == "allowed_domains") { if (this.state.wizard === 'allowed_domains') {
return <AllowedDomainsPage state={this.state} updateParent={this.updateParent} /> return <AllowedDomainsPage state={this.state} updateParent={this.updateParent} />;
} }
if (this.state.wizard == "send_invites") { if (this.state.wizard === 'send_invites') {
return <SendInivtesPage state={this.state} updateParent={this.updateParent} /> return <SendInivtesPage state={this.state} updateParent={this.updateParent} />;
} }
if (this.state.wizard == "username") { if (this.state.wizard === 'username') {
return <UsernamePage state={this.state} updateParent={this.updateParent} /> return <UsernamePage state={this.state} updateParent={this.updateParent} />;
} }
if (this.state.wizard == "password") { if (this.state.wizard === 'password') {
return <PasswordPage state={this.state} updateParent={this.updateParent} /> return <PasswordPage state={this.state} updateParent={this.updateParent} />;
} }
return (<div>You've already completed the signup process for this invitation or this invitation has expired.</div>); return (<div>You've already completed the signup process for this invitation or this invitation has expired.</div>);
} }
}); });

Просмотреть файл

@@ -43,14 +43,14 @@ var ActionTypes = Constants.ActionTypes;
global.window.setup_channel_page = function(team_name, team_type, team_id, channel_name, channel_id) { global.window.setup_channel_page = function(team_name, team_type, team_id, channel_name, channel_id) {
AppDispatcher.handleViewAction({ AppDispatcher.handleViewAction({
type: ActionTypes.CLICK_CHANNEL, type: ActionTypes.CLICK_CHANNEL,
name: channel_name, name: channel_name,
id: channel_id id: channel_id
}); });
AppDispatcher.handleViewAction({ AppDispatcher.handleViewAction({
type: ActionTypes.CLICK_TEAM, type: ActionTypes.CLICK_TEAM,
id: team_id id: team_id
}); });
React.render( React.render(
@@ -194,17 +194,17 @@ global.window.setup_channel_page = function(team_name, team_type, team_id, chann
); );
React.render( React.render(
<MentionList id="post_textbox" />, <MentionList id='post_textbox' />,
document.getElementById('post_mention_tab') document.getElementById('post_mention_tab')
); );
React.render( React.render(
<MentionList id="reply_textbox" />, <MentionList id='reply_textbox' />,
document.getElementById('reply_mention_tab') document.getElementById('reply_mention_tab')
); );
React.render( React.render(
<MentionList id="edit_textbox" />, <MentionList id='edit_textbox' />,
document.getElementById('edit_mention_tab') document.getElementById('edit_mention_tab')
); );

Просмотреть файл

@@ -862,8 +862,8 @@ module.exports.isEmailEnabledSynchronous = function() {
enabled = !value; enabled = !value;
}, },
error: function(xhr, status, err) { error: function(xhr, status, err) {
if (status != 200) { if (status !== '200') {
handleError("isEmailEnabled", xhr, status, err); handleError('isEmailEnabled', xhr, status, err);
} }
} }
}); });