Этот коммит содержится в:
Christopher Speller
2016-06-22 10:30:01 -04:00
коммит произвёл GitHub
родитель 00dc8e734c
Коммит 14510ce194
65 изменённых файлов: 741 добавлений и 615 удалений

207
webapp/routes/route_admin_console.jsx Обычный файл
Просмотреть файл

@@ -0,0 +1,207 @@
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import * as RouteUtils from 'routes/route_utils.jsx';
import {Route, Redirect, IndexRedirect} from 'react-router/es6';
import React from 'react';
import SystemAnalytics from 'components/analytics/system_analytics.jsx';
import ConfigurationSettings from 'components/admin_console/configuration_settings.jsx';
import LocalizationSettings from 'components/admin_console/localization_settings.jsx';
import UsersAndTeamsSettings from 'components/admin_console/users_and_teams_settings.jsx';
import PrivacySettings from 'components/admin_console/privacy_settings.jsx';
import LogSettings from 'components/admin_console/log_settings.jsx';
import EmailAuthenticationSettings from 'components/admin_console/email_authentication_settings.jsx';
import GitLabSettings from 'components/admin_console/gitlab_settings.jsx';
import LdapSettings from 'components/admin_console/ldap_settings.jsx';
import SignupSettings from 'components/admin_console/signup_settings.jsx';
import LoginSettings from 'components/admin_console/login_settings.jsx';
import PublicLinkSettings from 'components/admin_console/public_link_settings.jsx';
import SessionSettings from 'components/admin_console/session_settings.jsx';
import ConnectionSettings from 'components/admin_console/connection_settings.jsx';
import EmailSettings from 'components/admin_console/email_settings.jsx';
import PushSettings from 'components/admin_console/push_settings.jsx';
import WebhookSettings from 'components/admin_console/webhook_settings.jsx';
import ExternalServiceSettings from 'components/admin_console/external_service_settings.jsx';
import DatabaseSettings from 'components/admin_console/database_settings.jsx';
import StorageSettings from 'components/admin_console/storage_settings.jsx';
import ImageSettings from 'components/admin_console/image_settings.jsx';
import CustomBrandSettings from 'components/admin_console/custom_brand_settings.jsx';
import CustomEmojiSettings from 'components/admin_console/custom_emoji_settings.jsx';
import LegalAndSupportSettings from 'components/admin_console/legal_and_support_settings.jsx';
import ComplianceSettings from 'components/admin_console/compliance_settings.jsx';
import RateSettings from 'components/admin_console/rate_settings.jsx';
import DeveloperSettings from 'components/admin_console/developer_settings.jsx';
import TeamUsers from 'components/admin_console/team_users.jsx';
import TeamAnalytics from 'components/analytics/team_analytics.jsx';
import LicenseSettings from 'components/admin_console/license_settings.jsx';
import Audits from 'components/admin_console/audits.jsx';
import Logs from 'components/admin_console/logs.jsx';
export default (
<Route>
<Route
path='system_analytics'
component={SystemAnalytics}
/>
<Route path='general'>
<IndexRedirect to='configuration'/>
<Route
path='configuration'
component={ConfigurationSettings}
/>
<Route
path='localization'
component={LocalizationSettings}
/>
<Route
path='users_and_teams'
component={UsersAndTeamsSettings}
/>
<Route
path='privacy'
component={PrivacySettings}
/>
<Route
path='compliance'
component={ComplianceSettings}
/>
<Route
path='logging'
component={LogSettings}
/>
</Route>
<Route path='authentication'>
<IndexRedirect to='email'/>
<Route
path='email'
component={EmailAuthenticationSettings}
/>
<Route
path='gitlab'
component={GitLabSettings}
/>
<Route
path='ldap'
component={LdapSettings}
/>
</Route>
<Route path='security'>
<IndexRedirect to='sign_up'/>
<Route
path='sign_up'
component={SignupSettings}
/>
<Route
path='login'
component={LoginSettings}
/>
<Route
path='public_links'
component={PublicLinkSettings}
/>
<Route
path='sessions'
component={SessionSettings}
/>
<Route
path='connections'
component={ConnectionSettings}
/>
</Route>
<Route path='notifications'>
<IndexRedirect to='email'/>
<Route
path='email'
component={EmailSettings}
/>
<Route
path='push'
component={PushSettings}
/>
</Route>
<Route path='integrations'>
<IndexRedirect to='webhooks'/>
<Route
path='webhooks'
component={WebhookSettings}
/>
<Route
path='external'
component={ExternalServiceSettings}
/>
</Route>
<Route path='files'>
<IndexRedirect to='storage'/>
<Route
path='storage'
component={StorageSettings}
/>
<Route
path='images'
component={ImageSettings}
/>
</Route>
<Route path='customization'>
<IndexRedirect to='custom_brand'/>
<Route
path='custom_brand'
component={CustomBrandSettings}
/>
<Route
path='custom_emoji'
component={CustomEmojiSettings}
/>
<Route
path='legal_and_support'
component={LegalAndSupportSettings}
/>
</Route>
<Route path='advanced'>
<IndexRedirect to='rate'/>
<Route
path='rate'
component={RateSettings}
/>
<Route
path='database'
component={DatabaseSettings}
/>
<Route
path='developer'
component={DeveloperSettings}
/>
</Route>
<Route path='team'>
<Redirect
from=':team'
to=':team/users'
/>
<Route
path=':team/users'
component={TeamUsers}
/>
<Route
path=':team/analytics'
component={TeamAnalytics}
/>
<Redirect
from='*'
to='/error'
query={RouteUtils.notFoundParams}
/>
</Route>
<Route
path='license'
component={LicenseSettings}
/>
<Route
path='audits'
component={Audits}
/>
<Route
path='logs'
component={Logs}
/>
</Route>
);

