1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/frontend/src/index.jsx

88 lines
3.9 KiB
React
Raw Normal View History

2016-12-22 14:09:16 +01:00
import 'whatwg-fetch';
import 'react-mdl/extra/material.css';
import 'react-mdl/extra/material.js';
2016-11-10 14:26:24 +01:00
import React from 'react';
import ReactDOM from 'react-dom';
2017-08-28 21:40:44 +02:00
import { applyRouterMiddleware, Router, Route, IndexRedirect, hashHistory } from 'react-router';
2016-12-29 11:55:25 +01:00
import { useScroll } from 'react-router-scroll';
2016-11-10 14:26:24 +01:00
import { Provider } from 'react-redux';
import thunkMiddleware from 'redux-thunk';
2017-01-06 11:52:44 +01:00
import { createStore, applyMiddleware, compose } from 'redux';
2016-11-10 14:26:24 +01:00
import store from './store';
2018-01-29 09:07:10 +01:00
import MetricsPoller from './metrics-poller';
2016-11-10 14:26:24 +01:00
import App from './component/app';
import Features from './page/features';
import CreateFeatureToggle from './page/features/create';
import ViewFeatureToggle from './page/features/show';
2016-11-10 14:26:24 +01:00
import Strategies from './page/strategies';
import StrategyView from './page/strategies/show';
2016-11-10 14:26:24 +01:00
import CreateStrategies from './page/strategies/create';
import HistoryPage from './page/history';
2016-11-22 22:04:30 +01:00
import HistoryTogglePage from './page/history/toggle';
2016-11-10 14:26:24 +01:00
import Archive from './page/archive';
import ShowArchive from './page/archive/show';
2016-12-03 15:54:15 +01:00
import Applications from './page/applications';
2016-12-05 15:15:01 +01:00
import ApplicationView from './page/applications/view';
import LogoutFeatures from './page/user/logout';
2016-11-10 14:26:24 +01:00
2017-01-06 11:52:44 +01:00
let composeEnhancers;
2017-08-28 21:40:44 +02:00
if (process.env.NODE_ENV !== 'production' && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) {
2017-01-06 11:52:44 +01:00
composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
} else {
composeEnhancers = compose;
}
2017-08-28 21:40:44 +02:00
const unleashStore = createStore(store, composeEnhancers(applyMiddleware(thunkMiddleware)));
2018-01-29 09:07:10 +01:00
const metricsPoller = new MetricsPoller(unleashStore);
metricsPoller.start();
2016-11-10 14:26:24 +01:00
2016-12-05 17:04:00 +01:00
// "pageTitle" and "link" attributes are for internal usage only
2016-11-10 14:26:24 +01:00
ReactDOM.render(
<Provider store={unleashStore}>
2017-08-28 21:40:44 +02:00
<Router history={hashHistory} render={applyRouterMiddleware(useScroll())}>
2016-11-10 14:26:24 +01:00
<Route path="/" component={App}>
<IndexRedirect to="/features" />
2016-12-05 17:04:00 +01:00
2017-03-07 14:55:33 +01:00
<Route pageTitle="Feature Toggles" link="/features">
2017-08-28 21:40:44 +02:00
<Route pageTitle="Feature toggles" path="/features" component={Features} />
<Route pageTitle="New" path="/features/create" component={CreateFeatureToggle} />
<Route pageTitle=":name" path="/features/:activeTab/:name" component={ViewFeatureToggle} />
2016-12-05 17:04:00 +01:00
</Route>
2016-12-14 12:50:23 +01:00
2016-12-05 17:04:00 +01:00
<Route pageTitle="Strategies" link="/strategies">
2017-08-28 21:40:44 +02:00
<Route pageTitle="Strategies" path="/strategies" component={Strategies} />
<Route pageTitle="New" path="/strategies/create" component={CreateStrategies} />
<Route
pageTitle=":strategyName"
path="/strategies/:activeTab/:strategyName"
component={StrategyView}
/>
2016-12-05 17:04:00 +01:00
</Route>
2016-12-14 12:50:23 +01:00
2017-03-07 14:55:33 +01:00
<Route pageTitle="Event History" link="/history">
2017-08-28 21:40:44 +02:00
<Route pageTitle="Event history" path="/history" component={HistoryPage} />
<Route pageTitle=":toggleName" path="/history/:toggleName" component={HistoryTogglePage} />
2016-12-05 17:04:00 +01:00
</Route>
<Route pageTitle="Archived Toggles" link="/archive">
<Route pageTitle="Archived Toggles" path="/archive" component={Archive} />
<Route pageTitle=":name" path="/archive/:activeTab/:name" component={ShowArchive} />
</Route>
2016-12-05 17:04:00 +01:00
<Route pageTitle="Applications" link="/applications">
2017-08-28 21:40:44 +02:00
<Route pageTitle="Applications" path="/applications" component={Applications} />
<Route pageTitle=":name" path="/applications/:name" component={ApplicationView} />
2016-12-05 17:04:00 +01:00
</Route>
<Route pageTitle="Logout" link="/logout">
<Route pageTitle="Logout" path="/logout" component={LogoutFeatures} />
</Route>
2016-11-10 14:26:24 +01:00
</Route>
</Router>
</Provider>,
document.getElementById('app')
);