aboutsummaryrefslogtreecommitdiffstats
path: root/src/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/app.js')
-rw-r--r--src/app.js103
1 files changed, 103 insertions, 0 deletions
diff --git a/src/app.js b/src/app.js
new file mode 100644
index 000000000..b539ea494
--- /dev/null
+++ b/src/app.js
@@ -0,0 +1,103 @@
1import { webFrame } from 'electron';
2
3import React from 'react';
4import { render } from 'react-dom';
5import { Provider } from 'mobx-react';
6import { syncHistoryWithStore, RouterStore } from 'mobx-react-router';
7import { Router, Route, hashHistory, IndexRedirect } from 'react-router';
8
9import 'babel-polyfill';
10import smoothScroll from 'smoothscroll-polyfill';
11
12import ServerApi from './api/server/ServerApi';
13import LocalApi from './api/server/LocalApi';
14import storeFactory from './stores';
15import apiFactory from './api';
16import actions from './actions';
17import MenuFactory from './lib/Menu';
18import TouchBarFactory from './lib/TouchBar';
19import * as analytics from './lib/analytics';
20
21import I18N from './I18n';
22import AppLayoutContainer from './containers/layout/AppLayoutContainer';
23import SettingsWindow from './containers/settings/SettingsWindow';
24import RecipesScreen from './containers/settings/RecipesScreen';
25import ServicesScreen from './containers/settings/ServicesScreen';
26import EditServiceScreen from './containers/settings/EditServiceScreen';
27import AccountScreen from './containers/settings/AccountScreen';
28import EditUserScreen from './containers/settings/EditUserScreen';
29import EditSettingsScreen from './containers/settings/EditSettingsScreen';
30import WelcomeScreen from './containers/auth/WelcomeScreen';
31import LoginScreen from './containers/auth/LoginScreen';
32import PasswordScreen from './containers/auth/PasswordScreen';
33import SignupScreen from './containers/auth/SignupScreen';
34import ImportScreen from './containers/auth/ImportScreen';
35import PricingScreen from './containers/auth/PricingScreen';
36import InviteScreen from './containers/auth/InviteScreen';
37import AuthLayoutContainer from './containers/auth/AuthLayoutContainer';
38import SubscriptionPopupScreen from './containers/ui/SubscriptionPopupScreen';
39
40// Add Polyfills
41smoothScroll.polyfill();
42
43// Basic electron Setup
44webFrame.setVisualZoomLevelLimits(1, 1);
45webFrame.setLayoutZoomLevelLimits(0, 0);
46
47window.addEventListener('load', () => {
48 const api = apiFactory(new ServerApi(), new LocalApi());
49 const router = new RouterStore();
50 const history = syncHistoryWithStore(hashHistory, router);
51 const stores = storeFactory(api, actions, router);
52 const menu = new MenuFactory(stores, actions);
53 const touchBar = new TouchBarFactory(stores, actions);
54
55 window.franz = {
56 stores,
57 actions,
58 api,
59 menu,
60 touchBar,
61 analytics,
62 render() {
63 const preparedApp = (
64 <Provider stores={stores} actions={actions}>
65 <I18N>
66 <Router history={history}>
67 <Route path="/" component={AppLayoutContainer}>
68 <Route path="/settings" component={SettingsWindow}>
69 <IndexRedirect to="/settings/recipes" />
70 <Route path="/settings/recipes" component={RecipesScreen} />
71 <Route path="/settings/recipes/:filter" component={RecipesScreen} />
72 <Route path="/settings/services" component={ServicesScreen} />
73 <Route path="/settings/services/:action/:id" component={EditServiceScreen} />
74 <Route path="/settings/user" component={AccountScreen} />
75 <Route path="/settings/user/edit" component={EditUserScreen} />
76 <Route path="/settings/app" component={EditSettingsScreen} />
77 </Route>
78 </Route>
79 <Route path="/auth" component={AuthLayoutContainer}>
80 <IndexRedirect to="/auth/welcome" />
81 <Route path="/auth/welcome" component={WelcomeScreen} />
82 <Route path="/auth/login" component={LoginScreen} />
83 <Route path="/auth/signup">
84 <IndexRedirect to="/auth/signup/form" />
85 <Route path="/auth/signup/form" component={SignupScreen} />
86 <Route path="/auth/signup/pricing" component={PricingScreen} />
87 <Route path="/auth/signup/import" component={ImportScreen} />
88 <Route path="/auth/signup/invite" component={InviteScreen} />
89 </Route>
90 <Route path="/auth/password" component={PasswordScreen} />
91 <Route path="/auth/logout" component={LoginScreen} />
92 </Route>
93 <Route path="/payment/:url" component={SubscriptionPopupScreen} />
94 <Route path="*" component={AppLayoutContainer} />
95 </Router>
96 </I18N>
97 </Provider>
98 );
99 render(preparedApp, document.getElementById('root'));
100 },
101 };
102 window.franz.render();
103});