aboutsummaryrefslogtreecommitdiffstats
path: root/src/containers/settings/EditSettingsScreen.js
diff options
context:
space:
mode:
authorLibravatar Ricardo Cino <ricardo@cino.io>2022-06-27 18:21:31 +0200
committerLibravatar GitHub <noreply@github.com>2022-06-27 17:21:31 +0100
commit0bf13689d53bd493fb4d0a4213c1801013b5aa8a (patch)
tree2b5ae44e4f1aa73b49c011954ff1cb47e3959bad /src/containers/settings/EditSettingsScreen.js
parentchore: recommend specific vscode extensions to setup development [skip ci] (#... (diff)
downloadferdium-app-0bf13689d53bd493fb4d0a4213c1801013b5aa8a.tar.gz
ferdium-app-0bf13689d53bd493fb4d0a4213c1801013b5aa8a.tar.zst
ferdium-app-0bf13689d53bd493fb4d0a4213c1801013b5aa8a.zip
chore: transform containers/settings from js to tsx (#384)
Diffstat (limited to 'src/containers/settings/EditSettingsScreen.js')
-rw-r--r--src/containers/settings/EditSettingsScreen.js918
1 files changed, 0 insertions, 918 deletions
diff --git a/src/containers/settings/EditSettingsScreen.js b/src/containers/settings/EditSettingsScreen.js
deleted file mode 100644
index 867db6f08..000000000
--- a/src/containers/settings/EditSettingsScreen.js
+++ /dev/null
@@ -1,918 +0,0 @@
1import { ipcRenderer } from 'electron';
2import { Component } from 'react';
3import PropTypes from 'prop-types';
4import { inject, observer } from 'mobx-react';
5import { defineMessages, injectIntl } from 'react-intl';
6
7import AppStore from '../../stores/AppStore';
8import SettingsStore from '../../stores/SettingsStore';
9import UserStore from '../../stores/UserStore';
10import TodosStore from '../../features/todos/store';
11import Form from '../../lib/Form';
12import { APP_LOCALES, SPELLCHECKER_LOCALES } from '../../i18n/languages';
13import {
14 DEFAULT_APP_SETTINGS,
15 HIBERNATION_STRATEGIES,
16 SIDEBAR_WIDTH,
17 SIDEBAR_SERVICES_LOCATION,
18 ICON_SIZES,
19 NAVIGATION_BAR_BEHAVIOURS,
20 SEARCH_ENGINE_NAMES,
21 TODO_APPS,
22 DEFAULT_SETTING_KEEP_ALL_WORKSPACES_LOADED,
23 DEFAULT_IS_FEATURE_ENABLED_BY_USER,
24 WAKE_UP_STRATEGIES,
25 WAKE_UP_HIBERNATION_STRATEGIES,
26 SPLIT_COLUMNS_MIN,
27 SPLIT_COLUMNS_MAX,
28} from '../../config';
29import { isMac } from '../../environment';
30
31import { getSelectOptions } from '../../helpers/i18n-helpers';
32import { hash } from '../../helpers/password-helpers';
33import defaultUserAgent from '../../helpers/userAgent-helpers';
34
35import EditSettingsForm from '../../components/settings/settings/EditSettingsForm';
36import ErrorBoundary from '../../components/util/ErrorBoundary';
37
38import globalMessages from '../../i18n/globalMessages';
39import WorkspacesStore from '../../features/workspaces/store';
40import ServicesStore from '../../stores/ServicesStore';
41
42const debug = require('../../preload-safe-debug')('Ferdium:EditSettingsScreen');
43
44const messages = defineMessages({
45 autoLaunchOnStart: {
46 id: 'settings.app.form.autoLaunchOnStart',
47 defaultMessage: 'Launch Ferdium on start',
48 },
49 autoLaunchInBackground: {
50 id: 'settings.app.form.autoLaunchInBackground',
51 defaultMessage: 'Open in background',
52 },
53 runInBackground: {
54 id: 'settings.app.form.runInBackground',
55 defaultMessage: 'Keep Ferdium in background when closing the window',
56 },
57 startMinimized: {
58 id: 'settings.app.form.startMinimized',
59 defaultMessage: 'Start minimized',
60 },
61 confirmOnQuit: {
62 id: 'settings.app.form.confirmOnQuit',
63 defaultMessage: 'Confirm when quitting Ferdium',
64 },
65 enableSystemTray: {
66 id: 'settings.app.form.enableSystemTray',
67 defaultMessage: 'Always show Ferdium in System Tray',
68 },
69 enableMenuBar: {
70 id: 'settings.app.form.enableMenuBar',
71 defaultMessage: 'Always show Ferdium in Menu Bar',
72 },
73 reloadAfterResume: {
74 id: 'settings.app.form.reloadAfterResume',
75 defaultMessage: 'Reload Ferdium after system resume',
76 },
77 reloadAfterResumeTime: {
78 id: 'settings.app.form.reloadAfterResumeTime',
79 defaultMessage: 'Time to consider the system as idle/suspended (in minutes)',
80 },
81 minimizeToSystemTray: {
82 id: 'settings.app.form.minimizeToSystemTray',
83 defaultMessage: 'Minimize Ferdium to system tray',
84 },
85 closeToSystemTray: {
86 id: 'settings.app.form.closeToSystemTray',
87 defaultMessage: 'Close Ferdium to system tray',
88 },
89 privateNotifications: {
90 id: 'settings.app.form.privateNotifications',
91 defaultMessage: "Don't show message content in notifications",
92 },
93 clipboardNotifications: {
94 id: 'settings.app.form.clipboardNotifications',
95 defaultMessage: "Don't show notifications for clipboard events",
96 },
97 notifyTaskBarOnMessage: {
98 id: 'settings.app.form.notifyTaskBarOnMessage',
99 defaultMessage: 'Notify TaskBar/Dock on new message',
100 },
101 navigationBarBehaviour: {
102 id: 'settings.app.form.navigationBarBehaviour',
103 defaultMessage: 'Navigation bar behaviour',
104 },
105 searchEngine: {
106 id: 'settings.app.form.searchEngine',
107 defaultMessage: 'Search engine',
108 },
109 hibernateOnStartup: {
110 id: 'settings.app.form.hibernateOnStartup',
111 defaultMessage: 'Keep services in hibernation on startup',
112 },
113 hibernationStrategy: {
114 id: 'settings.app.form.hibernationStrategy',
115 defaultMessage: 'Hibernation strategy',
116 },
117 wakeUpStrategy: {
118 id: 'settings.app.form.wakeUpStrategy',
119 defaultMessage: 'Wake up strategy',
120 },
121 wakeUpHibernationStrategy: {
122 id: 'settings.app.form.wakeUpHibernationStrategy',
123 defaultMessage: 'Hibernation strategy after automatic wake up',
124 },
125 wakeUpHibernationSplay: {
126 id: 'settings.app.form.wakeUpHibernationSplay',
127 defaultMessage: 'Splay hibernate/wake cycles to reduce load',
128 },
129 predefinedTodoServer: {
130 id: 'settings.app.form.predefinedTodoServer',
131 defaultMessage: 'Todo Server',
132 },
133 customTodoServer: {
134 id: 'settings.app.form.customTodoServer',
135 defaultMessage: 'Custom Todo Server',
136 },
137 enableLock: {
138 id: 'settings.app.form.enableLock',
139 defaultMessage: 'Enable Password Lock',
140 },
141 lockPassword: {
142 id: 'settings.app.form.lockPassword',
143 defaultMessage: 'Password',
144 },
145 useTouchIdToUnlock: {
146 id: 'settings.app.form.useTouchIdToUnlock',
147 defaultMessage: 'Allow using TouchID to unlock Ferdium',
148 },
149 inactivityLock: {
150 id: 'settings.app.form.inactivityLock',
151 defaultMessage: 'Lock after inactivity',
152 },
153 scheduledDNDEnabled: {
154 id: 'settings.app.form.scheduledDNDEnabled',
155 defaultMessage: 'Enable scheduled Do-not-Disturb',
156 },
157 scheduledDNDStart: {
158 id: 'settings.app.form.scheduledDNDStart',
159 defaultMessage: 'From',
160 },
161 scheduledDNDEnd: {
162 id: 'settings.app.form.scheduledDNDEnd',
163 defaultMessage: 'To',
164 },
165 language: {
166 id: 'settings.app.form.language',
167 defaultMessage: 'Language',
168 },
169 darkMode: {
170 id: 'settings.app.form.darkMode',
171 defaultMessage: 'Enable Dark Mode',
172 },
173 adaptableDarkMode: {
174 id: 'settings.app.form.adaptableDarkMode',
175 defaultMessage: "Synchronize dark mode with my OS's dark mode setting",
176 },
177 universalDarkMode: {
178 id: 'settings.app.form.universalDarkMode',
179 defaultMessage: 'Enable universal Dark Mode',
180 },
181 splitMode: {
182 id: 'settings.app.form.splitMode',
183 defaultMessage: 'Enable Split View Mode',
184 },
185 splitColumns: {
186 id: 'settings.app.form.splitColumns',
187 defaultMessage: 'Number of columns',
188 },
189 serviceRibbonWidth: {
190 id: 'settings.app.form.serviceRibbonWidth',
191 defaultMessage: 'Sidebar width',
192 },
193 sidebarServicesLocation: {
194 id: 'settings.app.form.sidebarServicesLocation',
195 defaultMessage: 'Sidebar Services Icons Location',
196 },
197 iconSize: {
198 id: 'settings.app.form.iconSize',
199 defaultMessage: 'Service icon size',
200 },
201 enableLongPressServiceHint: {
202 id: 'settings.app.form.enableLongPressServiceHint',
203 defaultMessage: 'Enable service shortcut hint on long press',
204 },
205 useVerticalStyle: {
206 id: 'settings.app.form.useVerticalStyle',
207 defaultMessage: 'Use horizontal style',
208 },
209 hideCollapseButton: {
210 id: 'settings.app.form.hideCollapseButton',
211 defaultMessage: 'Hide Collapse button',
212 },
213 hideRecipesButton: {
214 id: 'settings.app.form.hideRecipesButton',
215 defaultMessage: 'Hide Recipes button',
216 },
217 hideSplitModeButton: {
218 id: 'settings.app.form.hideSplitModeButton',
219 defaultMessage: 'Hide Split Mode button',
220 },
221 useGrayscaleServices: {
222 id: 'settings.app.form.useGrayscaleServices',
223 defaultMessage: 'Use grayscale services',
224 },
225 grayscaleServicesDim: {
226 id: 'settings.app.form.grayscaleServicesDim',
227 defaultMessage: 'Grayscale dim level',
228 },
229 hideWorkspacesButton: {
230 id: 'settings.app.form.hideWorkspacesButton',
231 defaultMessage: 'Hide Workspace Drawer button',
232 },
233 hideNotificationsButton: {
234 id: 'settings.app.form.hideNotificationsButton',
235 defaultMessage: 'Hide Notifications & Sound button',
236 },
237 hideSettingsButton: {
238 id: 'settings.app.form.hideSettingsButton',
239 defaultMessage: 'Hide Settings button',
240 },
241 alwaysShowWorkspaces: {
242 id: 'settings.app.form.alwaysShowWorkspaces',
243 defaultMessage: 'Always show workspace drawer',
244 },
245 accentColor: {
246 id: 'settings.app.form.accentColor',
247 defaultMessage: 'Accent color',
248 },
249 progressbarAccentColor: {
250 id: 'settings.app.form.progressbarAccentColor',
251 defaultMessage: 'Progressbar Accent color',
252 },
253 showDisabledServices: {
254 id: 'settings.app.form.showDisabledServices',
255 defaultMessage: 'Display disabled services tabs',
256 },
257 showServiceName: {
258 id: 'settings.app.form.showServiceName',
259 defaultMessage: 'Display service name under the icon',
260 },
261 showMessageBadgeWhenMuted: {
262 id: 'settings.app.form.showMessagesBadgesWhenMuted',
263 defaultMessage: 'Show unread message badge when notifications are disabled',
264 },
265 showDragArea: {
266 id: 'settings.app.form.showDragArea',
267 defaultMessage: 'Show draggable area on window',
268 },
269 enableSpellchecking: {
270 id: 'settings.app.form.enableSpellchecking',
271 defaultMessage: 'Enable spell checking',
272 },
273 enableGPUAcceleration: {
274 id: 'settings.app.form.enableGPUAcceleration',
275 defaultMessage: 'Enable GPU Acceleration',
276 },
277 enableGlobalHideShortcut: {
278 id: 'settings.app.form.enableGlobalHideShortcut',
279 defaultMessage: 'Enable Global shortcut to hide Ferdium',
280 },
281 beta: {
282 id: 'settings.app.form.beta',
283 defaultMessage: 'Include pre-releases',
284 },
285 automaticUpdates: {
286 id: 'settings.app.form.automaticUpdates',
287 defaultMessage: 'Enable updates',
288 },
289 enableTodos: {
290 id: 'settings.app.form.enableTodos',
291 defaultMessage: 'Enable Ferdium Todos',
292 },
293 keepAllWorkspacesLoaded: {
294 id: 'settings.app.form.keepAllWorkspacesLoaded',
295 defaultMessage: 'Keep all workspaces loaded',
296 },
297});
298
299class EditSettingsScreen extends Component {
300 constructor(props) {
301 super(props);
302
303 this.state = {
304 lockedPassword: '',
305 };
306 }
307
308 onSubmit(settingsData) {
309 const { todos, workspaces } = this.props.stores;
310 const {
311 app,
312 settings,
313 user,
314 todos: todosActions,
315 workspaces: workspaceActions,
316 } = this.props.actions;
317
318 const useOriginalPassword = settingsData.lockedPassword === '';
319
320 this.setState({
321 lockedPassword: useOriginalPassword ? '' : settingsData.lockedPassword,
322 });
323
324 app.launchOnStartup({
325 enable: Boolean(settingsData.autoLaunchOnStart),
326 openInBackground: Boolean(settingsData.autoLaunchInBackground),
327 });
328
329 debug(`Updating settings store with data: ${settingsData}`);
330
331 settings.update({
332 type: 'app',
333 // TODO: The conversions might not be necessary once we convert to typescript
334 data: {
335 runInBackground: Boolean(settingsData.runInBackground),
336 enableSystemTray: Boolean(settingsData.enableSystemTray),
337 reloadAfterResume: Boolean(settingsData.reloadAfterResume),
338 reloadAfterResumeTime: Number(settingsData.reloadAfterResumeTime),
339 startMinimized: Boolean(settingsData.startMinimized),
340 confirmOnQuit: Boolean(settingsData.confirmOnQuit),
341 minimizeToSystemTray: Boolean(settingsData.minimizeToSystemTray),
342 closeToSystemTray: Boolean(settingsData.closeToSystemTray),
343 privateNotifications: Boolean(settingsData.privateNotifications),
344 clipboardNotifications: Boolean(settingsData.clipboardNotifications),
345 notifyTaskBarOnMessage: Boolean(settingsData.notifyTaskBarOnMessage),
346 navigationBarBehaviour: settingsData.navigationBarBehaviour,
347 searchEngine: settingsData.searchEngine,
348 hibernateOnStartup: Boolean(settingsData.hibernateOnStartup),
349 hibernationStrategy: Number(settingsData.hibernationStrategy),
350 wakeUpStrategy: Number(settingsData.wakeUpStrategy),
351 wakeUpHibernationStrategy: Number(settingsData.wakeUpHibernationStrategy),
352 wakeUpHibernationSplay: Boolean(settingsData.wakeUpHibernationSplay),
353 predefinedTodoServer: settingsData.predefinedTodoServer,
354 customTodoServer: settingsData.customTodoServer,
355 lockingFeatureEnabled: Boolean(settingsData.lockingFeatureEnabled),
356 lockedPassword: useOriginalPassword ? this.props.stores.settings.all.app.lockedPassword : 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 = {
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 return new Form(config);
847 }
848
849 render() {
850 const { app, services } = this.props.stores;
851 const {
852 updateStatus,
853 updateStatusTypes,
854 isClearingAllCache,
855 lockingFeatureEnabled,
856 } = app;
857 const { checkForUpdates, installUpdate, clearAllCache } =
858 this.props.actions.app;
859 const form = this.prepareForm();
860
861 return (
862 <ErrorBoundary>
863 <EditSettingsForm
864 form={form}
865 checkForUpdates={checkForUpdates}
866 installUpdate={installUpdate}
867 isCheckingForUpdates={updateStatus === updateStatusTypes.CHECKING}
868 isUpdateAvailable={updateStatus === updateStatusTypes.AVAILABLE}
869 noUpdateAvailable={updateStatus === updateStatusTypes.NOT_AVAILABLE}
870 updateIsReadyToInstall={updateStatus === updateStatusTypes.DOWNLOADED}
871 updateFailed={updateStatus === updateStatusTypes.FAILED}
872 showServicesUpdatedInfoBar={this.props.stores.ui.showServicesUpdatedInfoBar}
873 onSubmit={d => this.onSubmit(d)}
874 getCacheSize={() => app.cacheSize}
875 isClearingAllCache={isClearingAllCache}
876 onClearAllCache={clearAllCache}
877 lockingFeatureEnabled={lockingFeatureEnabled}
878 automaticUpdates={this.props.stores.settings.app.automaticUpdates}
879 isDarkmodeEnabled={this.props.stores.settings.app.darkMode}
880 isAdaptableDarkModeEnabled={
881 this.props.stores.settings.app.adaptableDarkMode
882 }
883 isUseGrayscaleServicesEnabled={this.props.stores.settings.app.useGrayscaleServices}
884 isSplitModeEnabled={this.props.stores.settings.app.splitMode}
885 isTodosActivated={this.props.stores.todos.isFeatureEnabledByUser}
886 isUsingCustomTodoService={
887 this.props.stores.todos.isUsingCustomTodoService
888 }
889 openProcessManager={() => this.openProcessManager()}
890 hasAddedTodosAsService={services.isTodosServiceAdded}
891 isOnline={app.isOnline}
892 />
893 </ErrorBoundary>
894 );
895 }
896}
897
898EditSettingsScreen.propTypes = {
899 stores: PropTypes.shape({
900 app: PropTypes.instanceOf(AppStore).isRequired,
901 user: PropTypes.instanceOf(UserStore).isRequired,
902 settings: PropTypes.instanceOf(SettingsStore).isRequired,
903 services: PropTypes.instanceOf(ServicesStore).isRequired,
904 todos: PropTypes.instanceOf(TodosStore).isRequired,
905 workspaces: PropTypes.instanceOf(WorkspacesStore).isRequired,
906 }).isRequired,
907 actions: PropTypes.shape({
908 app: PropTypes.instanceOf(AppStore).isRequired,
909 user: PropTypes.instanceOf(UserStore).isRequired,
910 settings: PropTypes.instanceOf(SettingsStore).isRequired,
911 todos: PropTypes.instanceOf(TodosStore).isRequired,
912 workspaces: PropTypes.instanceOf(WorkspacesStore).isRequired,
913 }).isRequired,
914};
915
916export default injectIntl(
917 inject('stores', 'actions')(observer(EditSettingsScreen)),
918);