forked from mozilla/testpilot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
74 lines (57 loc) · 2.05 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import 'babel-polyfill/browser';
import 'l20n/dist/compat/web/l20n';
import es6Promise from 'es6-promise';
import 'isomorphic-fetch';
import React from 'react';
import ReactDOM from 'react-dom';
import { createHistory } from 'history';
import { useRouterHistory } from 'react-router';
import { syncHistoryWithStore, routerReducer, routerMiddleware } from 'react-router-redux';
import { Provider } from 'react-redux';
import { combineReducers, createStore, applyMiddleware } from 'redux';
import createLogger from 'redux-logger';
import promise from 'redux-promise';
import './lib/ga-snippet';
import { setupAddonConnection } from './lib/addon';
import config from './config';
import experimentsActions from './actions/experiments';
import experimentsReducer from './reducers/experiments';
import browserActions from './actions/browser';
import browserReducer from './reducers/browser';
import addonReducer from './reducers/addon';
import AppRouter from './lib/router';
es6Promise.polyfill();
const initialState = {
experiments: { experiments: [], lastFetched: null },
browser: { isFirefox: false },
addon: { hasAddon: false, installed: [] }
};
const browserHistory = useRouterHistory(createHistory)({ basename: '/' });
const store = createStore(
combineReducers({
routing: routerReducer,
experiments: experimentsReducer,
browser: browserReducer,
addon: addonReducer
}),
initialState,
applyMiddleware(
promise,
routerMiddleware(browserHistory),
createLogger()
)
);
const history = syncHistoryWithStore(browserHistory, store);
ReactDOM.render(
<Provider store={store}>
<AppRouter history={history} />
</Provider>,
document.querySelector('div[data-hook=page-container]')
);
// HACK: For debugging fun
window.store = store;
store.dispatch(experimentsActions.experimentsFetch(config.experimentsURL,
config.usageCountsURL));
const isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
store.dispatch(browserActions.setIsFirefox(isFirefox));
setupAddonConnection(store);