36
webapp/routes/route_claim.jsx Обычный файл
Просмотреть файл

@@ -0,0 +1,36 @@
import * as RouteUtils from 'routes/route_utils.jsx';
export default {
path: 'claim',
getComponents: (location, callback) => {
System.import('components/claim/claim_controller.jsx').then(RouteUtils.importComponentSuccess(callback));
},
getChildRoutes: RouteUtils.createGetChildComponentsFunction(
[
{
path: 'oauth_to_email',
getComponents: (location, callback) => {
System.import('components/claim/components/oauth_to_email.jsx').then(RouteUtils.importComponentSuccess(callback));
}
},
{
path: 'email_to_oauth',
getComponents: (location, callback) => {
System.import('components/claim/components/email_to_oauth.jsx').then(RouteUtils.importComponentSuccess(callback));
}
},
{
path: 'ldap_to_email',
getComponents: (location, callback) => {
System.import('components/claim/components/ldap_to_email.jsx').then(RouteUtils.importComponentSuccess(callback));
}
},
{
path: 'email_to_ldap',
getComponents: (location, callback) => {
System.import('components/claim/components/email_to_ldap.jsx').then(RouteUtils.importComponentSuccess(callback));
}
}
]
)
};

25
webapp/routes/route_create_team.jsx Обычный файл
Просмотреть файл

@@ -0,0 +1,25 @@
import * as RouteUtils from 'routes/route_utils.jsx';
export default {
path: 'create_team',
getComponents: (location, callback) => {
System.import('components/create_team/create_team_controller.jsx').then(RouteUtils.importComponentSuccess(callback));
},
indexRoute: {onEnter: (nextState, replace) => replace('/create_team/display_name')},
getChildRoutes: RouteUtils.createGetChildComponentsFunction(
[
{
path: 'display_name',
getComponents: (location, callback) => {
System.import('components/create_team/components/display_name.jsx').then(RouteUtils.importComponentSuccess(callback));
}
},
{
path: 'team_url',
getComponents: (location, callback) => {
System.import('components/create_team/components/team_url.jsx').then(RouteUtils.importComponentSuccess(callback));
}
}
]
)
};

84
webapp/routes/route_integrations.jsx Обычный файл
Просмотреть файл

@@ -0,0 +1,84 @@
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import * as RouteUtils from 'routes/route_utils.jsx';
import {Route, IndexRoute, Redirect} from 'react-router/es6';
import React from 'react';
import BackstageNavbar from 'components/backstage/backstage_navbar.jsx';
import BackstageSidebar from 'components/backstage/backstage_sidebar.jsx';
import Integrations from 'components/backstage/integrations.jsx';
import InstalledIncomingWebhooks from 'components/backstage/installed_incoming_webhooks.jsx';
import InstalledOutgoingWebhooks from 'components/backstage/installed_outgoing_webhooks.jsx';
import InstalledCommands from 'components/backstage/installed_commands.jsx';
import AddIncomingWebhook from 'components/backstage/add_incoming_webhook.jsx';
import AddOutgoingWebhook from 'components/backstage/add_outgoing_webhook.jsx';
import AddCommand from 'components/backstage/add_command.jsx';
export default (
<Route path='integrations'>
<IndexRoute
components={{
navbar: BackstageNavbar,
sidebar: BackstageSidebar,
center: Integrations
}}
/>
<Route path='incoming_webhooks'>
<IndexRoute
components={{
navbar: BackstageNavbar,
sidebar: BackstageSidebar,
center: InstalledIncomingWebhooks
}}
/>
<Route
path='add'
components={{
navbar: BackstageNavbar,
sidebar: BackstageSidebar,
center: AddIncomingWebhook
}}
/>
</Route>
<Route path='outgoing_webhooks'>
<IndexRoute
components={{
navbar: BackstageNavbar,
sidebar: BackstageSidebar,
center: InstalledOutgoingWebhooks
}}
/>
<Route
path='add'
components={{
navbar: BackstageNavbar,
sidebar: BackstageSidebar,
center: AddOutgoingWebhook
}}
/>
</Route>
<Route path='commands'>
<IndexRoute
components={{
navbar: BackstageNavbar,
sidebar: BackstageSidebar,
center: InstalledCommands
}}
/>
<Route
path='add'
components={{
navbar: BackstageNavbar,
sidebar: BackstageSidebar,
center: AddCommand
}}
/>
</Route>
<Redirect
from='*'
to='/error'
query={RouteUtils.notFoundParams}
/>
</Route>
);

