Fixing signup flow. Better root redirect. Fixes back buttons.
Этот коммит содержится в:
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
import $ from 'jquery';
|
import $ from 'jquery';
|
||||||
import * as GlobalActions from 'action_creators/global_actions.jsx';
|
import * as GlobalActions from 'action_creators/global_actions.jsx';
|
||||||
|
import * as Client from 'utils/client.jsx';
|
||||||
import BrowserStore from 'stores/browser_store.jsx';
|
import BrowserStore from 'stores/browser_store.jsx';
|
||||||
import LocalizationStore from 'stores/localization_store.jsx';
|
import LocalizationStore from 'stores/localization_store.jsx';
|
||||||
|
|
||||||
@@ -12,6 +13,8 @@ import React from 'react';
|
|||||||
|
|
||||||
import FastClick from 'fastclick';
|
import FastClick from 'fastclick';
|
||||||
|
|
||||||
|
import {browserHistory} from 'react-router';
|
||||||
|
|
||||||
export default class Root extends React.Component {
|
export default class Root extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
@@ -21,10 +24,25 @@ export default class Root extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.localizationChanged = this.localizationChanged.bind(this);
|
this.localizationChanged = this.localizationChanged.bind(this);
|
||||||
|
this.redirectIfNecessary = this.redirectIfNecessary.bind(this);
|
||||||
}
|
}
|
||||||
localizationChanged() {
|
localizationChanged() {
|
||||||
this.setState({locale: LocalizationStore.getLocale(), translations: LocalizationStore.getTranslations()});
|
this.setState({locale: LocalizationStore.getLocale(), translations: LocalizationStore.getTranslations()});
|
||||||
}
|
}
|
||||||
|
redirectIfNecessary(props) {
|
||||||
|
if (props.location.pathname === '/') {
|
||||||
|
Client.getMeLoggedIn((data) => {
|
||||||
|
if (!data || data.logged_in === 'false') {
|
||||||
|
browserHistory.push('/signup_team');
|
||||||
|
} else {
|
||||||
|
browserHistory.push('/' + data.team_name + '/channels/town-square');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
componentWillReceiveProps(newProps) {
|
||||||
|
this.redirectIfNecessary(newProps);
|
||||||
|
}
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
// Setup localization listener
|
// Setup localization listener
|
||||||
LocalizationStore.addChangeListener(this.localizationChanged);
|
LocalizationStore.addChangeListener(this.localizationChanged);
|
||||||
@@ -70,12 +88,15 @@ export default class Root extends React.Component {
|
|||||||
|
|
||||||
// Get our localizaiton
|
// Get our localizaiton
|
||||||
GlobalActions.loadBrowserLocale();
|
GlobalActions.loadBrowserLocale();
|
||||||
|
|
||||||
|
// Redirect if Necessary
|
||||||
|
this.redirectIfNecessary(this.props);
|
||||||
}
|
}
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
LocalizationStore.removeChangeListener(this.localizationChanged);
|
LocalizationStore.removeChangeListener(this.localizationChanged);
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
if (this.state.translations == null) {
|
if (this.state.translations == null || this.props.children == null) {
|
||||||
return <div/>;
|
return <div/>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,8 @@ import BrowserStore from 'stores/browser_store.jsx';
|
|||||||
|
|
||||||
import {FormattedMessage} from 'react-intl';
|
import {FormattedMessage} from 'react-intl';
|
||||||
|
|
||||||
import {browserHistory} from 'react-router';
|
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {Link} from 'react-router';
|
import {Link, browserHistory} from 'react-router';
|
||||||
|
|
||||||
export default class SignupTeamComplete extends React.Component {
|
export default class SignupTeamComplete extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
|||||||
@@ -149,23 +149,6 @@ function preLoggedIn(nextState, replace, callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function onRootEnter(nextState, replace, callback) {
|
|
||||||
if (nextState.location.pathname === '/') {
|
|
||||||
Client.getMeLoggedIn((data) => {
|
|
||||||
if (!data || data.logged_in === 'false') {
|
|
||||||
replace({pathname: '/signup_team'});
|
|
||||||
callback();
|
|
||||||
} else {
|
|
||||||
replace({pathname: '/' + data.team_name + '/channels/town-square'});
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
|
|
||||||
function onPermalinkEnter(nextState) {
|
function onPermalinkEnter(nextState) {
|
||||||
const postId = nextState.params.postid;
|
const postId = nextState.params.postid;
|
||||||
|
|
||||||
@@ -216,7 +199,6 @@ function renderRootComponent() {
|
|||||||
<Route
|
<Route
|
||||||
path='/'
|
path='/'
|
||||||
component={Root}
|
component={Root}
|
||||||
onEnter={onRootEnter}
|
|
||||||
>
|
>
|
||||||
<Route
|
<Route
|
||||||
component={LoggedIn}
|
component={LoggedIn}
|
||||||
@@ -314,7 +296,7 @@ function renderRootComponent() {
|
|||||||
component={TeamURLPage}
|
component={TeamURLPage}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path='invites'
|
path='send_invites'
|
||||||
component={SendInivtesPage}
|
component={SendInivtesPage}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user