Changing the way we mattermost handles URLs. team.domain.com becomes domain.com/team.
Renaming team.Name to team.DisplayName and team.Domain to team.Name. So: team.Name -> url safe name. team.DisplayName -> nice name for users
Этот коммит содержится в:
@@ -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>
|
||||
|
||||
Ссылка в новой задаче
Block a user