diff options
author | Bennett <hello@vantezzen.io> | 2020-05-01 12:49:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-01 12:49:22 +0200 |
commit | b479acc0a7d2aa06d8adc7a030691447a36e9cfb (patch) | |
tree | 9bdc5a9420fc38920b402bb7c8a78d5db0bca6dc /src | |
parent | Restore delete service in sidebar (#692) (diff) | |
download | ferdium-app-b479acc0a7d2aa06d8adc7a030691447a36e9cfb.tar.gz ferdium-app-b479acc0a7d2aa06d8adc7a030691447a36e9cfb.tar.zst ferdium-app-b479acc0a7d2aa06d8adc7a030691447a36e9cfb.zip |
Refactor locking feature (#693)
Diffstat (limited to 'src')
-rw-r--r-- | src/app.js | 69 | ||||
-rw-r--r-- | src/containers/auth/LockedScreen.js | 28 | ||||
-rw-r--r-- | src/i18n/locales/defaultMessages.json | 36 | ||||
-rw-r--r-- | src/i18n/messages/src/components/layout/Sidebar.json | 36 | ||||
-rw-r--r-- | src/routes.js | 100 | ||||
-rw-r--r-- | src/stores/SettingsStore.js | 22 |
6 files changed, 153 insertions, 138 deletions
diff --git a/src/app.js b/src/app.js index 0e24420c3..aab1729d7 100644 --- a/src/app.js +++ b/src/app.js | |||
@@ -5,7 +5,7 @@ import { render } from 'react-dom'; | |||
5 | import { Provider } from 'mobx-react'; | 5 | import { Provider } from 'mobx-react'; |
6 | import { syncHistoryWithStore, RouterStore } from 'mobx-react-router'; | 6 | import { syncHistoryWithStore, RouterStore } from 'mobx-react-router'; |
7 | import { | 7 | import { |
8 | Router, Route, hashHistory, IndexRedirect, | 8 | hashHistory, |
9 | } from 'react-router'; | 9 | } from 'react-router'; |
10 | 10 | ||
11 | import '@babel/polyfill'; | 11 | import '@babel/polyfill'; |
@@ -20,33 +20,7 @@ import MenuFactory from './lib/Menu'; | |||
20 | import TouchBarFactory from './lib/TouchBar'; | 20 | import TouchBarFactory from './lib/TouchBar'; |
21 | 21 | ||
22 | import I18N from './I18n'; | 22 | import I18N from './I18n'; |
23 | import AppLayoutContainer from './containers/layout/AppLayoutContainer'; | 23 | import Routes from './routes'; |
24 | import SettingsWindow from './containers/settings/SettingsWindow'; | ||
25 | import RecipesScreen from './containers/settings/RecipesScreen'; | ||
26 | import ServicesScreen from './containers/settings/ServicesScreen'; | ||
27 | import EditServiceScreen from './containers/settings/EditServiceScreen'; | ||
28 | import AccountScreen from './containers/settings/AccountScreen'; | ||
29 | import TeamScreen from './containers/settings/TeamScreen'; | ||
30 | import EditUserScreen from './containers/settings/EditUserScreen'; | ||
31 | import EditSettingsScreen from './containers/settings/EditSettingsScreen'; | ||
32 | import InviteSettingsScreen from './containers/settings/InviteScreen'; | ||
33 | import SupportFerdiScreen from './containers/settings/SupportScreen'; | ||
34 | import WelcomeScreen from './containers/auth/WelcomeScreen'; | ||
35 | import LoginScreen from './containers/auth/LoginScreen'; | ||
36 | import LockedScreen from './containers/auth/LockedScreen'; | ||
37 | import PasswordScreen from './containers/auth/PasswordScreen'; | ||
38 | import ChangeServerScreen from './containers/auth/ChangeServerScreen'; | ||
39 | import SignupScreen from './containers/auth/SignupScreen'; | ||
40 | import ImportScreen from './containers/auth/ImportScreen'; | ||
41 | import PricingScreen from './containers/auth/PricingScreen'; | ||
42 | import InviteScreen from './containers/auth/InviteScreen'; | ||
43 | import AuthLayoutContainer from './containers/auth/AuthLayoutContainer'; | ||
44 | import SubscriptionPopupScreen from './containers/subscription/SubscriptionPopupScreen'; | ||
45 | import WorkspacesScreen from './features/workspaces/containers/WorkspacesScreen'; | ||
46 | import EditWorkspaceScreen from './features/workspaces/containers/EditWorkspaceScreen'; | ||
47 | import { WORKSPACES_ROUTES } from './features/workspaces'; | ||
48 | import AnnouncementScreen from './features/announcements/components/AnnouncementScreen'; | ||
49 | import { ANNOUNCEMENTS_ROUTES } from './features/announcements'; | ||
50 | 24 | ||
51 | // Add Polyfills | 25 | // Add Polyfills |
52 | smoothScroll.polyfill(); | 26 | smoothScroll.polyfill(); |
@@ -74,44 +48,7 @@ window.addEventListener('load', () => { | |||
74 | const preparedApp = ( | 48 | const preparedApp = ( |
75 | <Provider stores={stores} actions={actions}> | 49 | <Provider stores={stores} actions={actions}> |
76 | <I18N> | 50 | <I18N> |
77 | <Router history={history}> | 51 | <Routes history={history} /> |
78 | <Route path="/" component={AppLayoutContainer}> | ||
79 | <Route path={ANNOUNCEMENTS_ROUTES.TARGET} component={AnnouncementScreen} /> | ||
80 | <Route path="/settings" component={SettingsWindow}> | ||
81 | <IndexRedirect to="/settings/recipes" /> | ||
82 | <Route path="/settings/recipes" component={RecipesScreen} /> | ||
83 | <Route path="/settings/recipes/:filter" component={RecipesScreen} /> | ||
84 | <Route path="/settings/services" component={ServicesScreen} /> | ||
85 | <Route path="/settings/services/:action/:id" component={EditServiceScreen} /> | ||
86 | <Route path={WORKSPACES_ROUTES.ROOT} component={WorkspacesScreen} /> | ||
87 | <Route path={WORKSPACES_ROUTES.EDIT} component={EditWorkspaceScreen} /> | ||
88 | <Route path="/settings/user" component={AccountScreen} /> | ||
89 | <Route path="/settings/user/edit" component={EditUserScreen} /> | ||
90 | <Route path="/settings/team" component={TeamScreen} /> | ||
91 | <Route path="/settings/app" component={EditSettingsScreen} /> | ||
92 | <Route path="/settings/invite" component={InviteSettingsScreen} /> | ||
93 | <Route path="/settings/support" component={SupportFerdiScreen} /> | ||
94 | </Route> | ||
95 | </Route> | ||
96 | <Route path="/auth" component={AuthLayoutContainer}> | ||
97 | <IndexRedirect to="/auth/welcome" /> | ||
98 | <Route path="/auth/welcome" component={WelcomeScreen} /> | ||
99 | <Route path="/auth/login" component={LoginScreen} /> | ||
100 | <Route path="/auth/locked" component={LockedScreen} /> | ||
101 | <Route path="/auth/server" component={ChangeServerScreen} /> | ||
102 | <Route path="/auth/signup"> | ||
103 | <IndexRedirect to="/auth/signup/form" /> | ||
104 | <Route path="/auth/signup/form" component={SignupScreen} /> | ||
105 | <Route path="/auth/signup/pricing" component={PricingScreen} /> | ||
106 | <Route path="/auth/signup/import" component={ImportScreen} /> | ||
107 | <Route path="/auth/signup/invite" component={InviteScreen} /> | ||
108 | </Route> | ||
109 | <Route path="/auth/password" component={PasswordScreen} /> | ||
110 | <Route path="/auth/logout" component={LoginScreen} /> | ||
111 | </Route> | ||
112 | <Route path="/payment/:url" component={SubscriptionPopupScreen} /> | ||
113 | <Route path="*" component={AppLayoutContainer} /> | ||
114 | </Router> | ||
115 | </I18N> | 52 | </I18N> |
116 | </Provider> | 53 | </Provider> |
117 | ); | 54 | ); |
diff --git a/src/containers/auth/LockedScreen.js b/src/containers/auth/LockedScreen.js index aced64a98..8f6ce85c3 100644 --- a/src/containers/auth/LockedScreen.js +++ b/src/containers/auth/LockedScreen.js | |||
@@ -4,13 +4,7 @@ import { inject, observer } from 'mobx-react'; | |||
4 | import Locked from '../../components/auth/Locked'; | 4 | import Locked from '../../components/auth/Locked'; |
5 | import SettingsStore from '../../stores/SettingsStore'; | 5 | import SettingsStore from '../../stores/SettingsStore'; |
6 | 6 | ||
7 | import { globalError as globalErrorPropType } from '../../prop-types'; | ||
8 | |||
9 | export default @inject('stores', 'actions') @observer class LockedScreen extends Component { | 7 | export default @inject('stores', 'actions') @observer class LockedScreen extends Component { |
10 | static propTypes = { | ||
11 | error: globalErrorPropType.isRequired, | ||
12 | }; | ||
13 | |||
14 | state = { | 8 | state = { |
15 | error: false, | 9 | error: false, |
16 | } | 10 | } |
@@ -56,17 +50,23 @@ export default @inject('stores', 'actions') @observer class LockedScreen extends | |||
56 | } | 50 | } |
57 | 51 | ||
58 | render() { | 52 | render() { |
59 | const { stores, error } = this.props; | 53 | const { stores } = this.props; |
60 | const { useTouchIdToUnlock } = this.props.stores.settings.all.app; | 54 | const { useTouchIdToUnlock } = this.props.stores.settings.all.app; |
61 | 55 | ||
62 | return ( | 56 | return ( |
63 | <Locked | 57 | <div className="auth"> |
64 | onSubmit={this.onSubmit} | 58 | <div className="auth__layout"> |
65 | unlock={this.unlock} | 59 | <div className="auth__container"> |
66 | useTouchIdToUnlock={useTouchIdToUnlock} | 60 | <Locked |
67 | isSubmitting={stores.user.loginRequest.isExecuting} | 61 | onSubmit={this.onSubmit} |
68 | error={this.state.error || error} | 62 | unlock={this.unlock} |
69 | /> | 63 | useTouchIdToUnlock={useTouchIdToUnlock} |
64 | isSubmitting={stores.user.loginRequest.isExecuting} | ||
65 | error={this.state.error || {}} | ||
66 | /> | ||
67 | </div> | ||
68 | </div> | ||
69 | </div> | ||
70 | ); | 70 | ); |
71 | } | 71 | } |
72 | } | 72 | } |
diff --git a/src/i18n/locales/defaultMessages.json b/src/i18n/locales/defaultMessages.json index c80574aa8..5e3fe5810 100644 --- a/src/i18n/locales/defaultMessages.json +++ b/src/i18n/locales/defaultMessages.json | |||
@@ -1074,117 +1074,117 @@ | |||
1074 | "defaultMessage": "!!!Settings", | 1074 | "defaultMessage": "!!!Settings", |
1075 | "end": { | 1075 | "end": { |
1076 | "column": 3, | 1076 | "column": 3, |
1077 | "line": 18 | 1077 | "line": 21 |
1078 | }, | 1078 | }, |
1079 | "file": "src/components/layout/Sidebar.js", | 1079 | "file": "src/components/layout/Sidebar.js", |
1080 | "id": "sidebar.settings", | 1080 | "id": "sidebar.settings", |
1081 | "start": { | 1081 | "start": { |
1082 | "column": 12, | 1082 | "column": 12, |
1083 | "line": 15 | 1083 | "line": 18 |
1084 | } | 1084 | } |
1085 | }, | 1085 | }, |
1086 | { | 1086 | { |
1087 | "defaultMessage": "!!!Add new service", | 1087 | "defaultMessage": "!!!Add new service", |
1088 | "end": { | 1088 | "end": { |
1089 | "column": 3, | 1089 | "column": 3, |
1090 | "line": 22 | 1090 | "line": 25 |
1091 | }, | 1091 | }, |
1092 | "file": "src/components/layout/Sidebar.js", | 1092 | "file": "src/components/layout/Sidebar.js", |
1093 | "id": "sidebar.addNewService", | 1093 | "id": "sidebar.addNewService", |
1094 | "start": { | 1094 | "start": { |
1095 | "column": 17, | 1095 | "column": 17, |
1096 | "line": 19 | 1096 | "line": 22 |
1097 | } | 1097 | } |
1098 | }, | 1098 | }, |
1099 | { | 1099 | { |
1100 | "defaultMessage": "!!!Disable notifications & audio", | 1100 | "defaultMessage": "!!!Disable notifications & audio", |
1101 | "end": { | 1101 | "end": { |
1102 | "column": 3, | 1102 | "column": 3, |
1103 | "line": 26 | 1103 | "line": 29 |
1104 | }, | 1104 | }, |
1105 | "file": "src/components/layout/Sidebar.js", | 1105 | "file": "src/components/layout/Sidebar.js", |
1106 | "id": "sidebar.muteApp", | 1106 | "id": "sidebar.muteApp", |
1107 | "start": { | 1107 | "start": { |
1108 | "column": 8, | 1108 | "column": 8, |
1109 | "line": 23 | 1109 | "line": 26 |
1110 | } | 1110 | } |
1111 | }, | 1111 | }, |
1112 | { | 1112 | { |
1113 | "defaultMessage": "!!!Enable notifications & audio", | 1113 | "defaultMessage": "!!!Enable notifications & audio", |
1114 | "end": { | 1114 | "end": { |
1115 | "column": 3, | 1115 | "column": 3, |
1116 | "line": 30 | 1116 | "line": 33 |
1117 | }, | 1117 | }, |
1118 | "file": "src/components/layout/Sidebar.js", | 1118 | "file": "src/components/layout/Sidebar.js", |
1119 | "id": "sidebar.unmuteApp", | 1119 | "id": "sidebar.unmuteApp", |
1120 | "start": { | 1120 | "start": { |
1121 | "column": 10, | 1121 | "column": 10, |
1122 | "line": 27 | 1122 | "line": 30 |
1123 | } | 1123 | } |
1124 | }, | 1124 | }, |
1125 | { | 1125 | { |
1126 | "defaultMessage": "!!!Open workspace drawer", | 1126 | "defaultMessage": "!!!Open workspace drawer", |
1127 | "end": { | 1127 | "end": { |
1128 | "column": 3, | 1128 | "column": 3, |
1129 | "line": 34 | 1129 | "line": 37 |
1130 | }, | 1130 | }, |
1131 | "file": "src/components/layout/Sidebar.js", | 1131 | "file": "src/components/layout/Sidebar.js", |
1132 | "id": "sidebar.openWorkspaceDrawer", | 1132 | "id": "sidebar.openWorkspaceDrawer", |
1133 | "start": { | 1133 | "start": { |
1134 | "column": 23, | 1134 | "column": 23, |
1135 | "line": 31 | 1135 | "line": 34 |
1136 | } | 1136 | } |
1137 | }, | 1137 | }, |
1138 | { | 1138 | { |
1139 | "defaultMessage": "!!!Close workspace drawer", | 1139 | "defaultMessage": "!!!Close workspace drawer", |
1140 | "end": { | 1140 | "end": { |
1141 | "column": 3, | 1141 | "column": 3, |
1142 | "line": 38 | 1142 | "line": 41 |
1143 | }, | 1143 | }, |
1144 | "file": "src/components/layout/Sidebar.js", | 1144 | "file": "src/components/layout/Sidebar.js", |
1145 | "id": "sidebar.closeWorkspaceDrawer", | 1145 | "id": "sidebar.closeWorkspaceDrawer", |
1146 | "start": { | 1146 | "start": { |
1147 | "column": 24, | 1147 | "column": 24, |
1148 | "line": 35 | 1148 | "line": 38 |
1149 | } | 1149 | } |
1150 | }, | 1150 | }, |
1151 | { | 1151 | { |
1152 | "defaultMessage": "!!!Open Franz Todos", | 1152 | "defaultMessage": "!!!Open Franz Todos", |
1153 | "end": { | 1153 | "end": { |
1154 | "column": 3, | 1154 | "column": 3, |
1155 | "line": 42 | 1155 | "line": 45 |
1156 | }, | 1156 | }, |
1157 | "file": "src/components/layout/Sidebar.js", | 1157 | "file": "src/components/layout/Sidebar.js", |
1158 | "id": "sidebar.openTodosDrawer", | 1158 | "id": "sidebar.openTodosDrawer", |
1159 | "start": { | 1159 | "start": { |
1160 | "column": 19, | 1160 | "column": 19, |
1161 | "line": 39 | 1161 | "line": 42 |
1162 | } | 1162 | } |
1163 | }, | 1163 | }, |
1164 | { | 1164 | { |
1165 | "defaultMessage": "!!!Close Franz Todos", | 1165 | "defaultMessage": "!!!Close Franz Todos", |
1166 | "end": { | 1166 | "end": { |
1167 | "column": 3, | 1167 | "column": 3, |
1168 | "line": 46 | 1168 | "line": 49 |
1169 | }, | 1169 | }, |
1170 | "file": "src/components/layout/Sidebar.js", | 1170 | "file": "src/components/layout/Sidebar.js", |
1171 | "id": "sidebar.closeTodosDrawer", | 1171 | "id": "sidebar.closeTodosDrawer", |
1172 | "start": { | 1172 | "start": { |
1173 | "column": 20, | 1173 | "column": 20, |
1174 | "line": 43 | 1174 | "line": 46 |
1175 | } | 1175 | } |
1176 | }, | 1176 | }, |
1177 | { | 1177 | { |
1178 | "defaultMessage": "!!!Lock Ferdi", | 1178 | "defaultMessage": "!!!Lock Ferdi", |
1179 | "end": { | 1179 | "end": { |
1180 | "column": 3, | 1180 | "column": 3, |
1181 | "line": 50 | 1181 | "line": 53 |
1182 | }, | 1182 | }, |
1183 | "file": "src/components/layout/Sidebar.js", | 1183 | "file": "src/components/layout/Sidebar.js", |
1184 | "id": "sidebar.lockFerdi", | 1184 | "id": "sidebar.lockFerdi", |
1185 | "start": { | 1185 | "start": { |
1186 | "column": 13, | 1186 | "column": 13, |
1187 | "line": 47 | 1187 | "line": 50 |
1188 | } | 1188 | } |
1189 | } | 1189 | } |
1190 | ], | 1190 | ], |
diff --git a/src/i18n/messages/src/components/layout/Sidebar.json b/src/i18n/messages/src/components/layout/Sidebar.json index ddd9cd094..0495aa970 100644 --- a/src/i18n/messages/src/components/layout/Sidebar.json +++ b/src/i18n/messages/src/components/layout/Sidebar.json | |||
@@ -4,11 +4,11 @@ | |||
4 | "defaultMessage": "!!!Settings", | 4 | "defaultMessage": "!!!Settings", |
5 | "file": "src/components/layout/Sidebar.js", | 5 | "file": "src/components/layout/Sidebar.js", |
6 | "start": { | 6 | "start": { |
7 | "line": 15, | 7 | "line": 18, |
8 | "column": 12 | 8 | "column": 12 |
9 | }, | 9 | }, |
10 | "end": { | 10 | "end": { |
11 | "line": 18, | 11 | "line": 21, |
12 | "column": 3 | 12 | "column": 3 |
13 | } | 13 | } |
14 | }, | 14 | }, |
@@ -17,11 +17,11 @@ | |||
17 | "defaultMessage": "!!!Add new service", | 17 | "defaultMessage": "!!!Add new service", |
18 | "file": "src/components/layout/Sidebar.js", | 18 | "file": "src/components/layout/Sidebar.js", |
19 | "start": { | 19 | "start": { |
20 | "line": 19, | 20 | "line": 22, |
21 | "column": 17 | 21 | "column": 17 |
22 | }, | 22 | }, |
23 | "end": { | 23 | "end": { |
24 | "line": 22, | 24 | "line": 25, |
25 | "column": 3 | 25 | "column": 3 |
26 | } | 26 | } |
27 | }, | 27 | }, |
@@ -30,11 +30,11 @@ | |||
30 | "defaultMessage": "!!!Disable notifications & audio", | 30 | "defaultMessage": "!!!Disable notifications & audio", |
31 | "file": "src/components/layout/Sidebar.js", | 31 | "file": "src/components/layout/Sidebar.js", |
32 | "start": { | 32 | "start": { |
33 | "line": 23, | 33 | "line": 26, |
34 | "column": 8 | 34 | "column": 8 |
35 | }, | 35 | }, |
36 | "end": { | 36 | "end": { |
37 | "line": 26, | 37 | "line": 29, |
38 | "column": 3 | 38 | "column": 3 |
39 | } | 39 | } |
40 | }, | 40 | }, |
@@ -43,11 +43,11 @@ | |||
43 | "defaultMessage": "!!!Enable notifications & audio", | 43 | "defaultMessage": "!!!Enable notifications & audio", |
44 | "file": "src/components/layout/Sidebar.js", | 44 | "file": "src/components/layout/Sidebar.js", |
45 | "start": { | 45 | "start": { |
46 | "line": 27, | 46 | "line": 30, |
47 | "column": 10 | 47 | "column": 10 |
48 | }, | 48 | }, |
49 | "end": { | 49 | "end": { |
50 | "line": 30, | 50 | "line": 33, |
51 | "column": 3 | 51 | "column": 3 |
52 | } | 52 | } |
53 | }, | 53 | }, |
@@ -56,11 +56,11 @@ | |||
56 | "defaultMessage": "!!!Open workspace drawer", | 56 | "defaultMessage": "!!!Open workspace drawer", |
57 | "file": "src/components/layout/Sidebar.js", | 57 | "file": "src/components/layout/Sidebar.js", |
58 | "start": { | 58 | "start": { |
59 | "line": 31, | 59 | "line": 34, |
60 | "column": 23 | 60 | "column": 23 |
61 | }, | 61 | }, |
62 | "end": { | 62 | "end": { |
63 | "line": 34, | 63 | "line": 37, |
64 | "column": 3 | 64 | "column": 3 |
65 | } | 65 | } |
66 | }, | 66 | }, |
@@ -69,11 +69,11 @@ | |||
69 | "defaultMessage": "!!!Close workspace drawer", | 69 | "defaultMessage": "!!!Close workspace drawer", |
70 | "file": "src/components/layout/Sidebar.js", | 70 | "file": "src/components/layout/Sidebar.js", |
71 | "start": { | 71 | "start": { |
72 | "line": 35, | 72 | "line": 38, |
73 | "column": 24 | 73 | "column": 24 |
74 | }, | 74 | }, |
75 | "end": { | 75 | "end": { |
76 | "line": 38, | 76 | "line": 41, |
77 | "column": 3 | 77 | "column": 3 |
78 | } | 78 | } |
79 | }, | 79 | }, |
@@ -82,11 +82,11 @@ | |||
82 | "defaultMessage": "!!!Open Franz Todos", | 82 | "defaultMessage": "!!!Open Franz Todos", |
83 | "file": "src/components/layout/Sidebar.js", | 83 | "file": "src/components/layout/Sidebar.js", |
84 | "start": { | 84 | "start": { |
85 | "line": 39, | 85 | "line": 42, |
86 | "column": 19 | 86 | "column": 19 |
87 | }, | 87 | }, |
88 | "end": { | 88 | "end": { |
89 | "line": 42, | 89 | "line": 45, |
90 | "column": 3 | 90 | "column": 3 |
91 | } | 91 | } |
92 | }, | 92 | }, |
@@ -95,11 +95,11 @@ | |||
95 | "defaultMessage": "!!!Close Franz Todos", | 95 | "defaultMessage": "!!!Close Franz Todos", |
96 | "file": "src/components/layout/Sidebar.js", | 96 | "file": "src/components/layout/Sidebar.js", |
97 | "start": { | 97 | "start": { |
98 | "line": 43, | 98 | "line": 46, |
99 | "column": 20 | 99 | "column": 20 |
100 | }, | 100 | }, |
101 | "end": { | 101 | "end": { |
102 | "line": 46, | 102 | "line": 49, |
103 | "column": 3 | 103 | "column": 3 |
104 | } | 104 | } |
105 | }, | 105 | }, |
@@ -108,11 +108,11 @@ | |||
108 | "defaultMessage": "!!!Lock Ferdi", | 108 | "defaultMessage": "!!!Lock Ferdi", |
109 | "file": "src/components/layout/Sidebar.js", | 109 | "file": "src/components/layout/Sidebar.js", |
110 | "start": { | 110 | "start": { |
111 | "line": 47, | 111 | "line": 50, |
112 | "column": 13 | 112 | "column": 13 |
113 | }, | 113 | }, |
114 | "end": { | 114 | "end": { |
115 | "line": 50, | 115 | "line": 53, |
116 | "column": 3 | 116 | "column": 3 |
117 | } | 117 | } |
118 | } | 118 | } |
diff --git a/src/routes.js b/src/routes.js new file mode 100644 index 000000000..9986cdde5 --- /dev/null +++ b/src/routes.js | |||
@@ -0,0 +1,100 @@ | |||
1 | import React, { Component } from 'react'; | ||
2 | import PropTypes from 'prop-types'; | ||
3 | import { inject, observer } from 'mobx-react'; | ||
4 | import { | ||
5 | Router, Route, IndexRedirect, | ||
6 | } from 'react-router'; | ||
7 | |||
8 | import AppLayoutContainer from './containers/layout/AppLayoutContainer'; | ||
9 | import SettingsWindow from './containers/settings/SettingsWindow'; | ||
10 | import RecipesScreen from './containers/settings/RecipesScreen'; | ||
11 | import ServicesScreen from './containers/settings/ServicesScreen'; | ||
12 | import EditServiceScreen from './containers/settings/EditServiceScreen'; | ||
13 | import AccountScreen from './containers/settings/AccountScreen'; | ||
14 | import TeamScreen from './containers/settings/TeamScreen'; | ||
15 | import EditUserScreen from './containers/settings/EditUserScreen'; | ||
16 | import EditSettingsScreen from './containers/settings/EditSettingsScreen'; | ||
17 | import InviteSettingsScreen from './containers/settings/InviteScreen'; | ||
18 | import SupportFerdiScreen from './containers/settings/SupportScreen'; | ||
19 | import WelcomeScreen from './containers/auth/WelcomeScreen'; | ||
20 | import LoginScreen from './containers/auth/LoginScreen'; | ||
21 | import LockedScreen from './containers/auth/LockedScreen'; | ||
22 | import PasswordScreen from './containers/auth/PasswordScreen'; | ||
23 | import ChangeServerScreen from './containers/auth/ChangeServerScreen'; | ||
24 | import SignupScreen from './containers/auth/SignupScreen'; | ||
25 | import ImportScreen from './containers/auth/ImportScreen'; | ||
26 | import PricingScreen from './containers/auth/PricingScreen'; | ||
27 | import InviteScreen from './containers/auth/InviteScreen'; | ||
28 | import AuthLayoutContainer from './containers/auth/AuthLayoutContainer'; | ||
29 | import SubscriptionPopupScreen from './containers/subscription/SubscriptionPopupScreen'; | ||
30 | import WorkspacesScreen from './features/workspaces/containers/WorkspacesScreen'; | ||
31 | import EditWorkspaceScreen from './features/workspaces/containers/EditWorkspaceScreen'; | ||
32 | import { WORKSPACES_ROUTES } from './features/workspaces'; | ||
33 | import AnnouncementScreen from './features/announcements/components/AnnouncementScreen'; | ||
34 | import { ANNOUNCEMENTS_ROUTES } from './features/announcements'; | ||
35 | |||
36 | import SettingsStore from './stores/SettingsStore'; | ||
37 | |||
38 | export default @inject('stores', 'actions') @observer class Routes extends Component { | ||
39 | render() { | ||
40 | const { | ||
41 | locked, | ||
42 | lockingFeatureEnabled, | ||
43 | } = this.props.stores.settings.app; | ||
44 | |||
45 | const { history } = this.props; | ||
46 | |||
47 | if (lockingFeatureEnabled && locked) { | ||
48 | return ( | ||
49 | <LockedScreen /> | ||
50 | ); | ||
51 | } | ||
52 | |||
53 | return ( | ||
54 | <Router history={history}> | ||
55 | <Route path="/" component={AppLayoutContainer}> | ||
56 | <Route path={ANNOUNCEMENTS_ROUTES.TARGET} component={AnnouncementScreen} /> | ||
57 | <Route path="/settings" component={SettingsWindow}> | ||
58 | <IndexRedirect to="/settings/recipes" /> | ||
59 | <Route path="/settings/recipes" component={RecipesScreen} /> | ||
60 | <Route path="/settings/recipes/:filter" component={RecipesScreen} /> | ||
61 | <Route path="/settings/services" component={ServicesScreen} /> | ||
62 | <Route path="/settings/services/:action/:id" component={EditServiceScreen} /> | ||
63 | <Route path={WORKSPACES_ROUTES.ROOT} component={WorkspacesScreen} /> | ||
64 | <Route path={WORKSPACES_ROUTES.EDIT} component={EditWorkspaceScreen} /> | ||
65 | <Route path="/settings/user" component={AccountScreen} /> | ||
66 | <Route path="/settings/user/edit" component={EditUserScreen} /> | ||
67 | <Route path="/settings/team" component={TeamScreen} /> | ||
68 | <Route path="/settings/app" component={EditSettingsScreen} /> | ||
69 | <Route path="/settings/invite" component={InviteSettingsScreen} /> | ||
70 | <Route path="/settings/support" component={SupportFerdiScreen} /> | ||
71 | </Route> | ||
72 | </Route> | ||
73 | <Route path="/auth" component={AuthLayoutContainer}> | ||
74 | <IndexRedirect to="/auth/welcome" /> | ||
75 | <Route path="/auth/welcome" component={WelcomeScreen} /> | ||
76 | <Route path="/auth/login" component={LoginScreen} /> | ||
77 | <Route path="/auth/server" component={ChangeServerScreen} /> | ||
78 | <Route path="/auth/signup"> | ||
79 | <IndexRedirect to="/auth/signup/form" /> | ||
80 | <Route path="/auth/signup/form" component={SignupScreen} /> | ||
81 | <Route path="/auth/signup/pricing" component={PricingScreen} /> | ||
82 | <Route path="/auth/signup/import" component={ImportScreen} /> | ||
83 | <Route path="/auth/signup/invite" component={InviteScreen} /> | ||
84 | </Route> | ||
85 | <Route path="/auth/password" component={PasswordScreen} /> | ||
86 | <Route path="/auth/logout" component={LoginScreen} /> | ||
87 | </Route> | ||
88 | <Route path="/payment/:url" component={SubscriptionPopupScreen} /> | ||
89 | <Route path="*" component={AppLayoutContainer} /> | ||
90 | </Router> | ||
91 | ); | ||
92 | } | ||
93 | } | ||
94 | |||
95 | Routes.wrappedComponent.propTypes = { | ||
96 | stores: PropTypes.shape({ | ||
97 | settings: PropTypes.instanceOf(SettingsStore).isRequired, | ||
98 | }).isRequired, | ||
99 | history: PropTypes.any.isRequired, | ||
100 | }; | ||
diff --git a/src/stores/SettingsStore.js b/src/stores/SettingsStore.js index 227eb2145..dcf3c3b9d 100644 --- a/src/stores/SettingsStore.js +++ b/src/stores/SettingsStore.js | |||
@@ -56,21 +56,6 @@ export default class SettingsStore extends Store { | |||
56 | }, | 56 | }, |
57 | ); | 57 | ); |
58 | 58 | ||
59 | reaction( | ||
60 | () => this.all.app.locked, | ||
61 | () => { | ||
62 | const { router } = window.ferdi.stores; | ||
63 | if (this.all.app.locked && this.all.app.lockingFeatureEnabled) { | ||
64 | // App just got locked, redirect to unlock screen | ||
65 | router.push('/auth/locked'); | ||
66 | } else if (router.location.pathname.includes('/auth/locked')) { | ||
67 | // App is unlocked but user is still on locked screen | ||
68 | // Redirect to homepage | ||
69 | router.push('/'); | ||
70 | } | ||
71 | }, | ||
72 | ); | ||
73 | |||
74 | // Inactivity lock timer | 59 | // Inactivity lock timer |
75 | let inactivityTimer; | 60 | let inactivityTimer; |
76 | remote.getCurrentWindow().on('blur', () => { | 61 | remote.getCurrentWindow().on('blur', () => { |
@@ -96,15 +81,8 @@ export default class SettingsStore extends Store { | |||
96 | if (this.startup && resp.type === 'app' && resp.data.lockingFeatureEnabled) { | 81 | if (this.startup && resp.type === 'app' && resp.data.lockingFeatureEnabled) { |
97 | this.startup = false; | 82 | this.startup = false; |
98 | process.nextTick(() => { | 83 | process.nextTick(() => { |
99 | // If the app was previously closed unlocked | ||
100 | // we can update the `locked` setting and rely on the reaction to lock at startup | ||
101 | if (!this.all.app.locked) { | 84 | if (!this.all.app.locked) { |
102 | this.all.app.locked = true; | 85 | this.all.app.locked = true; |
103 | } else { | ||
104 | // Otherwise the app previously closed in a locked state | ||
105 | // We can't rely on updating the locked setting for the reaction to be triggered | ||
106 | // So we lock manually | ||
107 | window.ferdi.stores.router.push('/auth/locked'); | ||
108 | } | 86 | } |
109 | }); | 87 | }); |
110 | } | 88 | } |