aboutsummaryrefslogtreecommitdiffstats
path: root/src/containers/settings/EditSettingsScreen.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/containers/settings/EditSettingsScreen.tsx')
-rw-r--r--src/containers/settings/EditSettingsScreen.tsx906
1 files changed, 906 insertions, 0 deletions
diff --git a/src/containers/settings/EditSettingsScreen.tsx b/src/containers/settings/EditSettingsScreen.tsx
new file mode 100644
index 000000000..205c71107
--- /dev/null
+++ b/src/containers/settings/EditSettingsScreen.tsx
@@ -0,0 +1,906 @@
1import { ipcRenderer } from 'electron';
2import { Component, ReactElement } from 'react';
3import { inject, observer } from 'mobx-react';
4import { defineMessages, injectIntl } from 'react-intl';
5
6import { FormFields } from 'src/@types/mobx-form.types';
7import { StoresProps } from 'src/@types/ferdium-components.types';
8import Form from '../../lib/Form';
9import { APP_LOCALES, SPELLCHECKER_LOCALES } from '../../i18n/languages';
10import {
11 DEFAULT_APP_SETTINGS,
12 HIBERNATION_STRATEGIES,
13 SIDEBAR_WIDTH,
14 SIDEBAR_SERVICES_LOCATION,
15 ICON_SIZES,
16 NAVIGATION_BAR_BEHAVIOURS,
17 SEARCH_ENGINE_NAMES,
18 TODO_APPS,
19 DEFAULT_SETTING_KEEP_ALL_WORKSPACES_LOADED,
20 DEFAULT_IS_FEATURE_ENABLED_BY_USER,
21 WAKE_UP_STRATEGIES,
22 WAKE_UP_HIBERNATION_STRATEGIES,
23 SPLIT_COLUMNS_MIN,
24 SPLIT_COLUMNS_MAX,
25} from '../../config';
26import { isMac } from '../../environment';
27
28import { getSelectOptions } from '../../helpers/i18n-helpers';
29import { hash } from '../../helpers/password-helpers';
30import defaultUserAgent from '../../helpers/userAgent-helpers';
31
32import EditSettingsForm from '../../components/settings/settings/EditSettingsForm';
33import ErrorBoundary from '../../components/util/ErrorBoundary';
34
35import globalMessages from '../../i18n/globalMessages';
36
37const debug = require('../../preload-safe-debug')('Ferdium:EditSettingsScreen');
38
39const messages = defineMessages({
40 autoLaunchOnStart: {
41 id: 'settings.app.form.autoLaunchOnStart',
42 defaultMessage: 'Launch Ferdium on start',
43 },
44 autoLaunchInBackground: {
45 id: 'settings.app.form.autoLaunchInBackground',
46 defaultMessage: 'Open in background',
47 },
48 runInBackground: {
49 id: 'settings.app.form.runInBackground',
50 defaultMessage: 'Keep Ferdium in background when closing the window',
51 },
52 startMinimized: {
53 id: 'settings.app.form.startMinimized',
54 defaultMessage: 'Start minimized',
55 },
56 confirmOnQuit: {
57 id: 'settings.app.form.confirmOnQuit',
58 defaultMessage: 'Confirm when quitting Ferdium',
59 },
60 enableSystemTray: {
61 id: 'settings.app.form.enableSystemTray',
62 defaultMessage: 'Always show Ferdium in System Tray',
63 },
64 enableMenuBar: {
65 id: 'settings.app.form.enableMenuBar',
66 defaultMessage: 'Always show Ferdium in Menu Bar',
67 },
68 reloadAfterResume: {
69 id: 'settings.app.form.reloadAfterResume',
70 defaultMessage: 'Reload Ferdium after system resume',
71 },
72 reloadAfterResumeTime: {
73 id: 'settings.app.form.reloadAfterResumeTime',
74 defaultMessage:
75 'Time to consider the system as idle/suspended (in minutes)',
76 },
77 minimizeToSystemTray: {
78 id: 'settings.app.form.minimizeToSystemTray',
79 defaultMessage: 'Minimize Ferdium to system tray',
80 },
81 closeToSystemTray: {
82 id: 'settings.app.form.closeToSystemTray',
83 defaultMessage: 'Close Ferdium to system tray',
84 },
85 privateNotifications: {
86 id: 'settings.app.form.privateNotifications',
87 defaultMessage: "Don't show message content in notifications",
88 },
89 clipboardNotifications: {
90 id: 'settings.app.form.clipboardNotifications',
91 defaultMessage: "Don't show notifications for clipboard events",
92 },
93 notifyTaskBarOnMessage: {
94 id: 'settings.app.form.notifyTaskBarOnMessage',
95 defaultMessage: 'Notify TaskBar/Dock on new message',
96 },
97 navigationBarBehaviour: {
98 id: 'settings.app.form.navigationBarBehaviour',
99 defaultMessage: 'Navigation bar behaviour',
100 },
101 searchEngine: {
102 id: 'settings.app.form.searchEngine',
103 defaultMessage: 'Search engine',
104 },
105 hibernateOnStartup: {
106 id: 'settings.app.form.hibernateOnStartup',
107 defaultMessage: 'Keep services in hibernation on startup',
108 },
109 hibernationStrategy: {
110 id: 'settings.app.form.hibernationStrategy',
111 defaultMessage: 'Hibernation strategy',
112 },
113 wakeUpStrategy: {
114 id: 'settings.app.form.wakeUpStrategy',
115 defaultMessage: 'Wake up strategy',
116 },
117 wakeUpHibernationStrategy: {
118 id: 'settings.app.form.wakeUpHibernationStrategy',
119 defaultMessage: 'Hibernation strategy after automatic wake up',
120 },
121 wakeUpHibernationSplay: {
122 id: 'settings.app.form.wakeUpHibernationSplay',
123 defaultMessage: 'Splay hibernate/wake cycles to reduce load',
124 },
125 predefinedTodoServer: {
126 id: 'settings.app.form.predefinedTodoServer',
127 defaultMessage: 'Todo Server',
128 },
129 customTodoServer: {
130 id: 'settings.app.form.customTodoServer',
131 defaultMessage: 'Custom Todo Server',
132 },
133 enableLock: {
134 id: 'settings.app.form.enableLock',
135 defaultMessage: 'Enable Password Lock',
136 },
137 lockPassword: {
138 id: 'settings.app.form.lockPassword',
139 defaultMessage: 'Password',
140 },
141 useTouchIdToUnlock: {
142 id: 'settings.app.form.useTouchIdToUnlock',
143 defaultMessage: 'Allow using TouchID to unlock Ferdium',
144 },
145 inactivityLock: {
146 id: 'settings.app.form.inactivityLock',
147 defaultMessage: 'Lock after inactivity',
148 },
149 scheduledDNDEnabled: {
150 id: 'settings.app.form.scheduledDNDEnabled',
151 defaultMessage: 'Enable scheduled Do-not-Disturb',
152 },
153 scheduledDNDStart: {
154 id: 'settings.app.form.scheduledDNDStart',
155 defaultMessage: 'From',
156 },
157 scheduledDNDEnd: {
158 id: 'settings.app.form.scheduledDNDEnd',
159 defaultMessage: 'To',
160 },
161 language: {
162 id: 'settings.app.form.language',
163 defaultMessage: 'Language',
164 },
165 darkMode: {
166 id: 'settings.app.form.darkMode',
167 defaultMessage: 'Enable Dark Mode',
168 },
169 adaptableDarkMode: {
170 id: 'settings.app.form.adaptableDarkMode',
171 defaultMessage: "Synchronize dark mode with my OS's dark mode setting",
172 },
173 universalDarkMode: {
174 id: 'settings.app.form.universalDarkMode',
175 defaultMessage: 'Enable universal Dark Mode',
176 },
177 splitMode: {
178 id: 'settings.app.form.splitMode',
179 defaultMessage: 'Enable Split View Mode',
180 },
181 splitColumns: {
182 id: 'settings.app.form.splitColumns',
183 defaultMessage: 'Number of columns',
184 },
185 serviceRibbonWidth: {
186 id: 'settings.app.form.serviceRibbonWidth',
187 defaultMessage: 'Sidebar width',
188 },
189 sidebarServicesLocation: {
190 id: 'settings.app.form.sidebarServicesLocation',
191 defaultMessage: 'Sidebar Services Icons Location',
192 },
193 iconSize: {
194 id: 'settings.app.form.iconSize',
195 defaultMessage: 'Service icon size',
196 },
197 enableLongPressServiceHint: {
198 id: 'settings.app.form.enableLongPressServiceHint',
199 defaultMessage: 'Enable service shortcut hint on long press',
200 },
201 useVerticalStyle: {
202 id: 'settings.app.form.useVerticalStyle',
203 defaultMessage: 'Use horizontal style',
204 },
205 hideCollapseButton: {
206 id: 'settings.app.form.hideCollapseButton',
207 defaultMessage: 'Hide Collapse button',
208 },
209 hideRecipesButton: {
210 id: 'settings.app.form.hideRecipesButton',
211 defaultMessage: 'Hide Recipes button',
212 },
213 hideSplitModeButton: {
214 id: 'settings.app.form.hideSplitModeButton',
215 defaultMessage: 'Hide Split Mode button',
216 },
217 useGrayscaleServices: {
218 id: 'settings.app.form.useGrayscaleServices',
219 defaultMessage: 'Use grayscale services',
220 },
221 grayscaleServicesDim: {
222 id: 'settings.app.form.grayscaleServicesDim',
223 defaultMessage: 'Grayscale dim level',
224 },
225 hideWorkspacesButton: {
226 id: 'settings.app.form.hideWorkspacesButton',
227 defaultMessage: 'Hide Workspace Drawer button',
228 },
229 hideNotificationsButton: {
230 id: 'settings.app.form.hideNotificationsButton',
231 defaultMessage: 'Hide Notifications & Sound button',
232 },
233 hideSettingsButton: {
234 id: 'settings.app.form.hideSettingsButton',
235 defaultMessage: 'Hide Settings button',
236 },
237 alwaysShowWorkspaces: {
238 id: 'settings.app.form.alwaysShowWorkspaces',
239 defaultMessage: 'Always show workspace drawer',
240 },
241 accentColor: {
242 id: 'settings.app.form.accentColor',
243 defaultMessage: 'Accent color',
244 },
245 progressbarAccentColor: {
246 id: 'settings.app.form.progressbarAccentColor',
247 defaultMessage: 'Progressbar Accent color',
248 },
249 showDisabledServices: {
250 id: 'settings.app.form.showDisabledServices',
251 defaultMessage: 'Display disabled services tabs',
252 },
253 showServiceName: {
254 id: 'settings.app.form.showServiceName',
255 defaultMessage: 'Display service name under the icon',
256 },
257 showMessageBadgeWhenMuted: {
258 id: 'settings.app.form.showMessagesBadgesWhenMuted',
259 defaultMessage: 'Show unread message badge when notifications are disabled',
260 },
261 showDragArea: {
262 id: 'settings.app.form.showDragArea',
263 defaultMessage: 'Show draggable area on window',
264 },
265 enableSpellchecking: {
266 id: 'settings.app.form.enableSpellchecking',
267 defaultMessage: 'Enable spell checking',
268 },
269 enableGPUAcceleration: {
270 id: 'settings.app.form.enableGPUAcceleration',
271 defaultMessage: 'Enable GPU Acceleration',
272 },
273 enableGlobalHideShortcut: {
274 id: 'settings.app.form.enableGlobalHideShortcut',
275 defaultMessage: 'Enable Global shortcut to hide Ferdium',
276 },
277 beta: {
278 id: 'settings.app.form.beta',
279 defaultMessage: 'Include pre-releases',
280 },
281 automaticUpdates: {
282 id: 'settings.app.form.automaticUpdates',
283 defaultMessage: 'Enable updates',
284 },
285 enableTodos: {
286 id: 'settings.app.form.enableTodos',
287 defaultMessage: 'Enable Ferdium Todos',
288 },
289 keepAllWorkspacesLoaded: {
290 id: 'settings.app.form.keepAllWorkspacesLoaded',
291 defaultMessage: 'Keep all workspaces loaded',
292 },
293});
294
295interface EditSettingsScreenProps extends StoresProps {
296 intl: any;
297}
298
299class EditSettingsScreen extends Component<EditSettingsScreenProps> {
300 state = {
301 lockedPassword: '',
302 };
303
304 onSubmit(settingsData) {
305 const { todos, workspaces } = this.props.stores;
306 const {
307 app,
308 settings,
309 user,
310 todos: todosActions,
311 workspaces: workspaceActions,
312 } = this.props.actions;
313
314 const useOriginalPassword = settingsData.lockedPassword === '';
315
316 this.setState({
317 lockedPassword: useOriginalPassword ? '' : settingsData.lockedPassword,
318 });
319
320 app.launchOnStartup({
321 enable: Boolean(settingsData.autoLaunchOnStart),
322 openInBackground: Boolean(settingsData.autoLaunchInBackground),
323 });
324
325 debug(`Updating settings store with data: ${settingsData}`);
326
327 settings.update({
328 type: 'app',
329 // TODO: The conversions might not be necessary once we convert to typescript
330 data: {
331 runInBackground: Boolean(settingsData.runInBackground),
332 enableSystemTray: Boolean(settingsData.enableSystemTray),
333 reloadAfterResume: Boolean(settingsData.reloadAfterResume),
334 reloadAfterResumeTime: Number(settingsData.reloadAfterResumeTime),
335 startMinimized: Boolean(settingsData.startMinimized),
336 confirmOnQuit: Boolean(settingsData.confirmOnQuit),
337 minimizeToSystemTray: Boolean(settingsData.minimizeToSystemTray),
338 closeToSystemTray: Boolean(settingsData.closeToSystemTray),
339 privateNotifications: Boolean(settingsData.privateNotifications),
340 clipboardNotifications: Boolean(settingsData.clipboardNotifications),
341 notifyTaskBarOnMessage: Boolean(settingsData.notifyTaskBarOnMessage),
342 navigationBarBehaviour: settingsData.navigationBarBehaviour,
343 searchEngine: settingsData.searchEngine,
344 hibernateOnStartup: Boolean(settingsData.hibernateOnStartup),
345 hibernationStrategy: Number(settingsData.hibernationStrategy),
346 wakeUpStrategy: Number(settingsData.wakeUpStrategy),
347 wakeUpHibernationStrategy: Number(
348 settingsData.wakeUpHibernationStrategy,
349 ),
350 wakeUpHibernationSplay: Boolean(settingsData.wakeUpHibernationSplay),
351 predefinedTodoServer: settingsData.predefinedTodoServer,
352 customTodoServer: settingsData.customTodoServer,
353 lockingFeatureEnabled: Boolean(settingsData.lockingFeatureEnabled),
354 lockedPassword: useOriginalPassword
355 ? this.props.stores.settings.all.app.lockedPassword
356 : hash(String(settingsData.lockedPassword)),
357 useTouchIdToUnlock: Boolean(settingsData.useTouchIdToUnlock),
358 inactivityLock: Number(settingsData.inactivityLock),
359 scheduledDNDEnabled: Boolean(settingsData.scheduledDNDEnabled),
360 scheduledDNDStart: settingsData.scheduledDNDStart,
361 scheduledDNDEnd: settingsData.scheduledDNDEnd,
362 enableGPUAcceleration: Boolean(settingsData.enableGPUAcceleration),
363 enableGlobalHideShortcut: Boolean(
364 settingsData.enableGlobalHideShortcut,
365 ),
366 showDisabledServices: Boolean(settingsData.showDisabledServices),
367 showServiceName: Boolean(settingsData.showServiceName),
368 darkMode: Boolean(settingsData.darkMode),
369 adaptableDarkMode: Boolean(settingsData.adaptableDarkMode),
370 universalDarkMode: Boolean(settingsData.universalDarkMode),
371 splitMode: Boolean(settingsData.splitMode),
372 splitColumns: Number(settingsData.splitColumns),
373 serviceRibbonWidth: Number(settingsData.serviceRibbonWidth),
374 sidebarServicesLocation: Number(settingsData.sidebarServicesLocation),
375 iconSize: Number(settingsData.iconSize),
376 enableLongPressServiceHint: Boolean(
377 settingsData.enableLongPressServiceHint,
378 ),
379 useVerticalStyle: Boolean(settingsData.useVerticalStyle),
380 hideCollapseButton: Boolean(settingsData.hideCollapseButton),
381 hideRecipesButton: Boolean(settingsData.hideRecipesButton),
382 hideSplitModeButton: Boolean(settingsData.hideSplitModeButton),
383 useGrayscaleServices: Boolean(settingsData.useGrayscaleServices),
384 grayscaleServicesDim: Number(settingsData.grayscaleServicesDim),
385 hideWorkspacesButton: Boolean(settingsData.hideWorkspacesButton),
386 hideNotificationsButton: Boolean(settingsData.hideNotificationsButton),
387 hideSettingsButton: Boolean(settingsData.hideSettingsButton),
388 alwaysShowWorkspaces: Boolean(settingsData.alwaysShowWorkspaces),
389 accentColor: settingsData.accentColor,
390 progressbarAccentColor: settingsData.progressbarAccentColor,
391 showMessageBadgeWhenMuted: Boolean(
392 settingsData.showMessageBadgeWhenMuted,
393 ),
394 showDragArea: Boolean(settingsData.showDragArea),
395 enableSpellchecking: Boolean(settingsData.enableSpellchecking),
396 spellcheckerLanguage: settingsData.spellcheckerLanguage,
397 userAgentPref: settingsData.userAgentPref,
398 beta: Boolean(settingsData.beta), // we need this info in the main process as well
399 automaticUpdates: Boolean(settingsData.automaticUpdates), // we need this info in the main process as well
400 locale: settingsData.locale, // we need this info in the main process as well
401 },
402 });
403
404 user.update({
405 userData: {
406 automaticUpdates: Boolean(settingsData.automaticUpdates),
407 beta: Boolean(settingsData.beta),
408 locale: settingsData.locale,
409 },
410 });
411
412 const { keepAllWorkspacesLoaded } = workspaces.settings;
413 if (
414 Boolean(keepAllWorkspacesLoaded) !==
415 Boolean(settingsData.keepAllWorkspacesLoaded)
416 ) {
417 workspaceActions.toggleKeepAllWorkspacesLoadedSetting();
418 }
419
420 if (todos.isFeatureActive) {
421 const { isFeatureEnabledByUser } = todos.settings;
422 if (
423 Boolean(isFeatureEnabledByUser) !== Boolean(settingsData.enableTodos)
424 ) {
425 todosActions.toggleTodosFeatureVisibility();
426 }
427 }
428 }
429
430 openProcessManager() {
431 ipcRenderer.send('openProcessManager');
432 }
433
434 prepareForm() {
435 const { app, settings, user, todos, workspaces } = this.props.stores;
436 const { intl } = this.props;
437 const { lockedPassword } = this.state;
438
439 const locales = getSelectOptions({
440 locales: APP_LOCALES,
441 });
442
443 const navigationBarBehaviours = getSelectOptions({
444 locales: NAVIGATION_BAR_BEHAVIOURS,
445 sort: false,
446 });
447
448 const searchEngines = getSelectOptions({
449 locales: SEARCH_ENGINE_NAMES,
450 sort: false,
451 });
452
453 const hibernationStrategies = getSelectOptions({
454 locales: HIBERNATION_STRATEGIES,
455 sort: false,
456 });
457
458 const wakeUpStrategies = getSelectOptions({
459 locales: WAKE_UP_STRATEGIES,
460 sort: false,
461 });
462
463 const wakeUpHibernationStrategies = getSelectOptions({
464 locales: WAKE_UP_HIBERNATION_STRATEGIES,
465 sort: false,
466 });
467
468 const todoApp = getSelectOptions({
469 locales: TODO_APPS,
470 sort: false,
471 });
472
473 const sidebarWidth = getSelectOptions({
474 locales: SIDEBAR_WIDTH,
475 sort: false,
476 });
477
478 const sidebarServicesLocation = getSelectOptions({
479 locales: SIDEBAR_SERVICES_LOCATION,
480 sort: false,
481 });
482
483 const iconSizes = getSelectOptions({
484 locales: ICON_SIZES,
485 sort: false,
486 });
487
488 const spellcheckingLanguages = getSelectOptions({
489 locales: SPELLCHECKER_LOCALES,
490 automaticDetectionText: intl.formatMessage(
491 globalMessages.spellcheckerAutomaticDetection,
492 ),
493 });
494
495 const config: FormFields = {
496 fields: {
497 autoLaunchOnStart: {
498 label: intl.formatMessage(messages.autoLaunchOnStart),
499 value: app.autoLaunchOnStart,
500 default: DEFAULT_APP_SETTINGS.autoLaunchOnStart,
501 },
502 autoLaunchInBackground: {
503 label: intl.formatMessage(messages.autoLaunchInBackground),
504 value: app.launchInBackground,
505 default: DEFAULT_APP_SETTINGS.autoLaunchInBackground,
506 },
507 runInBackground: {
508 label: intl.formatMessage(messages.runInBackground),
509 value: settings.all.app.runInBackground,
510 default: DEFAULT_APP_SETTINGS.runInBackground,
511 },
512 startMinimized: {
513 label: intl.formatMessage(messages.startMinimized),
514 value: settings.all.app.startMinimized,
515 default: DEFAULT_APP_SETTINGS.startMinimized,
516 },
517 confirmOnQuit: {
518 label: intl.formatMessage(messages.confirmOnQuit),
519 value: settings.all.app.confirmOnQuit,
520 default: DEFAULT_APP_SETTINGS.confirmOnQuit,
521 },
522 enableSystemTray: {
523 label: intl.formatMessage(
524 isMac ? messages.enableMenuBar : messages.enableSystemTray,
525 ),
526 value: settings.all.app.enableSystemTray,
527 default: DEFAULT_APP_SETTINGS.enableSystemTray,
528 },
529 reloadAfterResume: {
530 label: intl.formatMessage(messages.reloadAfterResume),
531 value: settings.all.app.reloadAfterResume,
532 default: DEFAULT_APP_SETTINGS.reloadAfterResume,
533 },
534 reloadAfterResumeTime: {
535 label: intl.formatMessage(messages.reloadAfterResumeTime),
536 value: settings.all.app.reloadAfterResumeTime,
537 default: DEFAULT_APP_SETTINGS.reloadAfterResumeTime,
538 },
539 minimizeToSystemTray: {
540 label: intl.formatMessage(messages.minimizeToSystemTray),
541 value: settings.all.app.minimizeToSystemTray,
542 default: DEFAULT_APP_SETTINGS.minimizeToSystemTray,
543 },
544 closeToSystemTray: {
545 label: intl.formatMessage(messages.closeToSystemTray),
546 value: settings.all.app.closeToSystemTray,
547 default: DEFAULT_APP_SETTINGS.closeToSystemTray,
548 },
549 privateNotifications: {
550 label: intl.formatMessage(messages.privateNotifications),
551 value: settings.all.app.privateNotifications,
552 default: DEFAULT_APP_SETTINGS.privateNotifications,
553 },
554 clipboardNotifications: {
555 label: intl.formatMessage(messages.clipboardNotifications),
556 value: settings.all.app.clipboardNotifications,
557 default: DEFAULT_APP_SETTINGS.clipboardNotifications,
558 },
559 notifyTaskBarOnMessage: {
560 label: intl.formatMessage(messages.notifyTaskBarOnMessage),
561 value: settings.all.app.notifyTaskBarOnMessage,
562 default: DEFAULT_APP_SETTINGS.notifyTaskBarOnMessage,
563 },
564 navigationBarBehaviour: {
565 label: intl.formatMessage(messages.navigationBarBehaviour),
566 value: settings.all.app.navigationBarBehaviour,
567 default: DEFAULT_APP_SETTINGS.navigationBarBehaviour,
568 options: navigationBarBehaviours,
569 },
570 searchEngine: {
571 label: intl.formatMessage(messages.searchEngine),
572 value: settings.all.app.searchEngine,
573 default: DEFAULT_APP_SETTINGS.searchEngine,
574 options: searchEngines,
575 },
576 hibernateOnStartup: {
577 label: intl.formatMessage(messages.hibernateOnStartup),
578 value: settings.all.app.hibernateOnStartup,
579 default: DEFAULT_APP_SETTINGS.hibernateOnStartup,
580 },
581 hibernationStrategy: {
582 label: intl.formatMessage(messages.hibernationStrategy),
583 value: settings.all.app.hibernationStrategy,
584 options: hibernationStrategies,
585 default: DEFAULT_APP_SETTINGS.hibernationStrategy,
586 },
587 wakeUpStrategy: {
588 label: intl.formatMessage(messages.wakeUpStrategy),
589 value: settings.all.app.wakeUpStrategy,
590 options: wakeUpStrategies,
591 default: DEFAULT_APP_SETTINGS.wakeUpStrategy,
592 },
593 wakeUpHibernationStrategy: {
594 label: intl.formatMessage(messages.wakeUpHibernationStrategy),
595 value: settings.all.app.wakeUpHibernationStrategy,
596 options: wakeUpHibernationStrategies,
597 default: DEFAULT_APP_SETTINGS.wakeUpHibernationStrategy,
598 },
599 wakeUpHibernationSplay: {
600 label: intl.formatMessage(messages.wakeUpHibernationSplay),
601 value: settings.all.app.wakeUpHibernationSplay,
602 default: DEFAULT_APP_SETTINGS.wakeUpHibernationSplay,
603 },
604 predefinedTodoServer: {
605 label: intl.formatMessage(messages.predefinedTodoServer),
606 value: settings.all.app.predefinedTodoServer,
607 default: DEFAULT_APP_SETTINGS.predefinedTodoServer,
608 options: todoApp,
609 },
610 customTodoServer: {
611 label: intl.formatMessage(messages.customTodoServer),
612 value: settings.all.app.customTodoServer,
613 default: DEFAULT_APP_SETTINGS.customTodoServer,
614 },
615 lockingFeatureEnabled: {
616 label: intl.formatMessage(messages.enableLock),
617 value: settings.all.app.lockingFeatureEnabled || false,
618 default: DEFAULT_APP_SETTINGS.lockingFeatureEnabled,
619 },
620 lockedPassword: {
621 label: intl.formatMessage(messages.lockPassword),
622 value: lockedPassword,
623 default: '',
624 type: 'password',
625 },
626 useTouchIdToUnlock: {
627 label: intl.formatMessage(messages.useTouchIdToUnlock),
628 value: settings.all.app.useTouchIdToUnlock,
629 default: DEFAULT_APP_SETTINGS.useTouchIdToUnlock,
630 },
631 inactivityLock: {
632 label: intl.formatMessage(messages.inactivityLock),
633 value: settings.all.app.inactivityLock,
634 default: 0,
635 type: 'number',
636 },
637 scheduledDNDEnabled: {
638 label: intl.formatMessage(messages.scheduledDNDEnabled),
639 value: settings.all.app.scheduledDNDEnabled || false,
640 default: DEFAULT_APP_SETTINGS.scheduledDNDEnabled,
641 },
642 scheduledDNDStart: {
643 label: intl.formatMessage(messages.scheduledDNDStart),
644 value: settings.all.app.scheduledDNDStart,
645 default: '17:00',
646 type: 'time',
647 },
648 scheduledDNDEnd: {
649 label: intl.formatMessage(messages.scheduledDNDEnd),
650 value: settings.all.app.scheduledDNDEnd,
651 default: '09:00',
652 type: 'time',
653 },
654 showDisabledServices: {
655 label: intl.formatMessage(messages.showDisabledServices),
656 value: settings.all.app.showDisabledServices,
657 default: DEFAULT_APP_SETTINGS.showDisabledServices,
658 },
659 showServiceName: {
660 label: intl.formatMessage(messages.showServiceName),
661 value: settings.all.app.showServiceName,
662 default: DEFAULT_APP_SETTINGS.showServiceName,
663 },
664 showMessageBadgeWhenMuted: {
665 label: intl.formatMessage(messages.showMessageBadgeWhenMuted),
666 value: settings.all.app.showMessageBadgeWhenMuted,
667 default: DEFAULT_APP_SETTINGS.showMessageBadgeWhenMuted,
668 },
669 showDragArea: {
670 label: intl.formatMessage(messages.showDragArea),
671 value: settings.all.app.showDragArea,
672 default: DEFAULT_APP_SETTINGS.showDragArea,
673 },
674 enableSpellchecking: {
675 label: intl.formatMessage(messages.enableSpellchecking),
676 value: settings.all.app.enableSpellchecking,
677 default: DEFAULT_APP_SETTINGS.enableSpellchecking,
678 },
679 spellcheckerLanguage: {
680 label: intl.formatMessage(globalMessages.spellcheckerLanguage),
681 value: settings.all.app.spellcheckerLanguage,
682 options: spellcheckingLanguages,
683 default: DEFAULT_APP_SETTINGS.spellcheckerLanguage,
684 },
685 userAgentPref: {
686 label: intl.formatMessage(globalMessages.userAgentPref),
687 value: settings.all.app.userAgentPref,
688 default: DEFAULT_APP_SETTINGS.userAgentPref,
689 placeholder: defaultUserAgent(),
690 },
691 darkMode: {
692 label: intl.formatMessage(messages.darkMode),
693 value: settings.all.app.darkMode,
694 default: DEFAULT_APP_SETTINGS.darkMode,
695 },
696 adaptableDarkMode: {
697 label: intl.formatMessage(messages.adaptableDarkMode),
698 value: settings.all.app.adaptableDarkMode,
699 default: DEFAULT_APP_SETTINGS.adaptableDarkMode,
700 },
701 universalDarkMode: {
702 label: intl.formatMessage(messages.universalDarkMode),
703 value: settings.all.app.universalDarkMode,
704 default: DEFAULT_APP_SETTINGS.universalDarkMode,
705 },
706 splitMode: {
707 label: intl.formatMessage(messages.splitMode),
708 value: settings.all.app.splitMode,
709 default: DEFAULT_APP_SETTINGS.splitMode,
710 },
711 splitColumns: {
712 label: `${intl.formatMessage(
713 messages.splitColumns,
714 )} (${SPLIT_COLUMNS_MIN}-${SPLIT_COLUMNS_MAX})`,
715 value: settings.all.app.splitColumns,
716 default: DEFAULT_APP_SETTINGS.splitColumns,
717 },
718 serviceRibbonWidth: {
719 label: intl.formatMessage(messages.serviceRibbonWidth),
720 value: settings.all.app.serviceRibbonWidth,
721 default: DEFAULT_APP_SETTINGS.serviceRibbonWidth,
722 options: sidebarWidth,
723 },
724 sidebarServicesLocation: {
725 label: intl.formatMessage(messages.sidebarServicesLocation),
726 value: settings.all.app.sidebarServicesLocation,
727 default: DEFAULT_APP_SETTINGS.sidebarServicesLocation,
728 options: sidebarServicesLocation,
729 },
730 iconSize: {
731 label: intl.formatMessage(messages.iconSize),
732 value: settings.all.app.iconSize,
733 default: DEFAULT_APP_SETTINGS.iconSize,
734 options: iconSizes,
735 },
736 enableLongPressServiceHint: {
737 label: intl.formatMessage(messages.enableLongPressServiceHint),
738 value: settings.all.app.enableLongPressServiceHint,
739 default: DEFAULT_APP_SETTINGS.enableLongPressServiceHint,
740 },
741 useVerticalStyle: {
742 label: intl.formatMessage(messages.useVerticalStyle),
743 value: settings.all.app.useVerticalStyle,
744 default: DEFAULT_APP_SETTINGS.useVerticalStyle,
745 },
746 hideCollapseButton: {
747 label: intl.formatMessage(messages.hideCollapseButton),
748 value: settings.all.app.hideCollapseButton,
749 default: DEFAULT_APP_SETTINGS.hideCollapseButton,
750 },
751 hideRecipesButton: {
752 label: intl.formatMessage(messages.hideRecipesButton),
753 value: settings.all.app.hideRecipesButton,
754 default: DEFAULT_APP_SETTINGS.hideRecipesButton,
755 },
756 hideSplitModeButton: {
757 label: intl.formatMessage(messages.hideSplitModeButton),
758 value: settings.all.app.hideSplitModeButton,
759 default: DEFAULT_APP_SETTINGS.hideSplitModeButton,
760 },
761 useGrayscaleServices: {
762 label: intl.formatMessage(messages.useGrayscaleServices),
763 value: settings.all.app.useGrayscaleServices,
764 default: DEFAULT_APP_SETTINGS.useGrayscaleServices,
765 },
766 grayscaleServicesDim: {
767 label: intl.formatMessage(messages.grayscaleServicesDim),
768 value: settings.all.app.grayscaleServicesDim,
769 default: DEFAULT_APP_SETTINGS.grayscaleServicesDim,
770 },
771 hideWorkspacesButton: {
772 label: intl.formatMessage(messages.hideWorkspacesButton),
773 value: settings.all.app.hideWorkspacesButton,
774 default: DEFAULT_APP_SETTINGS.hideWorkspacesButton,
775 },
776 hideNotificationsButton: {
777 label: intl.formatMessage(messages.hideNotificationsButton),
778 value: settings.all.app.hideNotificationsButton,
779 default: DEFAULT_APP_SETTINGS.hideNotificationsButton,
780 },
781 hideSettingsButton: {
782 label: intl.formatMessage(messages.hideSettingsButton),
783 value: settings.all.app.hideSettingsButton,
784 default: DEFAULT_APP_SETTINGS.hideSettingsButton,
785 },
786 alwaysShowWorkspaces: {
787 label: intl.formatMessage(messages.alwaysShowWorkspaces),
788 value: settings.all.app.alwaysShowWorkspaces,
789 default: DEFAULT_APP_SETTINGS.alwaysShowWorkspaces,
790 },
791 accentColor: {
792 label: intl.formatMessage(messages.accentColor),
793 value: settings.all.app.accentColor,
794 default: DEFAULT_APP_SETTINGS.accentColor,
795 },
796 progressbarAccentColor: {
797 label: intl.formatMessage(messages.progressbarAccentColor),
798 value: settings.all.app.progressbarAccentColor,
799 default: DEFAULT_APP_SETTINGS.progressbarAccentColor,
800 },
801 enableGPUAcceleration: {
802 label: intl.formatMessage(messages.enableGPUAcceleration),
803 value: settings.all.app.enableGPUAcceleration,
804 default: DEFAULT_APP_SETTINGS.enableGPUAcceleration,
805 },
806 enableGlobalHideShortcut: {
807 label: intl.formatMessage(messages.enableGlobalHideShortcut),
808 value: settings.all.app.enableGlobalHideShortcut,
809 default: DEFAULT_APP_SETTINGS.enableGlobalHideShortcut,
810 },
811 locale: {
812 label: intl.formatMessage(messages.language),
813 value: app.locale,
814 options: locales,
815 default: DEFAULT_APP_SETTINGS.locale,
816 },
817 beta: {
818 label: intl.formatMessage(messages.beta),
819 value: user.data.beta,
820 default: DEFAULT_APP_SETTINGS.beta,
821 },
822 automaticUpdates: {
823 label: intl.formatMessage(messages.automaticUpdates),
824 value: settings.app.automaticUpdates,
825 default: DEFAULT_APP_SETTINGS.automaticUpdates,
826 },
827 },
828 };
829
830 if (workspaces.isFeatureActive) {
831 config.fields.keepAllWorkspacesLoaded = {
832 label: intl.formatMessage(messages.keepAllWorkspacesLoaded),
833 value: workspaces.settings.keepAllWorkspacesLoaded,
834 default: DEFAULT_SETTING_KEEP_ALL_WORKSPACES_LOADED,
835 };
836 }
837
838 if (todos.isFeatureActive) {
839 config.fields.enableTodos = {
840 label: intl.formatMessage(messages.enableTodos),
841 value: todos.settings.isFeatureEnabledByUser,
842 default: DEFAULT_IS_FEATURE_ENABLED_BY_USER,
843 };
844 }
845
846 // @ts-ignore: Remove this ignore once mobx-react-form v4 with typescript
847 // support has been released.
848 return new Form(config);
849 }
850
851 render(): ReactElement {
852 const { app, services } = this.props.stores;
853 const {
854 updateStatus,
855 updateStatusTypes,
856 isClearingAllCache,
857 lockingFeatureEnabled,
858 } = app;
859 const { checkForUpdates, installUpdate, clearAllCache } =
860 this.props.actions.app;
861 const form = this.prepareForm();
862
863 return (
864 <ErrorBoundary>
865 <EditSettingsForm
866 form={form}
867 checkForUpdates={checkForUpdates}
868 installUpdate={installUpdate}
869 isCheckingForUpdates={updateStatus === updateStatusTypes.CHECKING}
870 isUpdateAvailable={updateStatus === updateStatusTypes.AVAILABLE}
871 noUpdateAvailable={updateStatus === updateStatusTypes.NOT_AVAILABLE}
872 updateIsReadyToInstall={updateStatus === updateStatusTypes.DOWNLOADED}
873 updateFailed={updateStatus === updateStatusTypes.FAILED}
874 showServicesUpdatedInfoBar={
875 this.props.stores.ui.showServicesUpdatedInfoBar
876 }
877 onSubmit={d => this.onSubmit(d)}
878 getCacheSize={() => app.cacheSize}
879 isClearingAllCache={isClearingAllCache}
880 onClearAllCache={clearAllCache}
881 lockingFeatureEnabled={lockingFeatureEnabled}
882 automaticUpdates={this.props.stores.settings.app.automaticUpdates}
883 isDarkmodeEnabled={this.props.stores.settings.app.darkMode}
884 isAdaptableDarkModeEnabled={
885 this.props.stores.settings.app.adaptableDarkMode
886 }
887 isUseGrayscaleServicesEnabled={
888 this.props.stores.settings.app.useGrayscaleServices
889 }
890 isSplitModeEnabled={this.props.stores.settings.app.splitMode}
891 isTodosActivated={this.props.stores.todos.isFeatureEnabledByUser}
892 isUsingCustomTodoService={
893 this.props.stores.todos.isUsingCustomTodoService
894 }
895 openProcessManager={() => this.openProcessManager()}
896 hasAddedTodosAsService={services.isTodosServiceAdded}
897 isOnline={app.isOnline}
898 />
899 </ErrorBoundary>
900 );
901 }
902}
903
904export default injectIntl(
905 inject('stores', 'actions')(observer(EditSettingsScreen)),
906);