);
}
});
TeamURLPage = React.createClass({
displayName: 'TeamURLPage',
propTypes: {
state: React.PropTypes.object,
updateParent: React.PropTypes.func
},
submitBack: function(e) {
e.preventDefault();
this.props.state.wizard = 'team_display_name';
this.props.updateParent(this.props.state);
},
submitNext: function(e) {
e.preventDefault();
var name = this.refs.name.getDOMNode().value.trim();
if (!name) {
this.setState({nameError: 'This field is required'});
return;
}
var cleanedName = utils.cleanUpUrlable(name);
var urlRegex = /^[a-z]+([a-z\-0-9]+|(__)?)[a-z0-9]+$/g;
if (cleanedName !== name || !urlRegex.test(name)) {
this.setState({nameError: "Use only lower case letters, numbers and dashes. Must start with a letter and can't end in a dash."});
return;
} else if (cleanedName.length <= 3 || cleanedName.length > 15) {
this.setState({nameError: 'Name must be 4 or more characters up to a maximum of 15'});
return;
}
for (var index = 0; index < constants.RESERVED_TEAM_NAMES.length; index++) {
if (cleanedName.indexOf(constants.RESERVED_TEAM_NAMES[index]) === 0) {
this.setState({nameError: 'This team name is unavailable'});
return;
}
}
client.findTeamByName(name,
function success(data) {
if (!data) {
if (config.AllowSignupDomainsWizard) {
this.props.state.wizard = 'allowed_domains';
} else {
this.props.state.wizard = 'send_invites';
this.props.state.team.type = 'O';
}
this.props.state.team.name = name;
this.props.updateParent(this.props.state);
} else {
this.state.nameError = 'This URL is unavailable. Please try another.';
this.setState(this.state);
}
}.bind(this),
function error(err) {
this.state.nameError = err.message;
this.setState(this.state);
}.bind(this)
);
},
getInitialState: function() {
return {};
},
handleFocus: function(e) {
e.preventDefault();
e.currentTarget.select();
},
render: function() {
$('body').tooltip({selector: '[data-toggle=tooltip]', trigger: 'hover click'});
client.track('signup', 'signup_team_03_url');
var nameError = null;
var nameDivClass = 'form-group';
if (this.state.nameError) {
nameError = ;
nameDivClass += ' has-error';
}
return (
);
}
});
AllowedDomainsPage = React.createClass({
displayName: 'AllowedDomainsPage',
propTypes: {
state: React.PropTypes.object,
updateParent: React.PropTypes.func
},
submitBack: function(e) {
e.preventDefault();
this.props.state.wizard = 'team_url';
this.props.updateParent(this.props.state);
},
submitNext: function(e) {
e.preventDefault();
if (this.refs.open_network.getDOMNode().checked) {
this.props.state.wizard = 'send_invites';
this.props.state.team.type = 'O';
this.props.updateParent(this.props.state);
return;
}
if (this.refs.allow.getDOMNode().checked) {
var name = this.refs.name.getDOMNode().value.trim();
var domainRegex = /^\w+\.\w+$/;
if (!name) {
this.setState({nameError: 'This field is required'});
return;
}
if (!name.trim().match(domainRegex)) {
this.setState({nameError: 'The domain doesn\'t appear valid'});
return;
}
this.props.state.wizard = 'send_invites';
this.props.state.team.allowed_domains = name;
this.props.state.team.type = 'I';
this.props.updateParent(this.props.state);
} else {
this.props.state.wizard = 'send_invites';
this.props.state.team.type = 'I';
this.props.updateParent(this.props.state);
}
},
getInitialState: function() {
return {};
},
render: function() {
client.track('signup', 'signup_team_04_allow_domains');
var nameError = null;
var nameDivClass = 'form-group';
if (this.state.nameError) {
nameError = ;
nameDivClass += ' has-error';
}
return (
);
}
});
EmailItem = React.createClass({
displayName: 'EmailItem',
propTypes: {
focus: React.PropTypes.bool
},
getInitialState: function() {
return {};
},
getValue: function() {
return this.refs.email.getDOMNode().value.trim();
},
validate: function(teamEmail) {
var email = this.refs.email.getDOMNode().value.trim().toLowerCase();
if (!email) {
return true;
}
if (!utils.isEmail(email)) {
this.state.emailError = 'Please enter a valid email address';
this.setState(this.state);
return false;
} else if (email === teamEmail) {
this.state.emailError = 'Please use a different email than the one used at signup';
this.setState(this.state);
return false;
}
this.state.emailError = '';
this.setState(this.state);
return true;
},
render: function() {
var emailError = null;
var emailDivClass = 'form-group';
if (this.state.emailError) {
emailError = ;
emailDivClass += ' has-error';
}
return (
{emailError}
);
}
});
SendInivtesPage = React.createClass({
displayName: 'SendInivtesPage',
propTypes: {
state: React.PropTypes.object,
updateParent: React.PropTypes.func
},
submitBack: function(e) {
e.preventDefault();
if (config.AllowSignupDomainsWizard) {
this.props.state.wizard = 'allowed_domains';
} else {
this.props.state.wizard = 'team_url';
}
this.props.updateParent(this.props.state);
},
submitNext: function(e) {
e.preventDefault();
var valid = true;
if (this.state.emailEnabled) {
var emails = [];
for (var i = 0; i < this.props.state.invites.length; i++) {
if (!this.refs['email_' + i].validate(this.props.state.team.email)) {
valid = false;
} else {
emails.push(this.refs['email_' + i].getValue());
}
}
if (valid) {
this.props.state.invites = emails;
}
}
if (valid) {
this.props.state.wizard = 'username';
this.props.updateParent(this.props.state);
}
},
submitAddInvite: function(e) {
e.preventDefault();
this.props.state.wizard = 'send_invites';
if (!this.props.state.invites) {
this.props.state.invites = [];
}
this.props.state.invites.push('');
this.props.updateParent(this.props.state);
},
submitSkip: function(e) {
e.preventDefault();
this.props.state.wizard = 'username';
this.props.updateParent(this.props.state);
},
getInitialState: function() {
return {
emailEnabled: !ConfigStore.getSettingAsBoolean('ByPassEmail', false)
};
},
render: function() {
client.track('signup', 'signup_team_05_send_invites');
var content = null;
var bottomContent = null;
if (this.state.emailEnabled) {
var emails = [];
for (var i = 0; i < this.props.state.invites.length; i++) {
if (i === 0) {
emails.push();
} else {
emails.push();
}
}
content = (
{'if you prefer, you can invite ' + strings.Team + ' members later'} and skip this step for now.
);
} else {
content = (
{'Email is currently disabled for your ' + strings.Team + ', and emails cannot be sent. Contact your system administrator to enable email and email invitations.'}
);
}
});
UsernamePage = React.createClass({
displayName: 'UsernamePage',
propTypes: {
state: React.PropTypes.object,
updateParent: React.PropTypes.func
},
submitBack: function(e) {
e.preventDefault();
this.props.state.wizard = 'send_invites';
this.props.updateParent(this.props.state);
},
submitNext: function(e) {
e.preventDefault();
var name = this.refs.name.getDOMNode().value.trim();
var usernameError = utils.isValidUsername(name);
if (usernameError === 'Cannot use a reserved word as a username.') {
this.setState({nameError: 'This username is reserved, please choose a new one.'});
return;
} else if (usernameError) {
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;
}
this.props.state.wizard = 'password';
this.props.state.user.username = name;
this.props.updateParent(this.props.state);
},
getInitialState: function() {
return {};
},
render: function() {
client.track('signup', 'signup_team_06_username');
var nameError = null;
var nameDivClass = 'form-group';
if (this.state.nameError) {
nameError = ;
nameDivClass += ' has-error';
}
return (