mirror of
https://github.com/vale981/Vulcan
synced 2025-03-05 17:41:43 -05:00
Add route name to wrapper class in layout; add support for custom layouts; export RoutesTable
This commit is contained in:
parent
e7d1b9b99e
commit
eafd294d49
8 changed files with 30 additions and 14 deletions
|
@ -6,7 +6,7 @@ import Users from 'meteor/vulcan:users';
|
|||
import AdminUsers from './users/AdminUsers.jsx';
|
||||
|
||||
const AdminHome = ({ currentUser }) =>
|
||||
<div className="admin-home">
|
||||
<div className="admin-home page">
|
||||
<Components.ShowIf check={Users.isAdmin} document={currentUser} failureComponent={<p className="admin-home-message"><FormattedMessage id="app.noPermission" /></p>}>
|
||||
<AdminUsers />
|
||||
</Components.ShowIf>
|
||||
|
|
|
@ -46,6 +46,7 @@ const options = {
|
|||
collection: Users,
|
||||
fragmentName: 'UsersCurrent',
|
||||
terms: {view: 'usersAdmin'},
|
||||
limit: 20
|
||||
}
|
||||
|
||||
export default withList(options)(AdminUsersList);
|
|
@ -1,10 +1,10 @@
|
|||
import { Components, registerComponent, withCurrentUser } from 'meteor/vulcan:core';
|
||||
import React, { PropTypes, Component } from 'react';
|
||||
import classNames from 'classnames';
|
||||
|
||||
const Layout = ({currentUser, children}) =>
|
||||
<div className="wrapper" id="wrapper">
|
||||
const Layout = ({currentUser, children, currentRoute}) =>
|
||||
|
||||
<Components.HeadTags />
|
||||
<div className={classNames('wrapper', `wrapper-${currentRoute.name.replace('.', '-')}`)} id="wrapper">
|
||||
|
||||
{currentUser ? <Components.UsersProfileCheck currentUser={currentUser} documentId={currentUser._id} /> : null}
|
||||
|
||||
|
|
|
@ -21,11 +21,18 @@ class App extends PureComponent {
|
|||
}
|
||||
|
||||
render() {
|
||||
|
||||
const currentRoute = _.last(this.props.routes);
|
||||
const LayoutComponent = currentRoute.layoutName ? Components[currentRoute.layoutName] : Components.Layout;
|
||||
|
||||
return (
|
||||
<IntlProvider locale={this.getLocale()} messages={Strings[this.getLocale()]}>
|
||||
<Components.Layout {...this.props} >
|
||||
{ this.props.currentUserLoading ? <Components.Loading /> : this.props.children }
|
||||
</Components.Layout>
|
||||
<div>
|
||||
<Components.HeadTags />
|
||||
<LayoutComponent {...this.props} currentRoute={currentRoute}>
|
||||
{ this.props.currentUserLoading ? <Components.Loading /> : this.props.children }
|
||||
</LayoutComponent>
|
||||
</div>
|
||||
</IntlProvider>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ export {
|
|||
// render context
|
||||
renderContext, getRenderContext, withRenderContext,
|
||||
// routes
|
||||
Routes, addRoute, addAsChildRoute, getRoute, populateRoutesApp,
|
||||
Routes, RoutesTable, addRoute, addAsChildRoute, getRoute, populateRoutesApp,
|
||||
// settings
|
||||
getSetting,
|
||||
// strings
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { addRoute, getComponent } from 'meteor/vulcan:core';
|
||||
|
||||
addRoute([
|
||||
{name: "cheatsheet", path: "/cheatsheet", component: import('../components/Cheatsheet.jsx')},
|
||||
{name: "groups", path: "/groups", component: import('../components/Groups.jsx')},
|
||||
{name: "settings", path: "/settings", component: import('../components/Settings.jsx')},
|
||||
{name: "emails", path: "/emails", component: import('../components/Emails.jsx')},
|
||||
{name: "cheatsheet", path: "/cheatsheet", component: import('./components/Cheatsheet.jsx')},
|
||||
{name: "groups", path: "/groups", component: import('./components/Groups.jsx')},
|
||||
{name: "settings", path: "/settings", component: import('./components/Settings.jsx')},
|
||||
{name: "emails", path: "/emails", component: import('./components/Emails.jsx')},
|
||||
]);
|
||||
|
|
|
@ -13,7 +13,7 @@ export { Components, registerComponent, replaceComponent, getRawComponent, getCo
|
|||
export { Collections, createCollection } from './collections.js';
|
||||
export { Callbacks, addCallback, removeCallback, runCallbacks, runCallbacksAsync } from './callbacks.js';
|
||||
export { GraphQLSchema, addGraphQLSchema, addGraphQLQuery, addGraphQLMutation, addGraphQLResolvers, removeGraphQLResolver, addToGraphQLContext } from './graphql.js';
|
||||
export { Routes, addRoute, addAsChildRoute, getRoute, populateRoutesApp } from './routes.js';
|
||||
export { Routes, RoutesTable, addRoute, addAsChildRoute, getRoute, populateRoutesApp } from './routes.js';
|
||||
export { Utils } from './utils.js';
|
||||
export { getSetting } from './settings.js';
|
||||
export { Strings, addStrings } from './strings.js';
|
||||
|
@ -21,4 +21,4 @@ export { configureStore, getActions, addAction, getReducers, addReducer, getMidd
|
|||
export { Headtags } from './headtags.js';
|
||||
export { Fragments, registerFragment, getFragment, getFragmentName, extendFragment, removeFromFragment } from './fragments.js';
|
||||
export { createApolloClient } from './apollo.js';
|
||||
export { dynamicLoader } from './dynamic_loader.js';
|
||||
export { dynamicLoader } from './dynamic_loader.js';
|
|
@ -10,6 +10,7 @@ import {
|
|||
addRoute,
|
||||
Routes, populateComponentsApp, populateRoutesApp,
|
||||
getRenderContext,
|
||||
dynamicLoader,
|
||||
} from 'meteor/vulcan:lib';
|
||||
|
||||
import { RouterServer } from './router.jsx';
|
||||
|
@ -29,6 +30,13 @@ Meteor.startup(() => {
|
|||
delete indexRoute.path; // delete the '/' path to avoid warning
|
||||
}
|
||||
|
||||
// go through each route and if it's a promise, wrap it with dynamicLoader
|
||||
_.forEach(childRoutes, (route, routeName) => {
|
||||
if (route.component && typeof route.component.then === 'function') {
|
||||
route.component = dynamicLoader(route.component);
|
||||
}
|
||||
});
|
||||
|
||||
const AppRoutes = {
|
||||
path: '/',
|
||||
component: Components.App,
|
||||
|
|
Loading…
Add table
Reference in a new issue