123
webapp/routes/route_root.jsx Обычный файл
Просмотреть файл

@@ -0,0 +1,123 @@
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import * as RouteUtils from 'routes/route_utils.jsx';
import Root from 'components/root.jsx';
import claimAccountRoute from 'routes/route_claim.jsx';
import createTeamRoute from 'routes/route_create_team.jsx';
import teamRoute from 'routes/route_team.jsx';
import ErrorStore from 'stores/error_store.jsx';
function preLoggedIn(nextState, replace, callback) {
ErrorStore.clearLastError();
callback();
}
export default {
path: '/',
component: Root,
getChildRoutes: RouteUtils.createGetChildComponentsFunction(
[
{
getComponents: (location, callback) => {
System.import('components/header_footer_template.jsx').then(RouteUtils.importComponentSuccess(callback));
},
getChildRoutes: RouteUtils.createGetChildComponentsFunction(
[
{
path: 'login',
getComponents: (location, callback) => {
System.import('components/login/login_controller.jsx').then(RouteUtils.importComponentSuccess(callback));
}
},
{
path: 'reset_password',
getComponents: (location, callback) => {
System.import('components/password_reset_send_link.jsx').then(RouteUtils.importComponentSuccess(callback));
}
},
{
path: 'reset_password_complete',
getComponents: (location, callback) => {
System.import('components/password_reset_form.jsx').then(RouteUtils.importComponentSuccess(callback));
}
},
claimAccountRoute,
{
path: 'signup_user_complete',
getComponents: (location, callback) => {
System.import('components/signup_user_complete.jsx').then(RouteUtils.importComponentSuccess(callback));
}
},
{
path: 'should_verify_email',
getComponents: (location, callback) => {
System.import('components/should_verify_email.jsx').then(RouteUtils.importComponentSuccess(callback));
}
},
{
path: 'do_verify_email',
getComponents: (location, callback) => {
System.import('components/do_verify_email.jsx').then(RouteUtils.importComponentSuccess(callback));
}
}
]
)
},
{
path: 'error',
getComponents: (location, callback) => {
System.import('components/error_page.jsx').then(RouteUtils.importComponentSuccess(callback));
}
},
{
getComponents: (location, callback) => {
System.import('components/logged_in.jsx').then(RouteUtils.importComponentSuccess(callback));
},
onEnter: preLoggedIn,
getChildRoutes: RouteUtils.createGetChildComponentsFunction(
[
{
path: 'admin_console',
getComponents: (location, callback) => {
System.import('components/admin_console/admin_console.jsx').then(RouteUtils.importComponentSuccess(callback));
},
indexRoute: {onEnter: (nextState, replace) => replace('/admin_console/system_analytics')},
getChildRoutes: (location, callback) => {
System.import('routes/route_admin_console.jsx').then((comp) => callback(null, comp.default));
}
},
{
getComponents: (location, callback) => {
System.import('components/header_footer_template.jsx').then(RouteUtils.importComponentSuccess(callback));
},
getChildRoutes: RouteUtils.createGetChildComponentsFunction(
[
{
path: 'select_team',
getComponents: (location, callback) => {
System.import('components/select_team/select_team.jsx').then(RouteUtils.importComponentSuccess(callback));
}
},
createTeamRoute
]
)
},
teamRoute
]
)
},
{
path: '*',
onEnter: (nextState, replace) => {
replace({
pathname: 'error',
query: RouteUtils.notFoundParams
});
}
}
]
)
};

171
webapp/routes/route_team.jsx Обычный файл
Просмотреть файл

