summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-rw-r--r--web/react/components/delete_channel_modal.jsx2
-rw-r--r--web/react/components/login.jsx130
-rw-r--r--web/react/components/msg_typing.jsx2
-rw-r--r--web/react/components/navbar.jsx104
-rw-r--r--web/react/components/new_channel.jsx6
-rw-r--r--web/react/components/password_reset.jsx79
-rw-r--r--web/react/components/rename_channel_modal.jsx6
-rw-r--r--web/react/components/rename_team_modal.jsx8
-rw-r--r--web/react/components/sidebar.jsx116
-rw-r--r--web/react/components/sidebar_header.jsx28
-rw-r--r--web/react/components/sidebar_right_menu.jsx4
-rw-r--r--web/react/components/signup_team.jsx11
-rw-r--r--web/react/components/signup_team_complete.jsx130
-rw-r--r--web/react/components/signup_user_complete.jsx7
-rw-r--r--web/react/components/team_members.jsx2
-rw-r--r--web/react/pages/channel.jsx10
-rw-r--r--web/react/pages/home.jsx7
-rw-r--r--web/react/pages/login.jsx4
-rw-r--r--web/react/pages/password_reset.jsx4
-rw-r--r--web/react/pages/signup_team_complete.jsx4
-rw-r--r--web/react/stores/browser_store.jsx2
-rw-r--r--web/react/stores/post_store.jsx12
-rw-r--r--web/react/stores/team_store.jsx9
-rw-r--r--web/react/stores/user_store.jsx29
-rw-r--r--web/react/utils/client.jsx33
-rw-r--r--web/react/utils/constants.jsx2
-rw-r--r--web/react/utils/utils.jsx26
-rw-r--r--web/sass-files/sass/partials/_headers.scss5
-rw-r--r--web/sass-files/sass/partials/_signup.scss4
-rw-r--r--web/templates/channel.html2
-rw-r--r--web/templates/home.html2
-rw-r--r--web/templates/login.html4
-rw-r--r--web/templates/password_reset.html2
-rw-r--r--web/templates/signup_team.html3
-rw-r--r--web/templates/signup_team_complete.html2
-rw-r--r--web/templates/signup_team_confirm.html1
-rw-r--r--web/templates/signup_user_complete.html2
-rw-r--r--web/web.go143
38 files changed, 338 insertions, 609 deletions
diff --git a/web/react/components/delete_channel_modal.jsx b/web/react/components/delete_channel_modal.jsx
index a8c690789..e23a37740 100644
--- a/web/react/components/delete_channel_modal.jsx
+++ b/web/react/components/delete_channel_modal.jsx
@@ -12,7 +12,7 @@ module.exports = React.createClass({
Client.deleteChannel(this.state.channel_id,
function(data) {
AsyncClient.getChannels(true);
- window.location.href = '/channels/town-square';
+ window.location.href = '/';
}.bind(this),
function(err) {
AsyncClient.dispatchError(err, "handleDelete");
diff --git a/web/react/components/login.jsx b/web/react/components/login.jsx
index 74c7d4065..71fefff5b 100644
--- a/web/react/components/login.jsx
+++ b/web/react/components/login.jsx
@@ -1,102 +1,21 @@
// 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');
+var TeamStore = require('../stores/team_store.jsx');
var BrowserStore = require('../stores/browser_store.jsx');
-
-
-var FindTeamDomain = React.createClass({
- handleSubmit: function(e) {
- e.preventDefault();
- var state = { }
-
- var domain = this.refs.domain.getDOMNode().value.trim();
- if (!domain) {
- state.server_error = "A domain is required"
- this.setState(state);
- return;
- }
-
- if (!BrowserStore.isLocalStorageSupported()) {
- state.server_error = "This service requires local storage to be enabled. Please enable it or exit private browsing.";
- this.setState(state);
- return;
- }
-
- state.server_error = "";
- this.setState(state);
-
- client.findTeamByDomain(domain,
- function(data) {
- console.log(data);
- if (data) {
- window.location.href = window.location.protocol + "//" + domain + "." + utils.getDomainWithOutSub();
- }
- else {
- this.state.server_error = "We couldn't find your " + strings.Team + ".";
- this.setState(this.state);
- }
- }.bind(this),
- function(err) {
- this.state.server_error = err.message;
- this.setState(this.state);
- }.bind(this)
- );
- },
- getInitialState: function() {
- return { };
- },
- render: function() {
- var server_error = this.state.server_error ? <label className="control-label">{this.state.server_error}</label> : null;
-
- return (
- <div className="signup-team__container">
- <div>
- <span className="signup-team__name">{ config.SiteName }</span>
- <br/>
- <span className="signup-team__subdomain">Enter your {strings.Team}'s domain.</span>
- <br/>
- <br/>
- </div>
- <form onSubmit={this.handleSubmit}>
- <div className={server_error ? 'form-group has-error' : 'form-group'}>
- { server_error }
- <input type="text" className="form-control" name="domain" ref="domain" placeholder="team domain" />
- </div>
- <div className="form-group">
- <button type="submit" className="btn btn-primary">Continue</button>
- </div>
- <div>
- <span>Don't remember your {strings.Team}'s domain? <a href="/find_team">Find it here</a></span>
- </div>
- <br/>
- <br/>
- <br/>
- <br/>
- <br/>
- <br/>
- <div>
- <span>{"Want to create your own " + strings.Team + "?"} <a href={utils.getHomeLink()} className="signup-team-login">Sign up now</a></span>
- </div>
- </form>
- </div>
- );
- }
-});
+var Constants = require('../utils/constants.jsx');
module.exports = React.createClass({
handleSubmit: function(e) {
e.preventDefault();
var state = { }
- var domain = this.refs.domain.getDOMNode().value.trim();
- if (!domain) {
- state.server_error = "A domain is required"
+ var name = this.props.teamName
+ if (!name) {
+ state.server_error = "Bad team name"
this.setState(state);
return;
}
@@ -124,23 +43,22 @@ module.exports = React.createClass({
state.server_error = "";
this.setState(state);
- client.loginByEmail(domain, email, password,
+ client.loginByEmail(name, email, password,
function(data) {
- UserStore.setLastDomain(domain);
- UserStore.setLastEmail(email);
UserStore.setCurrentUser(data);
+ UserStore.setLastEmail(email);
var redirect = utils.getUrlParameter("redirect");
if (redirect) {
- window.location.href = decodeURI(redirect);
+ window.location.pathname = decodeURI(redirect);
} else {
- window.location.href = '/channels/town-square';
+ window.location.pathname = '/' + name + '/channels/town-square';
}
}.bind(this),
function(err) {
if (err.message == "Login failed because email address has not been verified") {
- window.location.href = '/verify?domain=' + encodeURIComponent(domain) + '&email=' + encodeURIComponent(email);
+ window.location.href = '/verify_email?name=' + encodeURIComponent(name) + '&email=' + encodeURIComponent(email);
return;
}
state.server_error = err.message;
@@ -161,35 +79,35 @@ module.exports = React.createClass({
priorEmail = decodeURIComponent(emailParam);
}
- var subDomainClass = "form-control hidden";
- var subDomain = utils.getSubDomain();
+ var teamDisplayName = this.props.teamDisplayName;
+ var teamName = this.props.teamName;
- if (utils.isTestDomain()) {
- subDomainClass = "form-control";
- subDomain = UserStore.getLastDomain();
- } else if (subDomain == "") {
- return (<FindTeamDomain />);
+ var focusEmail = false;
+ var focusPassword = false;
+ if (priorEmail != "") {
+ focusPassword = true;
+ } else {
+ focusEmail = true;
}
return (
<div className="signup-team__container">
<div>
- <span className="signup-team__name">{ subDomain }</span>
+ <span className="signup-team__name">{ teamDisplayName }</span>
<br/>
- <span className="signup-team__subdomain">{ utils.getDomainWithOutSub() }</span>
+ <span className="signup-team__subdomain">/{ teamName }/</span>
<br/>
<br/>
</div>
<form onSubmit={this.handleSubmit}>
<div className={server_error ? 'form-group has-error' : 'form-group'}>
{ server_error }
- <input type="text" className={subDomainClass} name="domain" defaultValue={subDomain} ref="domain" placeholder="Domain" />
</div>
<div className={server_error ? 'form-group has-error' : 'form-group'}>
- <input type="email" className="form-control" name="email" defaultValue={priorEmail} ref="email" placeholder="Email" />
+ <input autoFocus={focusEmail} type="email" className="form-control" name="email" defaultValue={priorEmail} ref="email" placeholder="Email" />
</div>
<div className={server_error ? 'form-group has-error' : 'form-group'}>
- <input type="password" className="form-control" name="password" ref="password" placeholder="Password" />
+ <input autoFocus={focusPassword} type="password" className="form-control" name="password" ref="password" placeholder="Password" />
</div>
<div className="form-group">
<button type="submit" className="btn btn-primary">Sign in</button>
@@ -198,10 +116,10 @@ module.exports = React.createClass({
<span><a href="/find_team">{"Find other " + strings.TeamPlural}</a></span>
</div>
<div className="form-group">
- <a href="/reset_password">I forgot my password</a>
+ <a href={"/" + teamName + "/reset_password"}>I forgot my password</a>
</div>
<div className="external-link">
- <span>{"Want to create your own " + strings.Team + "?"} <a href={utils.getHomeLink()} className="signup-team-login">Sign up now</a></span>
+ <span>{"Want to create your own " + strings.Team + "?"} <a href="/" className="signup-team-login">Sign up now</a></span>
</div>
</form>
</div>
diff --git a/web/react/components/msg_typing.jsx b/web/react/components/msg_typing.jsx
index a6953028f..aacb315dd 100644
--- a/web/react/components/msg_typing.jsx
+++ b/web/react/components/msg_typing.jsx
@@ -51,7 +51,7 @@ module.exports = React.createClass({
},
render: function() {
return (
- <span className="msg-typing">{ this.state.text }</span>
+ <span className="msg-typing">{ this.state.text }</span>
);
}
});
diff --git a/web/react/components/navbar.jsx b/web/react/components/navbar.jsx
index 78cf7d8b8..34c65c34f 100644
--- a/web/react/components/navbar.jsx
+++ b/web/react/components/navbar.jsx
@@ -7,6 +7,7 @@ var client = require('../utils/client.jsx');
var AsyncClient = require('../utils/async_client.jsx');
var UserStore = require('../stores/user_store.jsx');
var ChannelStore = require('../stores/channel_store.jsx');
+var TeamStore = require('../stores/team_store.jsx');
var UserProfile = require('./user_profile.jsx');
var MessageWrapper = require('./message_wrapper.jsx');
@@ -61,93 +62,6 @@ var NotifyCounts = React.createClass({
}
});
-var NavbarLoginForm = React.createClass({
- handleSubmit: function(e) {
- e.preventDefault();
- var state = { };
-
- var domain = this.refs.domain.getDOMNode().value.trim();
- if (!domain) {
- state.server_error = "A domain is required";
- this.setState(state);
- return;
- }
-
- var email = this.refs.email.getDOMNode().value.trim();
- if (!email) {
- state.server_error = "An email is required";
- this.setState(state);
- return;
- }
-
- var password = this.refs.password.getDOMNode().value.trim();
- if (!password) {
- state.server_error = "A password is required";
- this.setState(state);
- return;
- }
-
- state.server_error = "";
- this.setState(state);
-
- client.loginByEmail(domain, email, password,
- function(data) {
- UserStore.setLastDomain(domain);
- UserStore.setLastEmail(email);
- UserStore.setCurrentUser(data);
-
- var redirect = utils.getUrlParameter("redirect");
- if (redirect) {
- window.location.href = decodeURI(redirect);
- } else {
- window.location.href = '/channels/town-square';
- }
-
- },
- function(err) {
- if (err.message == "Login failed because email address has not been verified") {
- window.location.href = '/verify?domain=' + encodeURIComponent(domain) + '&email=' + encodeURIComponent(email);
- return;
- }
- state.server_error = err.message;
- this.valid = false;
- this.setState(state);
- }.bind(this)
- );
- },
- getInitialState: function() {
- return { };
- },
- render: function() {
- var server_error = this.state.server_error ? <label className="control-label">{this.state.server_error}</label> : null;
-
- var subDomain = utils.getSubDomain();
- var subDomainClass = "form-control hidden";
-
- if (subDomain == "") {
- subDomain = UserStore.getLastDomain();
- subDomainClass = "form-control";
- }
-
- return (
- <form className="navbar-form navbar-right" onSubmit={this.handleSubmit}>
- <a href="/find_team">Find your team</a>
- <div className={server_error ? 'form-group has-error' : 'form-group'}>
- { server_error }
- <input type="text" className={subDomainClass} name="domain" defaultValue={subDomain} ref="domain" placeholder="Domain" />
- </div>
- <div className={server_error ? 'form-group has-error' : 'form-group'}>
- <input type="text" className="form-control" name="email" defaultValue={UserStore.getLastEmail()} ref="email" placeholder="Email" />
- </div>
- <div className={server_error ? 'form-group has-error' : 'form-group'}>
- <input type="password" className="form-control" name="password" ref="password" placeholder="Password" />
- </div>
- <button type="submit" className="btn btn-default">Login</button>
- </form>
- );
- }
-});
-
function getStateFromStores() {
return {
channel: ChannelStore.getCurrent(),
@@ -180,10 +94,10 @@ module.exports = React.createClass({
},
handleLeave: function(e) {
client.leaveChannel(this.state.channel.id,
- function() {
+ function(data, text, req) {
AsyncClient.getChannels(true);
- window.location.href = '/channels/town-square';
- },
+ window.location.href = TeamStore.getCurrentTeamUrl() + '/channels/town-square';
+ }.bind(this),
function(err) {
AsyncClient.dispatchError(err, "handleLeave");
}
@@ -229,7 +143,7 @@ module.exports = React.createClass({
var currentId = UserStore.getCurrentId();
var popoverContent = "";
- var channelTitle = this.props.teamName;
+ var channelTitle = this.props.teamDisplayName;
var isAdmin = false;
var isDirect = false;
var description = ""
@@ -333,14 +247,8 @@ module.exports = React.createClass({
<div className="navbar-brand">
<a href="/" className="heading">{ channelTitle }</a>
</div>
- : null }
+ : "" }
</div>
- { !currentId ?
- <div className="collapse navbar-collapse" id="navbar-collapse-1">
- <NavbarLoginForm />
- </div>
- : null
- }
</div>
</nav>
);
diff --git a/web/react/components/new_channel.jsx b/web/react/components/new_channel.jsx
index 069e0d6b1..49e088458 100644
--- a/web/react/components/new_channel.jsx
+++ b/web/react/components/new_channel.jsx
@@ -6,6 +6,8 @@ var utils = require('../utils/utils.jsx');
var client = require('../utils/client.jsx');
var asyncClient = require('../utils/async_client.jsx');
var UserStore = require('../stores/user_store.jsx');
+var TeamStore = require('../stores/team_store.jsx');
+var Constants = require('../utils/constants.jsx');
module.exports = React.createClass({
handleSubmit: function(e) {
@@ -60,13 +62,13 @@ module.exports = React.createClass({
var self = this;
client.createChannel(channel,
- function(data) {
+ function() {
this.refs.display_name.getDOMNode().value = "";
this.refs.channel_name.getDOMNode().value = "";
this.refs.channel_desc.getDOMNode().value = "";
$(self.refs.modal.getDOMNode()).modal('hide');
- window.location.href = "/channels/" + channel.name;
+ window.location = TeamStore.getCurrentTeamUrl() + "/channels/" + channel.name;
asyncClient.getChannels(true);
}.bind(this),
function(err) {
diff --git a/web/react/components/password_reset.jsx b/web/react/components/password_reset.jsx
index 24566c7b1..b2edea620 100644
--- a/web/react/components/password_reset.jsx
+++ b/web/react/components/password_reset.jsx
@@ -10,13 +10,6 @@ SendResetPasswordLink = React.createClass({
e.preventDefault();
var state = {};
- var domain = this.refs.domain.getDOMNode().value.trim();
- if (!domain) {
- state.error = "A domain is required"
- this.setState(state);
- return;
- }
-
var email = this.refs.email.getDOMNode().value.trim();
if (!email) {
state.error = "Please enter a valid email address."
@@ -29,17 +22,17 @@ SendResetPasswordLink = React.createClass({
data = {};
data['email'] = email;
- data['domain'] = domain;
+ data['name'] = this.props.teamName;
client.sendPasswordReset(data,
- function(data) {
- this.setState({ error: null, update_text: <p>A password reset link has been sent to <b>{email}</b> for your <b>{this.props.teamName}</b> team on {config.SiteName}.com.</p>, more_update_text: "Please check your inbox." });
- $(this.refs.reset_form.getDOMNode()).hide();
- }.bind(this),
- function(err) {
- this.setState({ error: err.message, update_text: null, more_update_text: null });
- }.bind(this)
- );
+ function(data) {
+ this.setState({ error: null, update_text: <p>A password reset link has been sent to <b>{email}</b> for your <b>{this.props.teamDisplayName}</b> team on {window.location.hostname}.</p>, more_update_text: "Please check your inbox." });
+ $(this.refs.reset_form.getDOMNode()).hide();
+ }.bind(this),
+ function(err) {
+ this.setState({ error: err.message, update_text: null, more_update_text: null });
+ }.bind(this)
+ );
},
getInitialState: function() {
return {};
@@ -48,24 +41,13 @@ SendResetPasswordLink = React.createClass({
var update_text = this.state.update_text ? <div className="reset-form alert alert-success">{this.state.update_text}{this.state.more_update_text}</div> : null;
var error = this.state.error ? <div className="form-group has-error"><label className="control-label">{this.state.error}</label></div> : null;
- var subDomain = utils.getSubDomain();
- var subDomainClass = "form-control hidden";
-
- if (subDomain == "") {
- subDomain = UserStore.getLastDomain();
- subDomainClass = "form-control";
- }
-
return (
<div className="col-sm-12">
<div className="signup-team__container">
<h3>Password Reset</h3>
{ update_text }
<form onSubmit={this.handleSendLink} ref="reset_form">
- <p>{"To reset your password, enter the email address you used to sign up for " + this.props.teamName + "."}</p>
- <div className="form-group">
- <input type="text" className={subDomainClass} name="domain" defaultValue={subDomain} ref="domain" placeholder="Domain" />
- </div>
+ <p>{"To reset your password, enter the email address you used to sign up for " + this.props.teamDisplayName + "."}</p>
<div className={error ? 'form-group has-error' : 'form-group'}>
<input type="text" className="form-control" name="email" ref="email" placeholder="Email" />
</div>
@@ -83,13 +65,6 @@ ResetPassword = React.createClass({
e.preventDefault();
var state = {};
- var domain = this.refs.domain.getDOMNode().value.trim();
- if (!domain) {
- state.error = "A domain is required"
- this.setState(state);
- return;
- }
-
var password = this.refs.password.getDOMNode().value.trim();
if (!password || password.length < 5) {
state.error = "Please enter at least 5 characters."
@@ -104,41 +79,30 @@ ResetPassword = React.createClass({
data['new_password'] = password;
data['hash'] = this.props.hash;
data['data'] = this.props.data;
- data['domain'] = domain;
+ data['name'] = this.props.teamName;
client.resetPassword(data,
- function(data) {
- this.setState({ error: null, update_text: "Your password has been updated successfully." });
- }.bind(this),
- function(err) {
- this.setState({ error: err.message, update_text: null });
- }.bind(this)
- );
+ function(data) {
+ this.setState({ error: null, update_text: "Your password has been updated successfully." });
+ }.bind(this),
+ function(err) {
+ this.setState({ error: err.message, update_text: null });
+ }.bind(this)
+ );
},
getInitialState: function() {
return {};
},
render: function() {
- var update_text = this.state.update_text ? <div className="form-group"><br/><label className="control-label reset-form">{this.state.update_text} Click <a href="/login">here</a> to log in.</label></div> : null;
+ var update_text = this.state.update_text ? <div className="form-group"><br/><label className="control-label reset-form">{this.state.update_text} Click <a href={"/" + this.props.teamName + "/login"}>here</a> to log in.</label></div> : null;
var error = this.state.error ? <div className="form-group has-error"><label className="control-label">{this.state.error}</label></div> : null;
- var subDomain = this.props.domain != "" ? this.props.domain : utils.getSubDomain();
- var subDomainClass = "form-control hidden";
-
- if (subDomain == "") {
- subDomain = UserStore.getLastDomain();
- subDomainClass = "form-control";
- }
-
return (
<div className="col-sm-12">
<div className="signup-team__container">
<h3>Password Reset</h3>
<form onSubmit={this.handlePasswordReset}>
- <p>{"Enter a new password for your " + this.props.teamName + " " + config.SiteName + " account."}</p>
- <div className="form-group">
- <input type="text" className={subDomainClass} name="domain" defaultValue={subDomain} ref="domain" placeholder="Domain" />
- </div>
+ <p>{"Enter a new password for your " + this.props.teamDisplayName + " " + config.SiteName + " account."}</p>
<div className={error ? 'form-group has-error' : 'form-group'}>
<input type="password" className="form-control" name="password" ref="password" placeholder="Password" />
</div>
@@ -161,14 +125,15 @@ module.exports = React.createClass({
if (this.props.isReset === "false") {
return (
<SendResetPasswordLink
+ teamDisplayName={this.props.teamDisplayName}
teamName={this.props.teamName}
/>
);
} else {
return (
<ResetPassword
+ teamDisplayName={this.props.teamDisplayName}
teamName={this.props.teamName}
- domain={this.props.domain}
hash={this.props.hash}
data={this.props.data}
/>
diff --git a/web/react/components/rename_channel_modal.jsx b/web/react/components/rename_channel_modal.jsx
index b4ccb2937..2ae331626 100644
--- a/web/react/components/rename_channel_modal.jsx
+++ b/web/react/components/rename_channel_modal.jsx
@@ -6,6 +6,8 @@ var utils = require('../utils/utils.jsx');
var Client = require('../utils/client.jsx');
var AsyncClient = require('../utils/async_client.jsx');
var ChannelStore = require('../stores/channel_store.jsx');
+var TeamStore = require('../stores/team_store.jsx');
+var Constants = require('../utils/constants.jsx');
module.exports = React.createClass({
handleSubmit: function(e) {
@@ -60,12 +62,12 @@ module.exports = React.createClass({
return;
Client.updateChannel(channel,
- function(data) {
+ function(data, text, req) {
this.refs.display_name.getDOMNode().value = "";
this.refs.channel_name.getDOMNode().value = "";
$('#' + this.props.modalId).modal('hide');
- window.location.href = '/channels/' + this.state.channel_name;
+ window.location.href = TeamStore.getCurrentTeamUrl() + '/channels/' + this.state.channel_name;
AsyncClient.getChannels(true);
}.bind(this),
function(err) {
diff --git a/web/react/components/rename_team_modal.jsx b/web/react/components/rename_team_modal.jsx
index 67a150b9d..a6da57b67 100644
--- a/web/react/components/rename_team_modal.jsx
+++ b/web/react/components/rename_team_modal.jsx
@@ -24,13 +24,13 @@ module.exports = React.createClass({
if (!valid)
return;
- if (this.props.teamName === name)
+ if (this.props.teamDisplayName === name)
return;
var data = {};
data["new_name"] = name;
- Client.updateTeamName(data,
+ Client.updateTeamDisplayName(data,
function(data) {
$('#rename_team_link').modal('hide');
window.location.reload();
@@ -47,11 +47,11 @@ module.exports = React.createClass({
componentDidMount: function() {
var self = this;
$(this.refs.modal.getDOMNode()).on('hidden.bs.modal', function(e) {
- self.setState({ name: self.props.teamName });
+ self.setState({ name: self.props.teamDisplayName });
});
},
getInitialState: function() {
- return { name: this.props.teamName };
+ return { name: this.props.teamDisplayName };
},
render: function() {
diff --git a/web/react/components/sidebar.jsx b/web/react/components/sidebar.jsx
index 65727c597..3cf67e410 100644
--- a/web/react/components/sidebar.jsx
+++ b/web/react/components/sidebar.jsx
@@ -6,6 +6,7 @@ var ChannelStore = require('../stores/channel_store.jsx');
var AsyncClient = require('../utils/async_client.jsx');
var SocketStore = require('../stores/socket_store.jsx');
var UserStore = require('../stores/user_store.jsx');
+var TeamStore = require('../stores/team_store.jsx');
var utils = require('../utils/utils.jsx');
var SidebarHeader = require('./sidebar_header.jsx');
var SearchBox = require('./search_bar.jsx');
@@ -13,93 +14,6 @@ var SearchBox = require('./search_bar.jsx');
var Constants = require('../utils/constants.jsx');
var ActionTypes = Constants.ActionTypes;
-var SidebarLoginForm = React.createClass({
- handleSubmit: function(e) {
- e.preventDefault();
- var state = { }
-
- var domain = this.refs.domain.getDOMNode().value.trim();
- if (!domain) {
- state.server_error = "A domain is required"
- this.setState(state);
- return;
- }
-
- var email = this.refs.email.getDOMNode().value.trim();
- if (!email) {
- state.server_error = "An email is required"
- this.setState(state);
- return;
- }
-
- var password = this.refs.password.getDOMNode().value.trim();
- if (!password) {
- state.server_error = "A password is required"
- this.setState(state);
- return;
- }
-
- state.server_error = "";
- this.setState(state);
-
- client.loginByEmail(domain, email, password,
- function(data) {
- UserStore.setLastDomain(domain);
- UserStore.setLastEmail(email);
- UserStore.setCurrentUser(data);
-
- var redirect = utils.getUrlParameter("redirect");
- if (redirect) {
- window.location.href = decodeURI(redirect);
- } else {
- window.location.href = '/channels/town-square';
- }
-
- }.bind(this),
- function(err) {
- if (err.message == "Login failed because email address has not been verified") {
- window.location.href = '/verify?domain=' + encodeURIComponent(domain) + '&email=' + encodeURIComponent(email);
- return;
- }
- state.server_error = err.message;
- this.valid = false;
- this.setState(state);
- }.bind(this)
- );
- },
- getInitialState: function() {
- return { };
- },
- render: function() {
- var server_error = this.state.server_error ? <label className="control-label">{this.state.server_error}</label> : null;
-
- var subDomain = utils.getSubDomain();
- var subDomainClass = "form-control hidden";
-
- if (subDomain == "") {
- subDomain = UserStore.getLastDomain();
- subDomainClass = "form-control";
- }
-
- return (
- <form className="" onSubmit={this.handleSubmit}>
- <a href="/find_team">{"Find your " + strings.Team}</a>
- <div className={server_error ? 'form-group has-error' : 'form-group'}>
- { server_error }
- <input type="text" className={subDomainClass} name="domain" defaultValue={subDomain} ref="domain" placeholder="Domain" />
- </div>
- <div className={server_error ? 'form-group has-error' : 'form-group'}>
- <input type="text" className="form-control" name="email" defaultValue={UserStore.getLastEmail()} ref="email" placeholder="Email" />
- </div>
- <div className={server_error ? 'form-group has-error' : 'form-group'}>
- <input type="password" className="form-control" name="password" ref="password" placeholder="Password" />
- </div>
- <button type="submit" className="btn btn-default">Login</button>
- </form>
- );
- }
-});
-
function getStateFromStores() {
var members = ChannelStore.getAllMembers();
var team_member_map = UserStore.getActiveOnlyProfiles();
@@ -192,7 +106,7 @@ function getStateFromStores() {
};
}
-var SidebarLoggedIn = React.createClass({
+module.exports = React.createClass({
componentDidMount: function() {
ChannelStore.addChangeListener(this._onChange);
UserStore.addChangeListener(this._onChange);
@@ -383,7 +297,7 @@ var SidebarLoggedIn = React.createClass({
);
} else {
return (
- <li key={channel.name} className={active}><a className={"sidebar-channel " + titleClass} href={"/channels/"+channel.name}><span className="status" dangerouslySetInnerHTML={{__html: statusIcon}} /> {badge}{channel.display_name}</a></li>
+ <li key={channel.name} className={active}><a className={"sidebar-channel " + titleClass} href={TeamStore.getCurrentTeamUrl() + "/channels/"+channel.name}><span className="status" dangerouslySetInnerHTML={{__html: statusIcon}} /> {badge}{channel.display_name}</a></li>
);
}
@@ -414,7 +328,7 @@ var SidebarLoggedIn = React.createClass({
}
return (
<div>
- <SidebarHeader teamName={this.props.teamName} teamType={this.props.teamType} />
+ <SidebarHeader teamDisplayName={this.props.teamDisplayName} teamType={this.props.teamType} />
<SearchBox />
<div className="nav-pills__container">
@@ -440,25 +354,3 @@ var SidebarLoggedIn = React.createClass({
);
}
});
-
-var SidebarLoggedOut = React.createClass({
- render: function() {
- return (
- <div>
- <SidebarHeader teamName={this.props.teamName} />
- <SidebarLoginForm />
- </div>
- );
- }
-});
-
-module.exports = React.createClass({
- render: function() {
- var currentId = UserStore.getCurrentId();
- if (currentId != null) {
- return <SidebarLoggedIn teamName={this.props.teamName} teamType={this.props.teamType} />;
- } else {
- return <SidebarLoggedOut teamName={this.props.teamName} />;
- }
- }
-});
diff --git a/web/react/components/sidebar_header.jsx b/web/react/components/sidebar_header.jsx
index 45c9ca629..bab2897b6 100644
--- a/web/react/components/sidebar_header.jsx
+++ b/web/react/components/sidebar_header.jsx
@@ -61,19 +61,15 @@ var NavbarDropdown = React.createClass({
var teams = [];
+ teams.push(<li className="divider" key="div"></li>);
if (this.state.teams.length > 1) {
for (var i = 0; i < this.state.teams.length; i++) {
- var domain = this.state.teams[i];
+ var teamName = this.state.teams[i];
- if (domain == utils.getSubDomain())
- continue;
-
- if (teams.length == 0)
- teams.push(<li className="divider" key="div"></li>);
-
- teams.push(<li key={ domain }><a href={window.location.protocol + "//" + domain + "." + utils.getDomainWithOutSub() }>Switch to { domain }</a></li>);
+ teams.push(<li key={ teamName }><a href={window.location.origin + "/" + teamName }>Switch to { teamName }</a></li>);
}
}
+ teams.push(<li><a href={window.location.origin + "/signup_team" }>Create a New Team</a></li>);
return (
<ul className="nav navbar-nav navbar-right">
@@ -110,19 +106,21 @@ module.exports = React.createClass({
},
render: function() {
- var me = UserStore.getCurrentUser();
-
+ var teamDisplayName = this.props.teamDisplayName ? this.props.teamDisplayName : config.SiteName;
+ var me = UserStore.getCurrentUser()
if (!me) {
return null;
}
return (
<div className="team__header theme">
- <img className="user__picture" src={"/api/v1/users/" + me.id + "/image?time=" + me.update_at} />
- <div className="header__info">
- <div className="user__name">{'@' + me.username}</div>
- <a className="team__name" href="/channels/town-square">{this.props.teamName}</a>
- </div>
+ <a className="settings_link" href="#" data-toggle="modal" data-target="#user_settings1">
+ <img className="user__picture" src={"/api/v1/users/" + me.id + "/image?time=" + me.update_at} />
+ <div className="header__info">
+ <div className="user__name">{ '@' + me.username}</div>
+ <div className="team__name">{ teamDisplayName }</div>
+ </div>
+ </a>
<NavbarDropdown teamType={this.props.teamType} />
</div>
);
diff --git a/web/react/components/sidebar_right_menu.jsx b/web/react/components/sidebar_right_menu.jsx
index 22d1d9ad2..15306a499 100644
--- a/web/react/components/sidebar_right_menu.jsx
+++ b/web/react/components/sidebar_right_menu.jsx
@@ -49,12 +49,12 @@ module.exports = React.createClass({
}
var siteName = config.SiteName != null ? config.SiteName : "";
- var teamName = this.props.teamName ? this.props.teamName : siteName;
+ var teamDisplayName = this.props.teamDisplayName ? this.props.teamDisplayName : siteName;
return (
<div>
<div className="team__header theme">
- <a className="team__name" href="/channels/town-square">{ teamName }</a>
+ <a className="team__name" href="/channels/town-square">{ teamDisplayName }</a>
</div>
<div className="nav-pills__container">
diff --git a/web/react/components/signup_team.jsx b/web/react/components/signup_team.jsx
index 22086250c..cf982cc1e 100644
--- a/web/react/components/signup_team.jsx
+++ b/web/react/components/signup_team.jsx
@@ -20,8 +20,8 @@ module.exports = React.createClass({
state.email_error = "";
}
- team.name = this.refs.name.getDOMNode().value.trim();
- if (!team.name) {
+ team.display_name = this.refs.name.getDOMNode().value.trim();
+ if (!team.display_name) {
state.name_error = "This field is required";
state.inValid = true;
}
@@ -34,7 +34,7 @@ module.exports = React.createClass({
return;
}
- client.signupTeam(team.email, team.name,
+ client.signupTeam(team.email, team.display_name,
function(data) {
if (data["follow_link"]) {
window.location.href = data["follow_link"];
@@ -61,7 +61,7 @@ module.exports = React.createClass({
return (
<form role="form" onSubmit={this.handleSubmit}>
<div className={ email_error ? "form-group has-error" : "form-group" }>
- <input type="email" ref="email" className="form-control" placeholder="Email Address" maxLength="128" />
+ <input autoFocus={true} type="email" ref="email" className="form-control" placeholder="Email Address" maxLength="128" />
{ email_error }
</div>
<div className={ name_error ? "form-group has-error" : "form-group" }>
@@ -70,6 +70,9 @@ module.exports = React.createClass({
</div>
{ server_error }
<button className="btn btn-md btn-primary" type="submit">Sign up for Free</button>
+ <div className="form-group form-group--small">
+ <span><a href="/find_team">{"Find my " + strings.Team}</a></span>
+ </div>
</form>
);
}
diff --git a/web/react/components/signup_team_complete.jsx b/web/react/components/signup_team_complete.jsx
index 9e2a13955..9ceeb6324 100644
--- a/web/react/components/signup_team_complete.jsx
+++ b/web/react/components/signup_team_complete.jsx
@@ -15,7 +15,7 @@ WelcomePage = React.createClass({
return;
}
e.preventDefault();
- this.props.state.wizard = "team_name";
+ this.props.state.wizard = "team_display_name";
this.props.updateParent(this.props.state);
},
handleDiffEmail: function (e) {
@@ -57,6 +57,17 @@ WelcomePage = React.createClass({
getInitialState: function() {
return { use_diff: false };
},
+ handleKeyPress: function(event) {
+ if (event.keyCode == 13) {
+ this.submitNext(event);
+ }
+ },
+ componentWillMount: function() {
+ document.addEventListener("keyup", this.handleKeyPress, false);
+ },
+ componentWillUnmount: function() {
+ document.removeEventListener("keyup", this.handleKeyPress, false);
+ },
render: function() {
client.track('signup', 'signup_team_01_welcome');
@@ -77,7 +88,7 @@ WelcomePage = React.createClass({
<span className="black">{ this.props.state.team.email }</span><br />
</p>
<div className="form-group">
- <button className="btn-primary btn form-group" 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 }
</div>
<hr />
@@ -92,15 +103,15 @@ WelcomePage = React.createClass({
{ email_error }
</div>
{ server_error }
- <button className="btn btn-md btn-primary" 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>
- <button onClick={this.handleDiffEmail} className={ this.state.use_diff ? "btn-default btn hidden" : "btn-default btn" }>Use a different address</button>
+ <button type="button" onClick={this.handleDiffEmail} className={ this.state.use_diff ? "btn-default btn hidden" : "btn-default btn" }>Use a different address</button>
</div>
);
}
});
-TeamNamePage = React.createClass({
+TeamDisplayNamePage = React.createClass({
submitBack: function (e) {
e.preventDefault();
this.props.state.wizard = "welcome";
@@ -109,19 +120,24 @@ TeamNamePage = React.createClass({
submitNext: function (e) {
e.preventDefault();
- var name = this.refs.name.getDOMNode().value.trim();
- if (!name) {
+ var display_name = this.refs.name.getDOMNode().value.trim();
+ if (!display_name) {
this.setState({name_error: "This field is required"});
return;
}
this.props.state.wizard = "team_url";
- this.props.state.team.name = name;
+ this.props.state.team.display_name = display_name;
this.props.updateParent(this.props.state);
},
getInitialState: function() {
return { };
},
+ handleFocus: function(e) {
+ e.preventDefault();
+
+ e.currentTarget.select();
+ },
render: function() {
client.track('signup', 'signup_team_02_name');
@@ -130,29 +146,31 @@ TeamNamePage = React.createClass({
return (
<div>
+ <form>
<img className="signup-team-logo" src="/static/images/logo.png" />
<h2>{utils.toTitleCase(strings.Team) + " Name"}</h2>
<div className={ name_error ? "form-group has-error" : "form-group" }>
<div className="row">
<div className="col-sm-9">
- <input type="text" ref="name" className="form-control" placeholder="" maxLength="128" defaultValue={this.props.state.team.name} />
+ <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>
{ name_error }
</div>
<p>{"Your " + strings.Team + " name shows in menus and headings. It may include the name of your " + strings.Company + ", but it's not required."}</p>
- <button className="btn btn-default" onClick={this.submitBack}><i className="glyphicon glyphicon-chevron-left"></i> Back</button>&nbsp;
- <button className="btn-primary btn" onClick={this.submitNext}>Next<i className="glyphicon glyphicon-chevron-right"></i></button>
+ <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>
+ </form>
</div>
);
}
});
-TeamUrlPage = React.createClass({
+TeamURLPage = React.createClass({
submitBack: function (e) {
e.preventDefault();
- this.props.state.wizard = "team_name";
+ this.props.state.wizard = "team_display_name";
this.props.updateParent(this.props.state);
},
submitNext: function (e) {
@@ -172,18 +190,18 @@ TeamUrlPage = React.createClass({
return;
}
else if (cleaned_name.length <= 3 || cleaned_name.length > 15) {
- this.setState({name_error: "Domain 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;
}
- for (var index = 0; index < constants.RESERVED_DOMAINS.length; index++) {
- if (cleaned_name.indexOf(constants.RESERVED_DOMAINS[index]) == 0) {
- this.setState({name_error: "This Team URL name is unavailable"})
+ for (var index = 0; index < constants.RESERVED_TEAM_NAMES.length; index++) {
+ if (cleaned_name.indexOf(constants.RESERVED_TEAM_NAMES[index]) == 0) {
+ this.setState({name_error: "This team name is unavailable"})
return;
}
}
- client.findTeamByDomain(name,
+ client.findTeamByName(name,
function(data) {
if (!data) {
if (config.AllowSignupDomainsWizard) {
@@ -193,7 +211,7 @@ TeamUrlPage = React.createClass({
this.props.state.team.type = 'O';
}
- this.props.state.team.domain = name;
+ this.props.state.team.name = name;
this.props.updateParent(this.props.state);
}
else {
@@ -210,6 +228,11 @@ TeamUrlPage = React.createClass({
getInitialState: function() {
return { };
},
+ handleFocus: function(e) {
+ e.preventDefault();
+
+ e.currentTarget.select();
+ },
render: function() {
client.track('signup', 'signup_team_03_url');
@@ -218,14 +241,15 @@ TeamUrlPage = React.createClass({
return (
<div>
+ <form>
<img className="signup-team-logo" src="/static/images/logo.png" />
<h2>{utils.toTitleCase(strings.Team) + " URL"}</h2>
<div className={ name_error ? "form-group has-error" : "form-group" }>
<div className="row">
<div className="col-sm-9">
<div className="input-group">
- <input type="text" ref="name" className="form-control text-right" placeholder="" maxLength="128" defaultValue={this.props.state.team.domain} />
- <span className="input-group-addon">.{ utils.getDomainWithOutSub() }</span>
+ <span className="input-group-addon">{ window.location.origin + "/" }</span>
+ <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>
@@ -233,8 +257,9 @@ TeamUrlPage = React.createClass({
</div>
<p className="black">{"Pick something short and memorable for your " + strings.Team + "'s web address."}</p>
<p>{"Your " + strings.Team + " URL can only contain lowercase letters, numbers and dashes. Also, it needs to start with a letter and cannot end in a dash."}</p>
- <button className="btn btn-default" onClick={this.submitBack}><i className="glyphicon glyphicon-chevron-left"></i> Back</button>&nbsp;
- <button className="btn-primary btn" onClick={this.submitNext}>Next<i className="glyphicon glyphicon-chevron-right"></i></button>
+ <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>
+ </form>
</div>
);
}
@@ -291,6 +316,7 @@ AllowedDomainsPage = React.createClass({
return (
<div>
+ <form>
<img className="signup-team-logo" src="/static/images/logo.png" />
<h2>Email Domain</h2>
<p>
@@ -303,7 +329,7 @@ AllowedDomainsPage = React.createClass({
<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} />
+ <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>
@@ -313,8 +339,9 @@ AllowedDomainsPage = React.createClass({
<p>
<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>
- <button className="btn btn-default" onClick={this.submitBack}><i className="glyphicon glyphicon-chevron-left"></i> Back</button>&nbsp;
- <button className="btn-primary btn" onClick={this.submitNext}>Next<i className="glyphicon glyphicon-chevron-right"></i></button>
+ <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>
+ </form>
</div>
);
}
@@ -356,7 +383,7 @@ EmailItem = React.createClass({
return (
<div className={ email_error ? "form-group has-error" : "form-group" }>
- <input 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 }
</div>
);
@@ -424,16 +451,22 @@ SendInivtesPage = React.createClass({
var emails = [];
for (var i = 0; i < this.props.state.invites.length; i++) {
- emails.push(<EmailItem key={i} ref={'email_' + i} email={this.props.state.invites[i]} />);
+ if (i == 0) {
+ emails.push(<EmailItem focus={true} key={i} ref={'email_' + i} email={this.props.state.invites[i]} />);
+ } else {
+ emails.push(<EmailItem focus={false} key={i} ref={'email_' + i} email={this.props.state.invites[i]} />);
+ }
}
return (
<div>
+ <form>
<img className="signup-team-logo" src="/static/images/logo.png" />
<h2>Send Invitations</h2>
{ emails }
- <div className="form-group"><button className="btn-default btn" onClick={this.submitAddInvite}>Add Invitation</button></div>
- <div className="form btn-default-group"><button className="btn btn-default" onClick={this.submitBack}><i className="glyphicon glyphicon-chevron-left"></i> Back</button>&nbsp;<button className="btn-primary btn" onClick={this.submitNext}>Next<i className="glyphicon glyphicon-chevron-right"></i></button></div>
+ <div className="form-group"><button type="button" className="btn-default btn" onClick={this.submitAddInvite}>Add Invitation</button></div>
+ <div className="form btn-default-group"><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></div>
+ </form>
<p>{"If you'd prefer, you can send invitations after you finish setting up the "+ strings.Team + "."}</p>
<div><a href="#" onClick={this.submitSkip}>Skip this step</a></div>
</div>
@@ -477,20 +510,22 @@ UsernamePage = React.createClass({
return (
<div>
+ <form>
<img className="signup-team-logo" src="/static/images/logo.png" />
<h2>Choose a username</h2>
<div className={ name_error ? "form-group has-error" : "form-group" }>
<div className="row">
<div className="col-sm-9">
- <input 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>
</div>
{ name_error }
</div>
<p>{"Pick something " + strings.Team + "mates will recognize. Your username is how you will appear to others."}</p>
<p>It can be made of lowercase letters and numbers.</p>
- <button className="btn btn-default" onClick={this.submitBack}><i className="glyphicon glyphicon-chevron-left"></i> Back</button>&nbsp;
- <button className="btn-primary btn" onClick={this.submitNext}>Next<i className="glyphicon glyphicon-chevron-right"></i></button>
+ <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>
+ </form>
</div>
);
}
@@ -531,18 +566,11 @@ PasswordPage = React.createClass({
props.state.wizard = "finished";
props.updateParent(props.state, true);
- if (utils.isTestDomain()) {
- UserStore.setLastDomain(teamSignup.team.domain);
- UserStore.setLastEmail(teamSignup.team.email);
- window.location.href = window.location.protocol + '//' + utils.getDomainWithOutSub() + '/login?email=' + encodeURIComponent(teamSignup.team.email);
- }
- else {
- window.location.href = window.location.protocol + '//' + teamSignup.team.domain + '.' + utils.getDomainWithOutSub() + '/login?email=' + encodeURIComponent(teamSignup.team.email);
- }
+ window.location.href = window.location.origin + '/' + props.state.team.name + '/login?email=' + encodeURIComponent(teamSignup.team.email);
// client.loginByEmail(teamSignup.team.domain, teamSignup.team.email, teamSignup.user.password,
// function(data) {
- // UserStore.setLastDomain(teamSignup.team.domain);
+ // TeamStore.setLastName(teamSignup.team.domain);
// UserStore.setLastEmail(teamSignup.team.email);
// UserStore.setCurrentUser(data);
// window.location.href = '/channels/town-square';
@@ -570,13 +598,14 @@ PasswordPage = React.createClass({
return (
<div>
+ <form>
<img className="signup-team-logo" src="/static/images/logo.png" />
<h2>Choose a password</h2>
<p>You'll use your email address ({this.props.state.team.email}) and password to log into {config.SiteName}.</p>
<div className={ name_error ? "form-group has-error" : "form-group" }>
<div className="row">
<div className="col-sm-9">
- <input type="password" ref="password" className="form-control" placeholder="" maxLength="128" />
+ <input autoFocus={true} type="password" ref="password" className="form-control" placeholder="" maxLength="128" />
</div>
</div>
{ name_error }
@@ -585,10 +614,11 @@ PasswordPage = React.createClass({
<label><input type="checkbox" ref="email_service" /> It's ok to send me occassional email with updates about the {config.SiteName} service.</label>
</div>
<div className="form-group">
- <button className="btn btn-default" onClick={this.submitBack}><i className="glyphicon glyphicon-chevron-left"></i> Back</button>&nbsp;
- <button className="btn-primary btn" id="finish-button" data-loading-text={"<span class='glyphicon glyphicon-refresh glyphicon-refresh-animate'></span> Creating "+strings.Team+"..."} onClick={this.submitNext}>Finish</button>
+ <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" id="finish-button" data-loading-text={"<span class='glyphicon glyphicon-refresh glyphicon-refresh-animate'></span> Creating "+strings.Team+"..."} onClick={this.submitNext}>Finish</button>
</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>
);
}
@@ -610,9 +640,9 @@ module.exports = React.createClass({
props.wizard = "welcome";
props.team = {};
props.team.email = this.props.email;
- props.team.name = this.props.name;
+ props.team.display_name = this.props.name;
props.team.company_name = this.props.name;
- props.team.domain = utils.cleanUpUrlable(this.props.name);
+ props.team.name = utils.cleanUpUrlable(this.props.name);
props.team.allowed_domains = "";
props.invites = [];
props.invites.push("");
@@ -630,12 +660,12 @@ module.exports = React.createClass({
return <WelcomePage state={this.state} updateParent={this.updateParent} />
}
- if (this.state.wizard == "team_name") {
- return <TeamNamePage state={this.state} updateParent={this.updateParent} />
+ if (this.state.wizard == "team_display_name") {
+ return <TeamDisplayNamePage state={this.state} updateParent={this.updateParent} />
}
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") {
diff --git a/web/react/components/signup_user_complete.jsx b/web/react/components/signup_user_complete.jsx
index d1053c778..eed323d1f 100644
--- a/web/react/components/signup_user_complete.jsx
+++ b/web/react/components/signup_user_complete.jsx
@@ -48,16 +48,17 @@ module.exports = React.createClass({
client.loginByEmail(this.props.domain, this.state.user.email, this.state.user.password,
function(data) {
- UserStore.setLastDomain(this.props.domain);
UserStore.setLastEmail(this.state.user.email);
UserStore.setCurrentUser(data);
if (this.props.hash > 0)
+ {
BrowserStore.setGlobalItem(this.props.hash, JSON.stringify({wizard: "finished"}));
- window.location.href = '/channels/town-square';
+ }
+ window.location.href = '/';
}.bind(this),
function(err) {
if (err.message == "Login failed because email address has not been verified") {
- window.location.href = "/verify?email="+ encodeURIComponent(this.state.user.email) + "&domain=" + encodeURIComponent(this.props.domain);
+ window.location.href = "/verify_email?email="+ encodeURIComponent(this.state.user.email) + "&domain=" + encodeURIComponent(this.props.domain);
} else {
this.state.server_error = err.message;
this.setState(this.state);
diff --git a/web/react/components/team_members.jsx b/web/react/components/team_members.jsx
index 6b978f88b..616fd2c99 100644
--- a/web/react/components/team_members.jsx
+++ b/web/react/components/team_members.jsx
@@ -57,7 +57,7 @@ module.exports = React.createClass({
<div className="modal-content">
<div className="modal-header">
<button type="button" className="close" data-dismiss="modal" aria-label="Close" data-reactid=".5.0.0.0.0"><span aria-hidden="true" data-reactid=".5.0.0.0.0.0">×</span></button>
- <h4 className="modal-title" id="myModalLabel">{this.props.teamName + " Members"}</h4>
+ <h4 className="modal-title" id="myModalLabel">{this.props.teamDisplayName + " Members"}</h4>
</div>
<div ref="modalBody" className="modal-body">
<div className="channel-settings">
diff --git a/web/react/pages/channel.jsx b/web/react/pages/channel.jsx
index 3aa985863..f70d60e3a 100644
--- a/web/react/pages/channel.jsx
+++ b/web/react/pages/channel.jsx
@@ -61,17 +61,17 @@ global.window.setup_channel_page = function(team_name, team_type, team_id, chann
);
React.render(
- <Navbar teamName={team_name} />,
+ <Navbar teamDisplayName={team_name} />,
document.getElementById('navbar')
);
React.render(
- <Sidebar teamName={team_name} teamType={team_type} />,
+ <Sidebar teamDisplayName={team_name} teamType={team_type} />,
document.getElementById('sidebar-left')
);
React.render(
- <RenameTeamModal teamName={team_name} />,
+ <RenameTeamModal teamDisplayName={team_name} />,
document.getElementById('rename_team_modal')
);
@@ -91,7 +91,7 @@ global.window.setup_channel_page = function(team_name, team_type, team_id, chann
);
React.render(
- <TeamMembersModal teamName={team_name} />,
+ <TeamMembersModal teamDisplayName={team_name} />,
document.getElementById('team_members_modal')
);
@@ -186,7 +186,7 @@ global.window.setup_channel_page = function(team_name, team_type, team_id, chann
);
React.render(
- <SidebarRightMenu teamName={team_name} teamType={team_type} />,
+ <SidebarRightMenu teamDisplayName={team_name} teamType={team_type} />,
document.getElementById('sidebar-menu')
);
diff --git a/web/react/pages/home.jsx b/web/react/pages/home.jsx
index 08dd32f73..b12fa4949 100644
--- a/web/react/pages/home.jsx
+++ b/web/react/pages/home.jsx
@@ -2,13 +2,14 @@
// See License.txt for license information.
var ChannelStore = require('../stores/channel_store.jsx');
+var TeamStore = require('../stores/team_store.jsx');
var Constants = require('../utils/constants.jsx');
-global.window.setup_home_page = function() {
+global.window.setup_home_page = function(teamURL) {
var last = ChannelStore.getLastVisitedName();
if (last == null || last.length === 0) {
- window.location.replace("/channels/" + Constants.DEFAULT_CHANNEL);
+ window.location = teamURL + "/channels/" + Constants.DEFAULT_CHANNEL;
} else {
- window.location.replace("/channels/" + last);
+ window.location = teamURL + "/channels/" + last;
}
}
diff --git a/web/react/pages/login.jsx b/web/react/pages/login.jsx
index a4e6b438e..8348f0b5d 100644
--- a/web/react/pages/login.jsx
+++ b/web/react/pages/login.jsx
@@ -3,9 +3,9 @@
var Login = require('../components/login.jsx');
-global.window.setup_login_page = function() {
+global.window.setup_login_page = function(teamDisplayName, teamName) {
React.render(
- <Login />,
+ <Login teamDisplayName={teamDisplayName} teamName={teamName}/>,
document.getElementById('login')
);
};
diff --git a/web/react/pages/password_reset.jsx b/web/react/pages/password_reset.jsx
index 6d0d88a10..c7a208973 100644
--- a/web/react/pages/password_reset.jsx
+++ b/web/react/pages/password_reset.jsx
@@ -3,13 +3,13 @@
var PasswordReset = require('../components/password_reset.jsx');
-global.window.setup_password_reset_page = function(is_reset, team_name, domain, hash, data) {
+global.window.setup_password_reset_page = function(is_reset, team_display_name, team_name, hash, data) {
React.render(
<PasswordReset
isReset={is_reset}
+ teamDisplayName={team_display_name}
teamName={team_name}
- domain={domain}
hash={hash}
data={data}
/>,
diff --git a/web/react/pages/signup_team_complete.jsx b/web/react/pages/signup_team_complete.jsx
index c17cbdfac..346f2ab5a 100644
--- a/web/react/pages/signup_team_complete.jsx
+++ b/web/react/pages/signup_team_complete.jsx
@@ -5,7 +5,7 @@ var SignupTeamComplete =require('../components/signup_team_complete.jsx');
global.window.setup_signup_team_complete_page = function(email, name, data, hash) {
React.render(
- <SignupTeamComplete name={name} email={email} hash={hash} data={data} />,
+ <SignupTeamComplete name={name} email={email} hash={hash} data={data}/>,
document.getElementById('signup-team-complete')
);
-}; \ No newline at end of file
+};
diff --git a/web/react/stores/browser_store.jsx b/web/react/stores/browser_store.jsx
index 4d6eb0b8d..4eed754cc 100644
--- a/web/react/stores/browser_store.jsx
+++ b/web/react/stores/browser_store.jsx
@@ -8,7 +8,7 @@ function getPrefix() {
}
// Also change model/utils.go ETAG_ROOT_VERSION
-var BROWSER_STORE_VERSION = '.3';
+var BROWSER_STORE_VERSION = '.4';
module.exports = {
_initialized: false,
diff --git a/web/react/stores/post_store.jsx b/web/react/stores/post_store.jsx
index e773bb688..5280bfe08 100644
--- a/web/react/stores/post_store.jsx
+++ b/web/react/stores/post_store.jsx
@@ -151,12 +151,12 @@ var PostStore = assign({}, EventEmitter.prototype, {
return BrowserStore.getItem("draft_" + channel_id + "_" + user_id);
},
clearDraftUploads: function() {
- BrowserStore.actionOnItemsWithPrefix("draft_", function (key, value) {
- if (value) {
- value.uploadsInProgress = 0;
- BrowserStore.setItem(key, value);
- }
- });
+ BrowserStore.actionOnItemsWithPrefix("draft_", function (key, value) {
+ if (value) {
+ value.uploadsInProgress = 0;
+ BrowserStore.setItem(key, value);
+ }
+ });
}
});
diff --git a/web/react/stores/team_store.jsx b/web/react/stores/team_store.jsx
index b7199a4a8..3f12725f8 100644
--- a/web/react/stores/team_store.jsx
+++ b/web/react/stores/team_store.jsx
@@ -57,10 +57,13 @@ var TeamStore = assign({}, EventEmitter.prototype, {
else
return null;
},
+ getCurrentTeamUrl: function() {
+ return window.location.origin + "/" + this.getCurrent().name;
+ },
storeTeam: function(team) {
- var teams = this._getTeams();
- teams[team.id] = team;
- this._storeTeams(teams);
+ var teams = this._getTeams();
+ teams[team.id] = team;
+ this._storeTeams(teams);
},
_storeTeams: function(teams) {
BrowserStore.setItem("user_teams", teams);
diff --git a/web/react/stores/user_store.jsx b/web/react/stores/user_store.jsx
index b0ea719d4..d03016c5d 100644
--- a/web/react/stores/user_store.jsx
+++ b/web/react/stores/user_store.jsx
@@ -67,9 +67,18 @@ var UserStore = assign({}, EventEmitter.prototype, {
},
setCurrentId: function(id) {
this._current_id = id;
+ if (id == null) {
+ BrowserStore.removeGlobalItem("current_user_id");
+ } else {
+ BrowserStore.setGlobalItem("current_user_id", id);
+ }
},
getCurrentId: function(skipFetch) {
- var current_id = this._current_id;
+ var current_id = this._current_id;
+
+ if (current_id == null) {
+ current_id = BrowserStore.getGlobalItem("current_user_id");
+ }
// this is a speical case to force fetch the
// current user if it's missing
@@ -92,17 +101,11 @@ var UserStore = assign({}, EventEmitter.prototype, {
return this._getProfiles()[this.getCurrentId()];
},
setCurrentUser: function(user) {
- this.saveProfile(user);
this.setCurrentId(user.id);
- },
- getLastDomain: function() {
- return BrowserStore.getItem("last_domain", '');
- },
- setLastDomain: function(domain) {
- BrowserStore.setItem("last_domain", domain);
+ this.saveProfile(user);
},
getLastEmail: function() {
- return BrowserStore.getItem("last_email", '');
+ return BrowserStore.getItem("last_email", '');
},
setLastEmail: function(email) {
BrowserStore.setItem("last_email", email);
@@ -144,18 +147,18 @@ var UserStore = assign({}, EventEmitter.prototype, {
this._storeProfiles(ps);
},
_storeProfiles: function(profiles) {
- BrowserStore.setGlobalItem("profiles", profiles);
+ BrowserStore.setItem("profiles", profiles);
var profileUsernameMap = {};
for (var id in profiles) {
profileUsernameMap[profiles[id].username] = profiles[id];
}
- BrowserStore.setGlobalItem("profileUsernameMap", profileUsernameMap);
+ BrowserStore.setItem("profileUsernameMap", profileUsernameMap);
},
_getProfiles: function() {
- return BrowserStore.getGlobalItem("profiles", {});
+ return BrowserStore.getItem("profiles", {});
},
_getProfilesUsernameMap: function() {
- return BrowserStore.getGlobalItem("profileUsernameMap", {});
+ return BrowserStore.getItem("profileUsernameMap", {});
},
setSessions: function(sessions) {
BrowserStore.setItem("sessions", sessions);
diff --git a/web/react/utils/client.jsx b/web/react/utils/client.jsx
index 11d4c2601..1c31dc5ed 100644
--- a/web/react/utils/client.jsx
+++ b/web/react/utils/client.jsx
@@ -2,6 +2,7 @@
// See License.txt for license information.
var BrowserStore = require('../stores/browser_store.jsx');
+var TeamStore = require('../stores/team_store.jsx');
module.exports.track = function(category, action, label, prop, val) {
global.window.snowplow('trackStructEvent', category, action, label, prop, val);
@@ -44,7 +45,12 @@ function handleError(method_name, xhr, status, err) {
module.exports.track('api', 'api_weberror', method_name, 'message', msg);
if (xhr.status == 401) {
- window.location.href = '/login?redirect=' + encodeURIComponent(window.location.pathname+window.location.search);
+ if (window.location.href.indexOf("/channels") === 0) {
+ window.location.pathname = '/login?redirect=' + encodeURIComponent(window.location.pathname+window.location.search);
+ } else {
+ var teamURL = window.location.href.split('/channels')[0];
+ window.location.href = teamURL + '/login?redirect=' + encodeURIComponent(window.location.pathname+window.location.search);
+ }
}
return e;
@@ -205,17 +211,18 @@ module.exports.resetPassword = function(data, success, error) {
module.exports.logout = function() {
module.exports.track('api', 'api_users_logout');
- BrowserStore.clear();
- window.location.href = "/logout";
+ var currentTeamUrl = TeamStore.getCurrentTeamUrl();
+ BrowserStore.clear();
+ window.location.href = currentTeamUrl + "/logout";
};
-module.exports.loginByEmail = function(domain, email, password, success, error) {
+module.exports.loginByEmail = function(name, email, password, success, error) {
$.ajax({
url: "/api/v1/users/login",
dataType: 'json',
contentType: 'application/json',
type: 'POST',
- data: JSON.stringify({domain: domain, email: email, password: password}),
+ data: JSON.stringify({name: name, email: email, password: password}),
success: function(data, textStatus, xhr) {
module.exports.track('api', 'api_users_login_success', data.team_id, 'email', data.email);
success(data, textStatus, xhr);
@@ -317,7 +324,7 @@ module.exports.inviteMembers = function(data, success, error) {
module.exports.track('api', 'api_teams_invite_members');
};
-module.exports.updateTeamName = function(data, success, error) {
+module.exports.updateTeamDisplayName = function(data, success, error) {
$.ajax({
url: "/api/v1/teams/update_name",
dataType: 'json',
@@ -326,7 +333,7 @@ module.exports.updateTeamName = function(data, success, error) {
data: JSON.stringify(data),
success: success,
error: function(xhr, status, err) {
- e = handleError("updateTeamName", xhr, status, err);
+ e = handleError("updateTeamDisplayName", xhr, status, err);
error(e);
}
});
@@ -334,13 +341,13 @@ module.exports.updateTeamName = function(data, success, error) {
module.exports.track('api', 'api_teams_update_name');
};
-module.exports.signupTeam = function(email, name, success, error) {
+module.exports.signupTeam = function(email, display_name, success, error) {
$.ajax({
url: "/api/v1/teams/signup",
dataType: 'json',
contentType: 'application/json',
type: 'POST',
- data: JSON.stringify({email: email, name: name}),
+ data: JSON.stringify({email: email, display_name: display_name}),
success: success,
error: function(xhr, status, err) {
e = handleError("singupTeam", xhr, status, err);
@@ -366,16 +373,16 @@ module.exports.createTeam = function(team, success, error) {
});
};
-module.exports.findTeamByDomain = function(domain, success, error) {
+module.exports.findTeamByName = function(teamName, success, error) {
$.ajax({
- url: "/api/v1/teams/find_team_by_domain",
+ url: "/api/v1/teams/find_team_by_name",
dataType: 'json',
contentType: 'application/json',
type: 'POST',
- data: JSON.stringify({domain: domain}),
+ data: JSON.stringify({name: teamName}),
success: success,
error: function(xhr, status, err) {
- e = handleError("findTeamByDomain", xhr, status, err);
+ e = handleError("findTeamByName", xhr, status, err);
error(e);
}
});
diff --git a/web/react/utils/constants.jsx b/web/react/utils/constants.jsx
index 3aadfb4b0..187e3c4a3 100644
--- a/web/react/utils/constants.jsx
+++ b/web/react/utils/constants.jsx
@@ -54,7 +54,7 @@ module.exports = {
DEFAULT_CHANNEL: 'town-square',
OFFTOPIC_CHANNEL: 'off-topic',
POST_CHUNK_SIZE: 60,
- RESERVED_DOMAINS: [
+ RESERVED_TEAM_NAMES: [
"www",
"web",
"admin",
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index 416ea5ae4..00580af6e 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -16,10 +16,10 @@ module.exports.isEmail = function(email) {
};
module.exports.cleanUpUrlable = function(input) {
- var cleaned = input.trim().replace(/-/g, ' ').replace(/[^\w\s]/gi, '').toLowerCase().replace(/\s/g, '-');
- cleaned = cleaned.replace(/^\-+/, '');
- cleaned = cleaned.replace(/\-+$/, '');
- return cleaned;
+ var cleaned = input.trim().replace(/-/g, ' ').replace(/[^\w\s]/gi, '').toLowerCase().replace(/\s/g, '-');
+ cleaned = cleaned.replace(/^\-+/, '');
+ cleaned = cleaned.replace(/\-+$/, '');
+ return cleaned;
};
@@ -114,7 +114,7 @@ module.exports.notifyMe = function(title, body, channel) {
if (channel) {
module.exports.switchChannel(channel);
} else {
- window.location.href = "/channels/town-square";
+ window.location.href = "/";
}
};
setTimeout(function(){
@@ -708,8 +708,8 @@ module.exports.switchChannel = function(channel, teammate_name) {
id: channel.id
});
- var domain = window.location.href.split('/channels')[0];
- history.replaceState('data', '', domain + '/channels/' + channel.name);
+ var teamURL = window.location.href.split('/channels')[0];
+ history.replaceState('data', '', teamURL + '/channels/' + channel.name);
if (channel.type === 'D' && teammate_name) {
document.title = teammate_name + " " + document.title.substring(document.title.lastIndexOf("-"));
@@ -784,18 +784,6 @@ Image.prototype.load = function(url, progressCallback) {
Image.prototype.completedPercentage = 0;
-module.exports.getHomeLink = function() {
- if (config.HomeLink != "") {
- return config.HomeLink;
- }
- var parts = window.location.host.split(".");
- if (parts.length <= 1) {
- return window.location.protocol + "//" + window.location.host;
- }
- parts[0] = "www";
- return window.location.protocol + "//" + parts.join(".");
-}
-
module.exports.changeColor =function(col, amt) {
var usePound = false;
diff --git a/web/sass-files/sass/partials/_headers.scss b/web/sass-files/sass/partials/_headers.scss
index c2740891a..adeaa70d7 100644
--- a/web/sass-files/sass/partials/_headers.scss
+++ b/web/sass-files/sass/partials/_headers.scss
@@ -98,6 +98,9 @@
fill: #fff;
}
}
+ .settings__link a:hover, a:visited, a:link, a:active {
+ text-decoration: none;
+ }
.user__picture {
width: 36px;
height: 36px;
@@ -248,4 +251,4 @@
margin-top: 8px;
fill: #AAA;
}
-} \ No newline at end of file
+}
diff --git a/web/sass-files/sass/partials/_signup.scss b/web/sass-files/sass/partials/_signup.scss
index a714aa44f..98931279b 100644
--- a/web/sass-files/sass/partials/_signup.scss
+++ b/web/sass-files/sass/partials/_signup.scss
@@ -6,7 +6,7 @@
}
.signup-team__container {
padding: 100px 0px 50px 0px;
- max-width: 340px;
+ max-width: 600px;
margin: 0 auto;
font-size: 1.1em;
position: relative;
@@ -118,4 +118,4 @@
.signup-team-login {
padding-bottom: 10px;
font-weight: 700;
-} \ No newline at end of file
+}
diff --git a/web/templates/channel.html b/web/templates/channel.html
index d96aee3d4..eaf0f2563 100644
--- a/web/templates/channel.html
+++ b/web/templates/channel.html
@@ -46,7 +46,7 @@
<div id="direct_channel_modal"></div>
<div id="channel_info_modal"></div>
<script>
-window.setup_channel_page('{{ .Props.TeamName }}', '{{ .Props.TeamType }}', '{{ .Props.TeamId }}', '{{ .Props.ChannelName }}', '{{ .Props.ChannelId }}');
+window.setup_channel_page('{{ .Props.TeamDisplayName }}', '{{ .Props.TeamType }}', '{{ .Props.TeamId }}', '{{ .Props.ChannelName }}', '{{ .Props.ChannelId }}');
</script>
</body>
</html>
diff --git a/web/templates/home.html b/web/templates/home.html
index abf8062f2..9ec8b7000 100644
--- a/web/templates/home.html
+++ b/web/templates/home.html
@@ -17,7 +17,7 @@
</div>
</div>
<script>
- window.setup_home_page();
+ window.setup_home_page({{.Props.TeamURL}});
</script>
</body>
</html>
diff --git a/web/templates/login.html b/web/templates/login.html
index c107e1ad5..24cebec8f 100644
--- a/web/templates/login.html
+++ b/web/templates/login.html
@@ -7,7 +7,7 @@
<div class="inner__wrap">
<div class="row content">
<div class="signup-header">
- {{.Props.TeamName}}
+ {{.Props.TeamDisplayName}}
</div>
<div class="col-sm-12">
<div id="login"></div>
@@ -20,7 +20,7 @@
</div>
</div>
<script>
- window.setup_login_page();
+window.setup_login_page({{.Props.TeamDisplayName}}, {{.Props.TeamName}});
</script>
</body>
</html>
diff --git a/web/templates/password_reset.html b/web/templates/password_reset.html
index 8b63556b1..6244f6418 100644
--- a/web/templates/password_reset.html
+++ b/web/templates/password_reset.html
@@ -9,7 +9,7 @@
</div>
</div>
<script>
- window.setup_password_reset_page('{{ .Props.IsReset }}', '{{ .Props.TeamName }}', '{{ .Props.Domain }}', '{{ .Props.Hash }}', '{{ .Props.Data }}');
+ window.setup_password_reset_page('{{ .Props.IsReset }}', '{{ .Props.TeamDisplayName }}', '{{ .Props.TeamName }}', '{{ .Props.Hash }}', '{{ .Props.Data }}');
</script>
</body>
</html>
diff --git a/web/templates/signup_team.html b/web/templates/signup_team.html
index fad332bee..b86590589 100644
--- a/web/templates/signup_team.html
+++ b/web/templates/signup_team.html
@@ -12,7 +12,6 @@
<h2>All team communication in one place, searchable and accessible anywhere</h2>
<h4 class="text--light">{{ .SiteName }} is free for an unlimited time, for unlimited users </h4 class="text--light">
<div id="signup-team"></div>
- <a class="signup-team-login" href="/login">or Sign In</a>
</div>
</div>
<div class="footer-push"></div>
@@ -23,7 +22,7 @@
</div>
</div>
<script>
- window.setup_signup_team_page();
+window.setup_signup_team_page();
</script>
</body>
</html>
diff --git a/web/templates/signup_team_complete.html b/web/templates/signup_team_complete.html
index 59f49cdbd..674e54ee2 100644
--- a/web/templates/signup_team_complete.html
+++ b/web/templates/signup_team_complete.html
@@ -19,7 +19,7 @@
</div>
</div>
<script>
- window.setup_signup_team_complete_page('{{.Props.Email}}', '{{.Props.Name}}', '{{.Props.Data}}', '{{.Props.Hash}}');
+window.setup_signup_team_complete_page('{{.Props.Email}}', '{{.Props.DisplayName}}', '{{.Props.Data}}', '{{.Props.Hash}}');
</script>
</body>
</html>
diff --git a/web/templates/signup_team_confirm.html b/web/templates/signup_team_confirm.html
index 9e21126da..3a6134af3 100644
--- a/web/templates/signup_team_confirm.html
+++ b/web/templates/signup_team_confirm.html
@@ -8,7 +8,6 @@
<div class="row content">
<div class="col-sm-12">
<div class="signup-team__container">
- <p>Did you mean to sign-in rather than sign up? Sign in <a href="/login">here</a>. </p>
<h3>Sign up Complete</h3>
<p>Please check your email: {{ .Props.Email }}<br>
You email contains a link to set up your team</p>
diff --git a/web/templates/signup_user_complete.html b/web/templates/signup_user_complete.html
index 5fe907ba7..0cc655b63 100644
--- a/web/templates/signup_user_complete.html
+++ b/web/templates/signup_user_complete.html
@@ -19,7 +19,7 @@
</div>
</div>
<script>
- window.setup_signup_user_complete_page('{{.Props.Email}}', '{{.Props.TeamDomain}}', '{{.Props.TeamName}}', '{{.Props.TeamId}}', '{{.Props.Data}}', '{{.Props.Hash}}');
+ window.setup_signup_user_complete_page('{{.Props.Email}}', '{{.Props.TeamName}}', '{{.Props.TeamDisplayName}}', '{{.Props.TeamId}}', '{{.Props.Data}}', '{{.Props.Hash}}');
</script>
</body>
</html>
diff --git a/web/web.go b/web/web.go
index b11e6e6b1..3e4bc2d53 100644
--- a/web/web.go
+++ b/web/web.go
@@ -42,25 +42,28 @@ func (me *HtmlTemplatePage) Render(c *api.Context, w http.ResponseWriter) {
func InitWeb() {
l4g.Debug("Initializing web routes")
+ mainrouter := api.Srv.Router
+
staticDir := utils.FindDir("web/static")
l4g.Debug("Using static directory at %v", staticDir)
- api.Srv.Router.PathPrefix("/static/").Handler(http.StripPrefix("/static/",
- http.FileServer(http.Dir(staticDir))))
-
- api.Srv.Router.Handle("/", api.AppHandler(root)).Methods("GET")
- api.Srv.Router.Handle("/login", api.AppHandler(login)).Methods("GET")
- api.Srv.Router.Handle("/signup_team_confirm/", api.AppHandler(signupTeamConfirm)).Methods("GET")
- api.Srv.Router.Handle("/signup_team_complete/", api.AppHandler(signupTeamComplete)).Methods("GET")
- api.Srv.Router.Handle("/signup_user_complete/", api.AppHandler(signupUserComplete)).Methods("GET")
-
- api.Srv.Router.Handle("/logout", api.AppHandler(logout)).Methods("GET")
-
- api.Srv.Router.Handle("/verify", api.AppHandler(verifyEmail)).Methods("GET")
- api.Srv.Router.Handle("/find_team", api.AppHandler(findTeam)).Methods("GET")
- api.Srv.Router.Handle("/reset_password", api.AppHandler(resetPassword)).Methods("GET")
-
- csr := api.Srv.Router.PathPrefix("/channels").Subrouter()
- csr.Handle("/{name:[A-Za-z0-9-]+(__)?[A-Za-z0-9-]+}", api.UserRequired(getChannel)).Methods("GET")
+ mainrouter.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir(staticDir))))
+
+ mainrouter.Handle("/", api.AppHandlerIndependent(root)).Methods("GET")
+ mainrouter.Handle("/{team:[A-Za-z0-9-]+(__)?[A-Za-z0-9-]+}", api.AppHandler(login)).Methods("GET")
+ mainrouter.Handle("/{team:[A-Za-z0-9-]+(__)?[A-Za-z0-9-]+}/", api.AppHandler(login)).Methods("GET")
+ mainrouter.Handle("/{team:[A-Za-z0-9-]+(__)?[A-Za-z0-9-]+}/login", api.AppHandler(login)).Methods("GET")
+ mainrouter.Handle("/{team:[A-Za-z0-9-]+(__)?[A-Za-z0-9-]+}/logout", api.AppHandler(logout)).Methods("GET")
+ mainrouter.Handle("/{team:[A-Za-z0-9-]+(__)?[A-Za-z0-9-]+}/reset_password", api.AppHandler(resetPassword)).Methods("GET")
+ // Bug in gorilla.mux pervents us from using regex here.
+ mainrouter.Handle("/{team}/channels/{channelname}", api.UserRequired(getChannel)).Methods("GET")
+
+ // Anything added here must have an _ in it so it does not conflict with team names
+ mainrouter.Handle("/signup_team_complete/", api.AppHandlerIndependent(signupTeamComplete)).Methods("GET")
+ mainrouter.Handle("/signup_user_complete/", api.AppHandlerIndependent(signupUserComplete)).Methods("GET")
+ mainrouter.Handle("/signup_team_confirm/", api.AppHandlerIndependent(signupTeamConfirm)).Methods("GET")
+ mainrouter.Handle("/verify_email", api.AppHandlerIndependent(verifyEmail)).Methods("GET")
+ mainrouter.Handle("/find_team", api.AppHandlerIndependent(findTeam)).Methods("GET")
+ mainrouter.Handle("/signup_team", api.AppHandlerIndependent(signup)).Methods("GET")
watchAndParseTemplates()
}
@@ -128,46 +131,53 @@ func root(c *api.Context, w http.ResponseWriter, r *http.Request) {
}
if len(c.Session.UserId) == 0 {
- if api.IsTestDomain(r) || strings.Index(r.Host, "www") == 0 || strings.Index(r.Host, "beta") == 0 || strings.Index(r.Host, "ci") == 0 {
- page := NewHtmlTemplatePage("signup_team", "Signup")
- page.Render(c, w)
- } else {
- login(c, w, r)
- }
+ page := NewHtmlTemplatePage("signup_team", "Signup")
+ page.Render(c, w)
} else {
page := NewHtmlTemplatePage("home", "Home")
+ page.Props["TeamURL"] = c.GetTeamURL()
page.Render(c, w)
}
}
-func login(c *api.Context, w http.ResponseWriter, r *http.Request) {
+func signup(c *api.Context, w http.ResponseWriter, r *http.Request) {
+
if !CheckBrowserCompatability(c, r) {
return
}
- teamName := "Beta"
- teamDomain := ""
- siteDomain := "." + utils.Cfg.ServiceSettings.Domain
+ page := NewHtmlTemplatePage("signup_team", "Signup")
+ page.Render(c, w)
+}
+
+func login(c *api.Context, w http.ResponseWriter, r *http.Request) {
+ if !CheckBrowserCompatability(c, r) {
+ return
+ }
+ params := mux.Vars(r)
+ teamName := params["team"]
- if utils.Cfg.ServiceSettings.Mode == utils.MODE_DEV {
- teamDomain = "developer"
- } else if utils.Cfg.ServiceSettings.Mode == utils.MODE_BETA {
- teamDomain = "beta"
+ var team *model.Team
+ if tResult := <-api.Srv.Store.Team().GetByName(teamName); tResult.Err != nil {
+ l4g.Error("Couldn't find team name=%v, teamURL=%v, err=%v", teamName, c.GetTeamURL(), tResult.Err.Message)
+ // This should probably do somthing nicer
+ http.Redirect(w, r, "http://"+r.Host, http.StatusTemporaryRedirect)
+ return
} else {
- teamDomain, siteDomain = model.GetSubDomain(c.TeamUrl)
- siteDomain = "." + siteDomain + ".com"
+ team = tResult.Data.(*model.Team)
+ }
- if tResult := <-api.Srv.Store.Team().GetByDomain(teamDomain); tResult.Err != nil {
- l4g.Error("Couldn't find team teamDomain=%v, siteDomain=%v, teamUrl=%v, err=%v", teamDomain, siteDomain, c.TeamUrl, tResult.Err.Message)
- } else {
- teamName = tResult.Data.(*model.Team).Name
- }
+ // If we are already logged into this team then go to home
+ if len(c.Session.UserId) != 0 && c.Session.TeamId == team.Id {
+ page := NewHtmlTemplatePage("home", "Home")
+ page.Props["TeamURL"] = c.GetTeamURL()
+ page.Render(c, w)
+ return
}
page := NewHtmlTemplatePage("login", "Login")
+ page.Props["TeamDisplayName"] = team.DisplayName
page.Props["TeamName"] = teamName
- page.Props["TeamDomain"] = teamDomain
- page.Props["SiteDomain"] = siteDomain
page.Render(c, w)
}
@@ -198,7 +208,7 @@ func signupTeamComplete(c *api.Context, w http.ResponseWriter, r *http.Request)
page := NewHtmlTemplatePage("signup_team_complete", "Complete Team Sign Up")
page.Props["Email"] = props["email"]
- page.Props["Name"] = props["name"]
+ page.Props["DisplayName"] = props["display_name"]
page.Props["Data"] = data
page.Props["Hash"] = hash
page.Render(c, w)
@@ -225,8 +235,8 @@ func signupUserComplete(c *api.Context, w http.ResponseWriter, r *http.Request)
}
props["email"] = ""
+ props["display_name"] = team.DisplayName
props["name"] = team.Name
- props["domain"] = team.Domain
props["id"] = team.Id
data = model.MapToJson(props)
hash = ""
@@ -249,8 +259,8 @@ func signupUserComplete(c *api.Context, w http.ResponseWriter, r *http.Request)
page := NewHtmlTemplatePage("signup_user_complete", "Complete User Sign Up")
page.Props["Email"] = props["email"]
+ page.Props["TeamDisplayName"] = props["display_name"]
page.Props["TeamName"] = props["name"]
- page.Props["TeamDomain"] = props["domain"]
page.Props["TeamId"] = props["id"]
page.Props["Data"] = data
page.Props["Hash"] = hash
@@ -259,12 +269,12 @@ func signupUserComplete(c *api.Context, w http.ResponseWriter, r *http.Request)
func logout(c *api.Context, w http.ResponseWriter, r *http.Request) {
api.Logout(c, w, r)
- http.Redirect(w, r, "/", http.StatusFound)
+ http.Redirect(w, r, c.GetTeamURL(), http.StatusFound)
}
func getChannel(c *api.Context, w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r)
- name := params["name"]
+ name := params["channelname"]
var channelId string
if result := <-api.Srv.Store.Channel().CheckPermissionsToByName(c.Session.TeamId, name, c.Session.UserId); result.Err != nil {
@@ -304,7 +314,7 @@ func getChannel(c *api.Context, w http.ResponseWriter, r *http.Request) {
//api.Handle404(w, r)
//Bad channel urls just redirect to the town-square for now
- http.Redirect(w, r, "/channels/town-square", http.StatusFound)
+ http.Redirect(w, r, c.GetTeamURL()+"/channels/town-square", http.StatusFound)
return
}
}
@@ -319,8 +329,8 @@ func getChannel(c *api.Context, w http.ResponseWriter, r *http.Request) {
}
page := NewHtmlTemplatePage("channel", "")
- page.Title = name + " - " + team.Name + " " + page.SiteName
- page.Props["TeamName"] = team.Name
+ page.Title = name + " - " + team.DisplayName + " " + page.SiteName
+ page.Props["TeamDisplayName"] = team.DisplayName
page.Props["TeamType"] = team.Type
page.Props["TeamId"] = team.Id
page.Props["ChannelName"] = name
@@ -331,7 +341,7 @@ func getChannel(c *api.Context, w http.ResponseWriter, r *http.Request) {
func verifyEmail(c *api.Context, w http.ResponseWriter, r *http.Request) {
resend := r.URL.Query().Get("resend")
- domain := r.URL.Query().Get("domain")
+ name := r.URL.Query().Get("name")
email := r.URL.Query().Get("email")
hashedId := r.URL.Query().Get("hid")
userId := r.URL.Query().Get("uid")
@@ -339,7 +349,7 @@ func verifyEmail(c *api.Context, w http.ResponseWriter, r *http.Request) {
if resend == "true" {
teamId := ""
- if result := <-api.Srv.Store.Team().GetByDomain(domain); result.Err != nil {
+ if result := <-api.Srv.Store.Team().GetByName(name); result.Err != nil {
c.Err = result.Err
return
} else {
@@ -351,7 +361,7 @@ func verifyEmail(c *api.Context, w http.ResponseWriter, r *http.Request) {
return
} else {
user := result.Data.(*model.User)
- api.FireAndForgetVerifyEmail(user.Id, user.FirstName, user.Email, domain, c.TeamUrl)
+ api.FireAndForgetVerifyEmail(user.Id, strings.Split(user.Nickname, " ")[0], user.Email, name, c.GetTeamURL())
http.Redirect(w, r, "/", http.StatusFound)
return
}
@@ -387,6 +397,8 @@ func resetPassword(c *api.Context, w http.ResponseWriter, r *http.Request) {
isResetLink := true
hash := r.URL.Query().Get("h")
data := r.URL.Query().Get("d")
+ params := mux.Vars(r)
+ teamName := params["team"]
if len(hash) == 0 || len(data) == 0 {
isResetLink = false
@@ -405,30 +417,25 @@ func resetPassword(c *api.Context, w http.ResponseWriter, r *http.Request) {
}
}
- teamName := "Developer/Beta"
- domain := ""
- if utils.Cfg.ServiceSettings.Mode != utils.MODE_DEV {
- domain, _ = model.GetSubDomain(c.TeamUrl)
-
- var team *model.Team
- if tResult := <-api.Srv.Store.Team().GetByDomain(domain); tResult.Err != nil {
- c.Err = tResult.Err
- return
- } else {
- team = tResult.Data.(*model.Team)
- }
+ teamDisplayName := "Developer/Beta"
+ var team *model.Team
+ if tResult := <-api.Srv.Store.Team().GetByName(teamName); tResult.Err != nil {
+ c.Err = tResult.Err
+ return
+ } else {
+ team = tResult.Data.(*model.Team)
+ }
- if team != nil {
- teamName = team.Name
- }
+ if team != nil {
+ teamDisplayName = team.DisplayName
}
page := NewHtmlTemplatePage("password_reset", "")
page.Title = "Reset Password - " + page.SiteName
- page.Props["TeamName"] = teamName
+ page.Props["TeamDisplayName"] = teamDisplayName
page.Props["Hash"] = hash
page.Props["Data"] = data
- page.Props["Domain"] = domain
+ page.Props["TeamName"] = teamName
page.Props["IsReset"] = strconv.FormatBool(isResetLink)
page.Render(c, w)
}