This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
outline/src/index.js

62 lines
2.1 KiB
JavaScript
Raw Normal View History

2016-02-27 21:53:11 +00:00
import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'mobx-react';
2016-05-07 16:18:20 +00:00
import Router from 'react-router/lib/Router';
import Route from 'react-router/lib/Route';
import IndexRoute from 'react-router/lib/IndexRoute';
2016-04-29 05:25:37 +00:00
import History from 'utils/History';
2016-02-27 21:53:11 +00:00
import stores from 'stores';
window.stores = stores;
2016-02-27 21:53:11 +00:00
import 'normalize.css/normalize.css';
2016-07-15 06:03:04 +00:00
import 'styles/base.scss';
import 'styles/fonts.css';
import 'styles/hljs-github-gist.scss';
import 'styles/codemirror.scss';
2016-04-29 05:25:37 +00:00
import Application from 'scenes/Application';
2016-04-29 05:25:37 +00:00
import Home from 'scenes/Home';
import Dashboard from 'scenes/Dashboard';
2016-05-07 18:52:08 +00:00
import Atlas from 'scenes/Atlas';
2016-05-22 14:25:13 +00:00
import DocumentScene from 'scenes/DocumentScene';
2016-05-26 04:26:06 +00:00
import DocumentEdit from 'scenes/DocumentEdit';
2016-04-29 05:25:37 +00:00
import SlackAuth from 'scenes/SlackAuth';
2016-02-27 21:53:11 +00:00
2016-06-26 05:43:28 +00:00
let DevTools;
if (__DEV__) {
DevTools = require('mobx-react-devtools').default;
}
2016-06-05 21:38:14 +00:00
2016-02-27 21:53:11 +00:00
function requireAuth(nextState, replace) {
if (!stores.user.authenticated) {
2016-02-27 21:53:11 +00:00
replace({
2016-04-29 05:25:37 +00:00
pathname: '/',
2016-02-27 21:53:11 +00:00
state: { nextPathname: nextState.location.pathname },
});
}
}
2016-06-05 01:28:14 +00:00
render((
<div style={{ display: 'flex', flex: 1, }}>
<Provider user={ stores.user }>
<Router history={History}>
<Route path="/" component={ Application }>
<IndexRoute component={Home} />
<Route path="/dashboard" component={ Dashboard } onEnter={ requireAuth } />
<Route path="/atlas/:id" component={ Atlas } onEnter={ requireAuth } />
<Route path="/atlas/:id/new" component={ DocumentEdit } onEnter={ requireAuth } newDocument={ true } />
<Route path="/documents/:id" component={ DocumentScene } onEnter={ requireAuth } />
<Route path="/documents/:id/edit" component={ DocumentEdit } onEnter={ requireAuth } />
<Route path="/documents/:id/new" component={ DocumentEdit } onEnter={ requireAuth } newChildDocument={ true } />
<Route path="/auth/slack" component={SlackAuth} />
</Route>
</Router>
</Provider>
2016-06-05 02:03:00 +00:00
{ __DEV__ ? <DevTools position={{ bottom: 0, right: 0 }} /> : null }
2016-06-05 01:28:14 +00:00
</div>
), document.getElementById('root'));