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/frontend/index.js

64 lines
2.2 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-07-25 05:43:50 +00:00
import Router from 'react-router/lib/Router';
import Route from 'react-router/lib/Route';
2016-05-07 16:18:20 +00:00
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';
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-07-18 03:59:32 +00:00
import Search from 'scenes/Search';
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((
2016-07-18 00:30:03 +00:00
<div style={{ display: 'flex', flex: 1, minHeight: '100%', }}>
2016-07-15 07:26:34 +00:00
<Provider { ...stores }>
2016-07-25 05:43:50 +00:00
<Router history={ History }>
<Route path="/" component={ Application }>
2016-07-25 05:43:50 +00:00
<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 } />
2016-07-18 03:59:32 +00:00
<Route path="/search" component={ Search } onEnter={ requireAuth } />
<Route path="/auth/slack" component={SlackAuth} />
</Route>
</Router>
</Provider>
2016-07-25 05:43:50 +00:00
{ __DEV__ && <DevTools position={{ bottom: 0, right: 0 }} /> }
2016-06-05 01:28:14 +00:00
</div>
), document.getElementById('root'));