Refactoring center panel away. Moving tutorial to a route. Fixing a

bunch of bugs.
Этот коммит содержится в:
Christopher Speller
2016-03-24 20:04:40 -04:00
родитель bf636404d2
Коммит 5ce1a4368b
22 изменённых файлов: 366 добавлений и 304 удалений

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

@@ -19,6 +19,7 @@ import NeedsTeam from 'components/needs_team.jsx';
import PasswordResetSendLink from 'components/password_reset_send_link.jsx';
import PasswordResetForm from 'components/password_reset_form.jsx';
import ChannelView from 'components/channel_view.jsx';
import PermalinkView from 'components/permalink_view.jsx';
import Sidebar from 'components/sidebar.jsx';
import * as AsyncClient from 'utils/async_client.jsx';
import PreferenceStore from 'stores/preference_store.jsx';
@@ -34,6 +35,7 @@ import SignupUserComplete from 'components/signup_user_complete.jsx';
import ShouldVerifyEmail from 'components/should_verify_email.jsx';
import DoVerifyEmail from 'components/do_verify_email.jsx';
import AdminConsole from 'components/admin_console/admin_controller.jsx';
import TutorialView from 'components/tutorial/tutorial_view.jsx';
import SignupTeamComplete from 'components/signup_team_complete/components/signup_team_complete.jsx';
import WelcomePage from 'components/signup_team_complete/components/team_signup_welcome_page.jsx';
@@ -133,20 +135,9 @@ function preLoggedIn(nextState, replace, callback) {
const d2 = AsyncClient.getChannels();
$.when(d1, d2).done(() => callback());
}
function onChannelChange(nextState) {
const channelName = nextState.params.channel;
// Make sure we have all the channels
AsyncClient.getChannels(true);
// Get our channel's ID
const channel = ChannelStore.getByName(channelName);
// User clicked channel
GlobalActions.emitChannelClickEvent(channel);
$.when(d1, d2).done(() => {
callback();
});
}
function onRootEnter(nextState, replace, callback) {
@@ -172,6 +163,26 @@ function onPermalinkEnter(nextState) {
GlobalActions.emitPostFocusEvent(postId);
}
function onChannelEnter(nextState) {
doChannelChange(nextState);
}
function onChannelChange(prevState, nextState) {
if (prevState.params.channel !== nextState.params.channel) {
doChannelChange(nextState);
}
}
function doChannelChange(state) {
let channel;
if (state.location.query.fakechannel) {
channel = JSON.parse(state.location.query.fakechannel);
} else {
channel = ChannelStore.getByName(state.params.channel);
}
GlobalActions.emitChannelClickEvent(channel);
}
function onLoggedOut(nextState) {
const teamName = nextState.params.team;
Client.logout(
@@ -204,7 +215,8 @@ function renderRootComponent() {
>
<Route
path=':team/channels/:channel'
onEnter={onChannelChange}
onEnter={onChannelEnter}
onChange={onChannelChange}
components={{
sidebar: Sidebar,
center: ChannelView
@@ -215,23 +227,23 @@ function renderRootComponent() {
onEnter={onPermalinkEnter}
components={{
sidebar: Sidebar,
center: ChannelView
center: PermalinkView
}}
/>
<Route
path=':team/tutorial'
components={{
sidebar: Sidebar,
center: TutorialView
}}
/>
<Route
path=':team/logout'
onEnter={onLoggedOut}
components={{
sidebar: null,
center: null
}}
/>
<Route
path='admin_console'
components={{
sidebar: null,
center: AdminConsole
}}
component={AdminConsole}
/>
</Route>
<Route component={NotLoggedIn}>