2016-08-18 11:41:13 +02:00
|
|
|
// These are the pages you can go to.
|
|
|
|
// They are all wrapped in the App component, which should contain the navbar etc
|
|
|
|
// See http://blog.mxstbr.com/2016/01/react-apps-with-pages for more information
|
|
|
|
// about the code splitting business
|
2016-08-18 11:47:26 +02:00
|
|
|
import { getAsyncInjectors } from 'utils/asyncInjectors';
|
2016-08-18 11:41:13 +02:00
|
|
|
|
|
|
|
const errorLoading = (err) => {
|
|
|
|
console.error('Dynamic page loading failed', err); // eslint-disable-line no-console
|
|
|
|
};
|
|
|
|
|
|
|
|
const loadModule = (cb) => (componentModule) => {
|
|
|
|
cb(null, componentModule.default);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default function createRoutes(store) {
|
2016-08-18 11:47:26 +02:00
|
|
|
// Create reusable async injectors using getAsyncInjectors factory
|
|
|
|
const { injectReducer, injectSagas } = getAsyncInjectors(store); // eslint-disable-line no-unused-vars
|
2016-08-18 11:41:13 +02:00
|
|
|
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
path: '/',
|
|
|
|
name: 'home',
|
|
|
|
getComponent(nextState, cb) {
|
|
|
|
const importModules = Promise.all([
|
|
|
|
System.import('containers/HomePage'),
|
|
|
|
]);
|
|
|
|
|
|
|
|
const renderRoute = loadModule(cb);
|
|
|
|
|
2016-09-02 17:52:42 +02:00
|
|
|
importModules.then(([component]) => {
|
2016-08-18 11:41:13 +02:00
|
|
|
renderRoute(component);
|
2016-08-23 13:49:15 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
importModules.catch(errorLoading);
|
|
|
|
},
|
2016-08-30 10:53:03 +02:00
|
|
|
childRoutes: [
|
|
|
|
{
|
2016-09-06 16:59:56 +02:00
|
|
|
path: '/plugins',
|
|
|
|
name: 'plugins',
|
2016-09-02 17:52:42 +02:00
|
|
|
getComponent(nextState, cb) {
|
|
|
|
const importModules = Promise.all([
|
|
|
|
System.import('containers/PluginPage'),
|
2016-08-30 10:53:03 +02:00
|
|
|
]);
|
2016-08-23 13:49:15 +02:00
|
|
|
|
2016-08-30 10:53:03 +02:00
|
|
|
const renderRoute = loadModule(cb);
|
2016-08-23 13:49:15 +02:00
|
|
|
|
2016-08-30 10:53:03 +02:00
|
|
|
importModules.then(([component]) => {
|
|
|
|
renderRoute(component);
|
|
|
|
});
|
2016-08-18 11:41:13 +02:00
|
|
|
|
2016-08-30 10:53:03 +02:00
|
|
|
importModules.catch(errorLoading);
|
|
|
|
},
|
2016-09-06 16:59:56 +02:00
|
|
|
childRoutes: [],
|
2016-08-30 10:53:03 +02:00
|
|
|
},
|
|
|
|
],
|
2016-08-18 11:41:13 +02:00
|
|
|
}, {
|
|
|
|
path: '*',
|
2016-08-26 14:35:59 +02:00
|
|
|
name: '404',
|
2016-08-18 11:41:13 +02:00
|
|
|
getComponent(nextState, cb) {
|
|
|
|
System.import('containers/NotFoundPage')
|
|
|
|
.then(loadModule(cb))
|
|
|
|
.catch(errorLoading);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|
|
|
|
}
|