@@ -0,0 +1,171 @@
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import $ from 'jquery';
import * as RouteUtils from 'routes/route_utils.jsx';
import {browserHistory} from 'react-router/es6';
import TeamStore from 'stores/team_store.jsx';
import * as GlobalActions from 'actions/global_actions.jsx';
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
import Constants from 'utils/constants.jsx';
const ActionTypes = Constants.ActionTypes;
import * as AsyncClient from 'utils/async_client.jsx';
import Client from 'utils/web_client.jsx';
import * as Utils from 'utils/utils.jsx';
import ChannelStore from 'stores/channel_store.jsx';
function onChannelEnter(nextState, replace, callback) {
doChannelChange(nextState, replace, callback);
}
function doChannelChange(state, replace, callback) {
let channel;
if (state.location.query.fakechannel) {
channel = JSON.parse(state.location.query.fakechannel);
} else {
channel = ChannelStore.getByName(state.params.channel);
if (!channel) {
channel = ChannelStore.getMoreByName(state.params.channel);
}
if (!channel) {
Client.joinChannelByName(
state.params.channel,
(data) => {
GlobalActions.emitChannelClickEvent(data);
callback();
},
() => {
if (state.params.team) {
replace('/' + state.params.team + '/channels/town-square');
} else {
replace('/');
}
callback();
}
);
return;
}
}
GlobalActions.emitChannelClickEvent(channel);
callback();
}
function preNeedsTeam(nextState, replace, callback) {
// First check to make sure you're in the current team
// for the current url.
var teamName = Utils.getTeamNameFromUrl();
var team = TeamStore.getByName(teamName);
const oldTeamId = TeamStore.getCurrentId();
if (!team) {
browserHistory.push('/');
return;
}
GlobalActions.emitCloseRightHandSide();
TeamStore.saveMyTeam(team);
TeamStore.emitChange();
// If the old team id is null then we will already have the direct
// profiles from initial load
if (oldTeamId != null) {
AsyncClient.getDirectProfiles();
}
var d1 = $.Deferred(); //eslint-disable-line new-cap
var d2 = $.Deferred(); //eslint-disable-line new-cap
Client.getChannels(
(data) => {
AppDispatcher.handleServerAction({
type: ActionTypes.RECEIVED_CHANNELS,
channels: data.channels,
members: data.members
});
d1.resolve();
},
(err) => {
AsyncClient.dispatchError(err, 'getChannels');
d1.resolve();
}
);
Client.getProfiles(
(data) => {
AppDispatcher.handleServerAction({
type: ActionTypes.RECEIVED_PROFILES,
profiles: data
});
d2.resolve();
},
(err) => {
AsyncClient.dispatchError(err, 'getProfiles');
d2.resolve();
}
);
$.when(d1, d2).done(() => {
callback();
});
}
function onPermalinkEnter(nextState) {
const postId = nextState.params.postid;
GlobalActions.emitPostFocusEvent(postId);
}
export default {
path: ':team',
getComponents: (location, callback) => {
System.import('components/needs_team.jsx').then(RouteUtils.importComponentSuccess(callback));
},
onEnter: preNeedsTeam,
indexRoute: {onEnter: (nextState, replace) => replace('/' + nextState.params.team + '/channels/town-square')},
childRoutes: [
{
path: 'channels/:channel',
onEnter: onChannelEnter,
getComponents: (location, callback) => {
Promise.all([
System.import('components/sidebar.jsx'),
System.import('components/channel_view.jsx')
]).then(
(comarr) => callback(null, {sidebar: comarr[0].default, center: comarr[1].default})
);
}
},
{
path: 'pl/:postid',
onEnter: onPermalinkEnter,
getComponents: (location, callback) => {
Promise.all([
System.import('components/sidebar.jsx'),
System.import('components/permalink_view.jsx')
]).then(
(comarr) => callback(null, {sidebar: comarr[0].default, center: comarr[1].default})
);
}
},
{
path: 'tutorial',
getComponents: (location, callback) => {
Promise.all([
System.import('components/sidebar.jsx'),
System.import('components/tutorial/tutorial_view.jsx')
]).then(
(comarr) => callback(null, {sidebar: comarr[0].default, center: comarr[1].default})
);
}
},
{
path: 'settings',
getChildRoutes: (location, callback) => {
System.import('routes/route_integrations.jsx').then((comp) => callback(null, [comp.default]));
}
}
]
};

20
webapp/routes/route_utils.jsx Обычный файл
Просмотреть файл

@@ -0,0 +1,20 @@
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import * as Utils from 'utils/utils.jsx';
export function importComponentSuccess(callback) {
return (comp) => callback(null, comp.default);
}
export function createGetChildComponentsFunction(arrayOfComponents) {
return (locaiton, callback) => callback(null, arrayOfComponents);
}
export const notFoundParams = {
title: Utils.localizeMessage('error.not_found.title', 'Page not found'),
message: Utils.localizeMessage('error.not_found.message', 'The page you were trying to reach does not exist'),
link: '/',
linkmessage: Utils.localizeMessage('error.not_found.link_message', 'Back to Mattermost')
};