diff options
Diffstat (limited to 'src/containers/settings/EditSettingsScreen.js')
-rw-r--r-- | src/containers/settings/EditSettingsScreen.js | 144 |
1 files changed, 139 insertions, 5 deletions
diff --git a/src/containers/settings/EditSettingsScreen.js b/src/containers/settings/EditSettingsScreen.js index 9aba212be..5fa90acd5 100644 --- a/src/containers/settings/EditSettingsScreen.js +++ b/src/containers/settings/EditSettingsScreen.js | |||
@@ -1,3 +1,4 @@ | |||
1 | import { ipcRenderer } from 'electron'; | ||
1 | import React, { Component } from 'react'; | 2 | import React, { Component } from 'react'; |
2 | import PropTypes from 'prop-types'; | 3 | import PropTypes from 'prop-types'; |
3 | import { inject, observer } from 'mobx-react'; | 4 | import { inject, observer } from 'mobx-react'; |
@@ -9,7 +10,7 @@ import UserStore from '../../stores/UserStore'; | |||
9 | import TodosStore from '../../features/todos/store'; | 10 | import TodosStore from '../../features/todos/store'; |
10 | import Form from '../../lib/Form'; | 11 | import Form from '../../lib/Form'; |
11 | import { APP_LOCALES, SPELLCHECKER_LOCALES } from '../../i18n/languages'; | 12 | import { APP_LOCALES, SPELLCHECKER_LOCALES } from '../../i18n/languages'; |
12 | import { DEFAULT_APP_SETTINGS } from '../../config'; | 13 | import { DEFAULT_APP_SETTINGS, DEFAULT_LOCK_PASSWORD, HIBERNATION_STRATEGIES } from '../../config'; |
13 | import { config as spellcheckerConfig } from '../../features/spellchecker'; | 14 | import { config as spellcheckerConfig } from '../../features/spellchecker'; |
14 | 15 | ||
15 | import { getSelectOptions } from '../../helpers/i18n-helpers'; | 16 | import { getSelectOptions } from '../../helpers/i18n-helpers'; |
@@ -17,6 +18,8 @@ import { getSelectOptions } from '../../helpers/i18n-helpers'; | |||
17 | import EditSettingsForm from '../../components/settings/settings/EditSettingsForm'; | 18 | import EditSettingsForm from '../../components/settings/settings/EditSettingsForm'; |
18 | import ErrorBoundary from '../../components/util/ErrorBoundary'; | 19 | import ErrorBoundary from '../../components/util/ErrorBoundary'; |
19 | 20 | ||
21 | import { API, TODOS_FRONTEND } from '../../environment'; | ||
22 | |||
20 | import globalMessages from '../../i18n/globalMessages'; | 23 | import globalMessages from '../../i18n/globalMessages'; |
21 | import { DEFAULT_IS_FEATURE_ENABLED_BY_USER } from '../../features/todos'; | 24 | import { DEFAULT_IS_FEATURE_ENABLED_BY_USER } from '../../features/todos'; |
22 | import WorkspacesStore from '../../features/workspaces/store'; | 25 | import WorkspacesStore from '../../features/workspaces/store'; |
@@ -25,7 +28,7 @@ import { DEFAULT_SETTING_KEEP_ALL_WORKSPACES_LOADED } from '../../features/works | |||
25 | const messages = defineMessages({ | 28 | const messages = defineMessages({ |
26 | autoLaunchOnStart: { | 29 | autoLaunchOnStart: { |
27 | id: 'settings.app.form.autoLaunchOnStart', | 30 | id: 'settings.app.form.autoLaunchOnStart', |
28 | defaultMessage: '!!!Launch Franz on start', | 31 | defaultMessage: '!!!Launch Ferdi on start', |
29 | }, | 32 | }, |
30 | autoLaunchInBackground: { | 33 | autoLaunchInBackground: { |
31 | id: 'settings.app.form.autoLaunchInBackground', | 34 | id: 'settings.app.form.autoLaunchInBackground', |
@@ -33,15 +36,55 @@ const messages = defineMessages({ | |||
33 | }, | 36 | }, |
34 | runInBackground: { | 37 | runInBackground: { |
35 | id: 'settings.app.form.runInBackground', | 38 | id: 'settings.app.form.runInBackground', |
36 | defaultMessage: '!!!Keep Franz in background when closing the window', | 39 | defaultMessage: '!!!Keep Ferdi in background when closing the window', |
37 | }, | 40 | }, |
38 | enableSystemTray: { | 41 | enableSystemTray: { |
39 | id: 'settings.app.form.enableSystemTray', | 42 | id: 'settings.app.form.enableSystemTray', |
40 | defaultMessage: '!!!Show Franz in system tray', | 43 | defaultMessage: '!!!Show Ferdi in system tray', |
41 | }, | 44 | }, |
42 | minimizeToSystemTray: { | 45 | minimizeToSystemTray: { |
43 | id: 'settings.app.form.minimizeToSystemTray', | 46 | id: 'settings.app.form.minimizeToSystemTray', |
44 | defaultMessage: '!!!Minimize Franz to system tray', | 47 | defaultMessage: '!!!Minimize Ferdi to system tray', |
48 | }, | ||
49 | privateNotifications: { | ||
50 | id: 'settings.app.form.privateNotifications', | ||
51 | defaultMessage: '!!!Don\'t show message content in notifications', | ||
52 | }, | ||
53 | hibernate: { | ||
54 | id: 'settings.app.form.hibernate', | ||
55 | defaultMessage: '!!!Enable service hibernation', | ||
56 | }, | ||
57 | hibernationStrategy: { | ||
58 | id: 'settings.app.form.hibernationStrategy', | ||
59 | defaultMessage: '!!!Hibernation strategy', | ||
60 | }, | ||
61 | server: { | ||
62 | id: 'settings.app.form.server', | ||
63 | defaultMessage: '!!!Server', | ||
64 | }, | ||
65 | todoServer: { | ||
66 | id: 'settings.app.form.todoServer', | ||
67 | defaultMessage: '!!!Todo Server', | ||
68 | }, | ||
69 | enableLock: { | ||
70 | id: 'settings.app.form.enableLock', | ||
71 | defaultMessage: '!!!Enable Ferdi password lock', | ||
72 | }, | ||
73 | lockPassword: { | ||
74 | id: 'settings.app.form.lockPassword', | ||
75 | defaultMessage: '!!!Ferdi Lock password', | ||
76 | }, | ||
77 | scheduledDNDEnabled: { | ||
78 | id: 'settings.app.form.scheduledDNDEnabled', | ||
79 | defaultMessage: '!!!Enable scheduled Do-not-Disturb', | ||
80 | }, | ||
81 | scheduledDNDStart: { | ||
82 | id: 'settings.app.form.scheduledDNDStart', | ||
83 | defaultMessage: '!!!From', | ||
84 | }, | ||
85 | scheduledDNDEnd: { | ||
86 | id: 'settings.app.form.scheduledDNDEnd', | ||
87 | defaultMessage: '!!!To', | ||
45 | }, | 88 | }, |
46 | language: { | 89 | language: { |
47 | id: 'settings.app.form.language', | 90 | id: 'settings.app.form.language', |
@@ -71,6 +114,10 @@ const messages = defineMessages({ | |||
71 | id: 'settings.app.form.beta', | 114 | id: 'settings.app.form.beta', |
72 | defaultMessage: '!!!Include beta versions', | 115 | defaultMessage: '!!!Include beta versions', |
73 | }, | 116 | }, |
117 | noUpdates: { | ||
118 | id: 'settings.app.form.noUpdates', | ||
119 | defaultMessage: '!!!Disable updates', | ||
120 | }, | ||
74 | enableTodos: { | 121 | enableTodos: { |
75 | id: 'settings.app.form.enableTodos', | 122 | id: 'settings.app.form.enableTodos', |
76 | defaultMessage: '!!!Enable Franz Todos', | 123 | defaultMessage: '!!!Enable Franz Todos', |
@@ -107,6 +154,16 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e | |||
107 | runInBackground: settingsData.runInBackground, | 154 | runInBackground: settingsData.runInBackground, |
108 | enableSystemTray: settingsData.enableSystemTray, | 155 | enableSystemTray: settingsData.enableSystemTray, |
109 | minimizeToSystemTray: settingsData.minimizeToSystemTray, | 156 | minimizeToSystemTray: settingsData.minimizeToSystemTray, |
157 | privateNotifications: settingsData.privateNotifications, | ||
158 | hibernate: settingsData.hibernate, | ||
159 | hibernationStrategy: settingsData.hibernationStrategy, | ||
160 | server: settingsData.server, | ||
161 | todoServer: settingsData.todoServer, | ||
162 | lockingFeatureEnabled: settingsData.lockingFeatureEnabled, | ||
163 | lockedPassword: settingsData.lockedPassword, | ||
164 | scheduledDNDEnabled: settingsData.scheduledDNDEnabled, | ||
165 | scheduledDNDStart: settingsData.scheduledDNDStart, | ||
166 | scheduledDNDEnd: settingsData.scheduledDNDEnd, | ||
110 | enableGPUAcceleration: settingsData.enableGPUAcceleration, | 167 | enableGPUAcceleration: settingsData.enableGPUAcceleration, |
111 | showDisabledServices: settingsData.showDisabledServices, | 168 | showDisabledServices: settingsData.showDisabledServices, |
112 | darkMode: settingsData.darkMode, | 169 | darkMode: settingsData.darkMode, |
@@ -114,12 +171,14 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e | |||
114 | enableSpellchecking: settingsData.enableSpellchecking, | 171 | enableSpellchecking: settingsData.enableSpellchecking, |
115 | spellcheckerLanguage: settingsData.spellcheckerLanguage, | 172 | spellcheckerLanguage: settingsData.spellcheckerLanguage, |
116 | beta: settingsData.beta, // we need this info in the main process as well | 173 | beta: settingsData.beta, // we need this info in the main process as well |
174 | noUpdates: settingsData.noUpdates, // we need this info in the main process as well | ||
117 | locale: settingsData.locale, // we need this info in the main process as well | 175 | locale: settingsData.locale, // we need this info in the main process as well |
118 | }, | 176 | }, |
119 | }); | 177 | }); |
120 | 178 | ||
121 | user.update({ | 179 | user.update({ |
122 | userData: { | 180 | userData: { |
181 | noUpdates: settingsData.noUpdates, | ||
123 | beta: settingsData.beta, | 182 | beta: settingsData.beta, |
124 | locale: settingsData.locale, | 183 | locale: settingsData.locale, |
125 | }, | 184 | }, |
@@ -140,6 +199,10 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e | |||
140 | } | 199 | } |
141 | } | 200 | } |
142 | 201 | ||
202 | openProcessManager() { | ||
203 | ipcRenderer.send('openProcessManager'); | ||
204 | } | ||
205 | |||
143 | prepareForm() { | 206 | prepareForm() { |
144 | const { | 207 | const { |
145 | app, settings, user, todos, workspaces, | 208 | app, settings, user, todos, workspaces, |
@@ -150,6 +213,11 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e | |||
150 | locales: APP_LOCALES, | 213 | locales: APP_LOCALES, |
151 | }); | 214 | }); |
152 | 215 | ||
216 | const hibernationStrategies = getSelectOptions({ | ||
217 | locales: HIBERNATION_STRATEGIES, | ||
218 | sort: false, | ||
219 | }); | ||
220 | |||
153 | const spellcheckingLanguages = getSelectOptions({ | 221 | const spellcheckingLanguages = getSelectOptions({ |
154 | locales: SPELLCHECKER_LOCALES, | 222 | locales: SPELLCHECKER_LOCALES, |
155 | automaticDetectionText: this.context.intl.formatMessage(globalMessages.spellcheckerAutomaticDetection), | 223 | automaticDetectionText: this.context.intl.formatMessage(globalMessages.spellcheckerAutomaticDetection), |
@@ -182,6 +250,60 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e | |||
182 | value: settings.all.app.minimizeToSystemTray, | 250 | value: settings.all.app.minimizeToSystemTray, |
183 | default: DEFAULT_APP_SETTINGS.minimizeToSystemTray, | 251 | default: DEFAULT_APP_SETTINGS.minimizeToSystemTray, |
184 | }, | 252 | }, |
253 | privateNotifications: { | ||
254 | label: intl.formatMessage(messages.privateNotifications), | ||
255 | value: settings.all.app.privateNotifications, | ||
256 | default: DEFAULT_APP_SETTINGS.privateNotifications, | ||
257 | }, | ||
258 | hibernate: { | ||
259 | label: intl.formatMessage(messages.hibernate), | ||
260 | value: settings.all.app.hibernate, | ||
261 | default: DEFAULT_APP_SETTINGS.hibernate, | ||
262 | }, | ||
263 | hibernationStrategy: { | ||
264 | label: intl.formatMessage(messages.hibernationStrategy), | ||
265 | value: settings.all.app.hibernationStrategy, | ||
266 | options: hibernationStrategies, | ||
267 | default: DEFAULT_APP_SETTINGS.hibernationStrategy, | ||
268 | }, | ||
269 | server: { | ||
270 | label: intl.formatMessage(messages.server), | ||
271 | value: settings.all.app.server || API, | ||
272 | default: API, | ||
273 | }, | ||
274 | todoServer: { | ||
275 | label: intl.formatMessage(messages.todoServer), | ||
276 | value: settings.all.app.todoServer, | ||
277 | default: TODOS_FRONTEND, | ||
278 | }, | ||
279 | lockingFeatureEnabled: { | ||
280 | label: intl.formatMessage(messages.enableLock), | ||
281 | value: settings.all.app.lockingFeatureEnabled || false, | ||
282 | default: false, | ||
283 | }, | ||
284 | lockedPassword: { | ||
285 | label: intl.formatMessage(messages.lockPassword), | ||
286 | value: settings.all.app.lockedPassword, | ||
287 | default: DEFAULT_LOCK_PASSWORD, | ||
288 | type: 'password', | ||
289 | }, | ||
290 | scheduledDNDEnabled: { | ||
291 | label: intl.formatMessage(messages.scheduledDNDEnabled), | ||
292 | value: settings.all.app.scheduledDNDEnabled || false, | ||
293 | default: false, | ||
294 | }, | ||
295 | scheduledDNDStart: { | ||
296 | label: intl.formatMessage(messages.scheduledDNDStart), | ||
297 | value: settings.all.app.scheduledDNDStart, | ||
298 | default: '17:00', | ||
299 | type: 'time', | ||
300 | }, | ||
301 | scheduledDNDEnd: { | ||
302 | label: intl.formatMessage(messages.scheduledDNDEnd), | ||
303 | value: settings.all.app.scheduledDNDEnd, | ||
304 | default: '09:00', | ||
305 | type: 'time', | ||
306 | }, | ||
185 | showDisabledServices: { | 307 | showDisabledServices: { |
186 | label: intl.formatMessage(messages.showDisabledServices), | 308 | label: intl.formatMessage(messages.showDisabledServices), |
187 | value: settings.all.app.showDisabledServices, | 309 | value: settings.all.app.showDisabledServices, |
@@ -224,6 +346,11 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e | |||
224 | value: user.data.beta, | 346 | value: user.data.beta, |
225 | default: DEFAULT_APP_SETTINGS.beta, | 347 | default: DEFAULT_APP_SETTINGS.beta, |
226 | }, | 348 | }, |
349 | noUpdates: { | ||
350 | label: intl.formatMessage(messages.noUpdates), | ||
351 | value: settings.app.noUpdates, | ||
352 | default: DEFAULT_APP_SETTINGS.noUpdates, | ||
353 | }, | ||
227 | }, | 354 | }, |
228 | }; | 355 | }; |
229 | 356 | ||
@@ -257,6 +384,8 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e | |||
257 | cacheSize, | 384 | cacheSize, |
258 | updateStatusTypes, | 385 | updateStatusTypes, |
259 | isClearingAllCache, | 386 | isClearingAllCache, |
387 | server, | ||
388 | lockingFeatureEnabled, | ||
260 | } = app; | 389 | } = app; |
261 | const { | 390 | const { |
262 | checkForUpdates, | 391 | checkForUpdates, |
@@ -282,6 +411,11 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e | |||
282 | isSpellcheckerIncludedInCurrentPlan={spellcheckerConfig.isIncludedInCurrentPlan} | 411 | isSpellcheckerIncludedInCurrentPlan={spellcheckerConfig.isIncludedInCurrentPlan} |
283 | isTodosEnabled={todos.isFeatureActive} | 412 | isTodosEnabled={todos.isFeatureActive} |
284 | isWorkspaceEnabled={workspaces.isFeatureActive} | 413 | isWorkspaceEnabled={workspaces.isFeatureActive} |
414 | server={server || 'https://api.franzinfra.com'} | ||
415 | lockingFeatureEnabled={lockingFeatureEnabled} | ||
416 | noUpdates={this.props.stores.settings.app.noUpdates} | ||
417 | hibernationEnabled={this.props.stores.settings.app.hibernate} | ||
418 | openProcessManager={() => this.openProcessManager()} | ||
285 | /> | 419 | /> |
286 | </ErrorBoundary> | 420 | </ErrorBoundary> |
287 | ); | 421 | ); |