From dc80abc1f4a626c923d0f0d8739173809000df60 Mon Sep 17 00:00:00 2001 From: André Oliveira <37463445+SpecialAro@users.noreply.github.com> Date: Mon, 4 Jul 2022 15:24:58 +0100 Subject: Fix bug of TODO settings not being shown when a TODO Recipe is present (#421) Fix #281 --- .../settings/settings/EditSettingsForm.js | 1020 ------------------- .../settings/settings/EditSettingsForm.jsx | 1039 ++++++++++++++++++++ src/containers/settings/EditSettingsScreen.tsx | 3 +- 3 files changed, 1040 insertions(+), 1022 deletions(-) delete mode 100644 src/components/settings/settings/EditSettingsForm.js create mode 100644 src/components/settings/settings/EditSettingsForm.jsx diff --git a/src/components/settings/settings/EditSettingsForm.js b/src/components/settings/settings/EditSettingsForm.js deleted file mode 100644 index 56d7b8905..000000000 --- a/src/components/settings/settings/EditSettingsForm.js +++ /dev/null @@ -1,1020 +0,0 @@ -import { systemPreferences } from '@electron/remote'; -import { Component } from 'react'; -import PropTypes from 'prop-types'; -import { observer } from 'mobx-react'; -import prettyBytes from 'pretty-bytes'; -import { defineMessages, injectIntl } from 'react-intl'; - -import { mdiGithub, mdiOpenInNew, mdiPowerPlug } from '@mdi/js'; - -import Form from '../../../lib/Form'; -import Button from '../../ui/button'; -import Toggle from '../../ui/Toggle'; -import Select from '../../ui/Select'; -import Input from '../../ui/Input'; -import ColorPickerInput from '../../ui/ColorPickerInput'; -import Infobox from '../../ui/Infobox'; -import { H1, H2, H3, H5 } from '../../ui/headline'; - -import { - DEFAULT_APP_SETTINGS, - FRANZ_TRANSLATION, - GITHUB_FRANZ_URL, - SPLIT_COLUMNS_MAX, - SPLIT_COLUMNS_MIN, -} from '../../../config'; -import { isMac, isWindows, lockFerdiumShortcutKey } from '../../../environment'; -import { - ferdiumVersion, - userDataPath, - userDataRecipesPath, -} from '../../../environment-remote'; -import { openPath } from '../../../helpers/url-helpers'; -import globalMessages from '../../../i18n/globalMessages'; -import Icon from '../../ui/icon'; -import Slider from '../../ui/Slider'; - -const debug = require('../../../preload-safe-debug')('Ferdium:EditSettingsForm'); - -const messages = defineMessages({ - headlineGeneral: { - id: 'settings.app.headlineGeneral', - defaultMessage: 'General', - }, - hibernateInfo: { - id: 'settings.app.hibernateInfo', - defaultMessage: - 'By default, Ferdium will keep all your services open and loaded in the background so they are ready when you want to use them. Service Hibernation will unload your services after a specified amount. This is useful to save RAM or keeping services from slowing down your computer.', - }, - inactivityLockInfo: { - id: 'settings.app.inactivityLockInfo', - defaultMessage: - 'Minutes of inactivity, after which Ferdium should automatically lock. Use 0 to disable', - }, - todoServerInfo: { - id: 'settings.app.todoServerInfo', - defaultMessage: 'This server will be used for the "Ferdium Todo" feature.', - }, - lockedPassword: { - id: 'settings.app.lockedPassword', - defaultMessage: 'Password', - }, - lockedPasswordInfo: { - id: 'settings.app.lockedPasswordInfo', - defaultMessage: - "Please make sure to set a password you'll remember.\nIf you loose this password, you will have to reinstall Ferdium.", - }, - lockInfo: { - id: 'settings.app.lockInfo', - defaultMessage: - 'Password Lock allows you to keep your messages protected.\nUsing Password Lock, you will be prompted to enter your password everytime you start Ferdium or lock Ferdium yourself using the lock symbol in the bottom left corner or the shortcut {lockShortcut}.', - }, - scheduledDNDTimeInfo: { - id: 'settings.app.scheduledDNDTimeInfo', - defaultMessage: - 'Times in 24-Hour-Format. End time can be before start time (e.g. start 17:00, end 09:00) to enable Do-not-Disturb overnight.', - }, - scheduledDNDInfo: { - id: 'settings.app.scheduledDNDInfo', - defaultMessage: - 'Scheduled Do-not-Disturb allows you to define a period of time in which you do not want to get Notifications from Ferdium.', - }, - headlineLanguage: { - id: 'settings.app.headlineLanguage', - defaultMessage: 'Language', - }, - headlineUpdates: { - id: 'settings.app.headlineUpdates', - defaultMessage: 'Updates', - }, - headlineAppearance: { - id: 'settings.app.headlineAppearance', - defaultMessage: 'Appearance', - }, - sectionMain: { - id: 'settings.app.sectionMain', - defaultMessage: 'Main', - }, - sectionHibernation: { - id: 'settings.app.sectionHibernation', - defaultMessage: 'Hibernation', - }, - sectionGeneralUi: { - id: 'settings.app.sectionGeneralUi', - defaultMessage: 'General UI', - }, - sectionSidebarSettings: { - id: 'settings.app.sectionSidebarSettings', - defaultMessage: 'Sidebar Settings', - }, - sectionPrivacy: { - id: 'settings.app.sectionPrivacy', - defaultMessage: 'Privacy Settings', - }, - sectionLanguage: { - id: 'settings.app.sectionLanguage', - defaultMessage: 'Language Settings', - }, - sectionAdvanced: { - id: 'settings.app.sectionAdvanced', - defaultMessage: 'Advanced Settings', - }, - sectionUpdates: { - id: 'settings.app.sectionUpdates', - defaultMessage: 'App Updates Settings', - }, - sectionServiceIconsSettings: { - id: 'settings.app.sectionServiceIconsSettings', - defaultMessage: 'Service Icons Settings', - }, - sectionAccentColorSettings: { - id: 'settings.app.sectionAccentColorSettings', - defaultMessage: 'Accent Color Settings', - }, - accentColorInfo: { - id: 'settings.app.accentColorInfo', - defaultMessage: - 'Write your color choice in a CSS-compatible format. (Default: {defaultAccentColor} or clear the input field)', - }, - overallTheme: { - id: 'settings.app.overallTheme', - defaultMessage: 'Overall Theme', - }, - progressbarTheme: { - id: 'settings.app.progressbarTheme', - defaultMessage: 'Progressbar Theme', - }, - universalDarkModeInfo: { - id: 'settings.app.universalDarkModeInfo', - defaultMessage: - 'Universal Dark Mode tries to dynamically generate dark mode styles for services that are otherwise not currently supported.', - }, - headlinePrivacy: { - id: 'settings.app.headlinePrivacy', - defaultMessage: 'Privacy', - }, - headlineAdvanced: { - id: 'settings.app.headlineAdvanced', - defaultMessage: 'Advanced', - }, - translationHelp: { - id: 'settings.app.translationHelp', - defaultMessage: 'Help us to translate Ferdium into your language.', - }, - spellCheckerLanguageInfo: { - id: 'settings.app.spellCheckerLanguageInfo', - defaultMessage: - "Ferdium uses your Mac's build-in spellchecker to check for typos. If you want to change the languages the spellchecker checks for, you can do so in your Mac's System Preferences.", - }, - subheadlineCache: { - id: 'settings.app.subheadlineCache', - defaultMessage: 'Cache', - }, - cacheInfo: { - id: 'settings.app.cacheInfo', - defaultMessage: 'Ferdium cache is currently using {size} of disk space.', - }, - cacheNotCleared: { - id: 'settings.app.cacheNotCleared', - defaultMessage: "Couldn't clear all cache", - }, - buttonClearAllCache: { - id: 'settings.app.buttonClearAllCache', - defaultMessage: 'Clear cache', - }, - subheadlineFerdiumProfile: { - id: 'settings.app.subheadlineFerdiumProfile', - defaultMessage: 'Ferdium Profile', - }, - buttonOpenFerdiumProfileFolder: { - id: 'settings.app.buttonOpenFerdiumProfileFolder', - defaultMessage: 'Open Profile folder', - }, - buttonOpenFerdiumServiceRecipesFolder: { - id: 'settings.app.buttonOpenFerdiumServiceRecipesFolder', - defaultMessage: 'Open Service Recipes folder', - }, - buttonSearchForUpdate: { - id: 'settings.app.buttonSearchForUpdate', - defaultMessage: 'Check for updates', - }, - buttonInstallUpdate: { - id: 'settings.app.buttonInstallUpdate', - defaultMessage: 'Restart & install update', - }, - updateStatusSearching: { - id: 'settings.app.updateStatusSearching', - defaultMessage: 'Searching for updates...', - }, - updateStatusAvailable: { - id: 'settings.app.updateStatusAvailable', - defaultMessage: 'Update available, downloading...', - }, - updateStatusUpToDate: { - id: 'settings.app.updateStatusUpToDate', - defaultMessage: 'You are using the latest version of Ferdium', - }, - currentVersion: { - id: 'settings.app.currentVersion', - defaultMessage: 'Current version:', - }, - appRestartRequired: { - id: 'settings.app.restartRequired', - defaultMessage: 'Changes require restart', - }, - servicesUpdated: { - id: 'infobar.servicesUpdated', - defaultMessage: 'Your services have been updated.', - }, - buttonReloadServices: { - id: 'infobar.buttonReloadServices', - defaultMessage: 'Reload services', - }, - numberOfColumns: { - id: 'settings.app.form.splitColumns', - defaultMessage: 'Number of columns', - }, -}); - -const Hr = () =>
; -const HrSections = () =>
; - -class EditSettingsForm extends Component { - static propTypes = { - checkForUpdates: PropTypes.func.isRequired, - installUpdate: PropTypes.func.isRequired, - form: PropTypes.instanceOf(Form).isRequired, - onSubmit: PropTypes.func.isRequired, - isCheckingForUpdates: PropTypes.bool.isRequired, - isUpdateAvailable: PropTypes.bool.isRequired, - noUpdateAvailable: PropTypes.bool.isRequired, - updateIsReadyToInstall: PropTypes.bool.isRequired, - updateFailed: PropTypes.bool.isRequired, - isClearingAllCache: PropTypes.bool.isRequired, - onClearAllCache: PropTypes.func.isRequired, - getCacheSize: PropTypes.func.isRequired, - isTodosActivated: PropTypes.bool.isRequired, - automaticUpdates: PropTypes.bool.isRequired, - isDarkmodeEnabled: PropTypes.bool.isRequired, - isAdaptableDarkModeEnabled: PropTypes.bool.isRequired, - isUseGrayscaleServicesEnabled: PropTypes.bool.isRequired, - openProcessManager: PropTypes.func.isRequired, - isSplitModeEnabled: PropTypes.bool.isRequired, - hasAddedTodosAsService: PropTypes.bool.isRequired, - isOnline: PropTypes.bool.isRequired, - }; - - state = { - activeSetttingsTab: 'general', - clearCacheButtonClicked: false, - }; - - setActiveSettingsTab(tab) { - this.setState({ - activeSetttingsTab: tab, - }); - } - - onClearCacheClicked = () => { - this.setState({ clearCacheButtonClicked: true }); - }; - - submit(e) { - e.preventDefault(); - this.props.form.submit({ - onSuccess: form => { - const values = form.values(); - this.props.onSubmit(values); - }, - onError: () => {}, - }); - } - - render() { - const { - checkForUpdates, - installUpdate, - form, - isCheckingForUpdates, - isAdaptableDarkModeEnabled, - isUseGrayscaleServicesEnabled, - isUpdateAvailable, - noUpdateAvailable, - updateIsReadyToInstall, - updateFailed, - showServicesUpdatedInfoBar, - isClearingAllCache, - onClearAllCache, - getCacheSize, - automaticUpdates, - isDarkmodeEnabled, - isSplitModeEnabled, - openProcessManager, - isTodosActivated, - hasAddedTodosAsService, - isOnline, - } = this.props; - const { intl } = this.props; - - let updateButtonLabelMessage = messages.buttonSearchForUpdate; - if (isCheckingForUpdates) { - updateButtonLabelMessage = messages.updateStatusSearching; - } else if (isUpdateAvailable) { - updateButtonLabelMessage = messages.updateStatusAvailable; - } else { - updateButtonLabelMessage = messages.buttonSearchForUpdate; - } - - const { lockingFeatureEnabled, scheduledDNDEnabled, reloadAfterResume } = - window['ferdium'].stores.settings.all.app; - - let cacheSize; - let notCleared; - if (this.state.activeSetttingsTab === 'advanced') { - const cacheSizeBytes = getCacheSize(); - debug('cacheSizeBytes:', cacheSizeBytes); - if (typeof cacheSizeBytes === 'number') { - cacheSize = prettyBytes(cacheSizeBytes); - debug('cacheSize:', cacheSize); - notCleared = - this.state.clearCacheButtonClicked && - isClearingAllCache === false && - cacheSizeBytes !== 0; - } else { - cacheSize = '…'; - notCleared = false; - } - } - - const profileFolder = userDataPath(); - const recipeFolder = userDataRecipesPath(); - - return ( -
-
-

{intl.formatMessage(globalMessages.settings)}

-
-
-
this.submit(e)} - onChange={e => this.submit(e)} - id="form" - > - {/* Titles */} -
-
{ - this.setActiveSettingsTab('general'); - }} - > - {intl.formatMessage(messages.headlineGeneral)} -
-
{ - this.setActiveSettingsTab('appearance'); - }} - > - {intl.formatMessage(messages.headlineAppearance)} -
-
{ - this.setActiveSettingsTab('privacy'); - }} - > - {intl.formatMessage(messages.headlinePrivacy)} -
-
{ - this.setActiveSettingsTab('language'); - }} - > - {intl.formatMessage(messages.headlineLanguage)} -
-
{ - this.setActiveSettingsTab('advanced'); - }} - > - {intl.formatMessage(messages.headlineAdvanced)} -
-
{ - this.setActiveSettingsTab('updates'); - }} - > - {intl.formatMessage(messages.headlineUpdates)} - {automaticUpdates && (updateIsReadyToInstall || isUpdateAvailable || showServicesUpdatedInfoBar) && ( - - )} -
-
- - {/* General */} - {this.state.activeSetttingsTab === 'general' && ( -
-

- {intl.formatMessage(messages.sectionMain)} -

- - - - - {reloadAfterResume &&
} - - {reloadAfterResume && ( -
- -
-
- )} - - {isWindows && } - {isWindows && } - - - - {!hasAddedTodosAsService && ( - <> - {isTodosActivated &&
} - - {isTodosActivated && ( -
- this.submit(e)} - field={form.$('customTodoServer')} - /> -

- {intl.formatMessage(messages.todoServerInfo)} -

-
- )} -
- )} - - )} - - {scheduledDNDEnabled &&
} - - - {scheduledDNDEnabled && ( - <> -
-
- this.submit(e)} - field={form.$('scheduledDNDStart')} - type="time" - /> -
-
- this.submit(e)} - field={form.$('scheduledDNDEnd')} - type="time" - /> -
-
-

{intl.formatMessage(messages.scheduledDNDTimeInfo)}

- - )} -

- {intl.formatMessage(messages.scheduledDNDInfo)} -

- -
- - - -

- {intl.formatMessage(messages.hibernateInfo)} -

- - - -
- )} - - {/* Appearance */} - {this.state.activeSetttingsTab === 'appearance' && ( -
-

- {intl.formatMessage(messages.sectionGeneralUi)} -

- {isMac && } - - - {!isAdaptableDarkModeEnabled && ( - - )} - {(isDarkmodeEnabled || isAdaptableDarkModeEnabled) && ( - <> - -

- - {intl.formatMessage(messages.universalDarkModeInfo)} - -

- - )} - - {isSplitModeEnabled &&
} - - {isSplitModeEnabled && ( - this.submit(e)} - field={form.$('splitColumns')} - /> - )} - - -

- {intl.formatMessage(messages.sectionAccentColorSettings)} -

-

- {intl.formatMessage(messages.accentColorInfo, { - defaultAccentColor: DEFAULT_APP_SETTINGS.accentColor, - })} -

-

- {intl.formatMessage(messages.overallTheme)} -

- this.submit(e)} - field={form.$('accentColor')} - className='color-picker-input' - /> -
-

-

- {intl.formatMessage(messages.progressbarTheme)} -

- this.submit(e)} - field={form.$('progressbarAccentColor')} - className='color-picker-input' - /> -
-

-

-

-
-

- - -

- {intl.formatMessage(messages.sectionSidebarSettings)} -

- - - - - - - - - - - - - - - - - - - - - -

- {intl.formatMessage(messages.sectionServiceIconsSettings)} -

- - - - - {isUseGrayscaleServicesEnabled &&
} - - - - {isUseGrayscaleServicesEnabled && ( - <> - this.submit(e)} - field={form.$('grayscaleServicesDim')} - /> -
- - )} - - - - - -

- {intl.formatMessage(messages.appRestartRequired)} -

- -
- - - {lockingFeatureEnabled && ( - <> - {isMac && systemPreferences.canPromptTouchID() && ( - - )} - - this.submit(e)} - field={form.$('lockedPassword')} - type="password" - scorePassword - showPasswordToggle - /> -

{intl.formatMessage(messages.lockedPasswordInfo)}

- - this.submit(e)} - field={form.$('inactivityLock')} - autoFocus - /> -

{intl.formatMessage(messages.inactivityLockInfo)}

- - )} -

- - {intl.formatMessage(messages.lockInfo, { - lockShortcut: `${lockFerdiumShortcutKey(false)}`, - })} - -

-
- )} - - {/* Language */} - {this.state.activeSetttingsTab === 'language' && ( -
- -

- {intl.formatMessage(messages.sectionLanguage)} -

- - - )} - {isMac && form.$('enableSpellchecking').value && ( -

- {intl.formatMessage(messages.spellCheckerLanguageInfo)} -

- )} -

- {intl.formatMessage(messages.appRestartRequired)} -

- -
- - - {intl.formatMessage(messages.translationHelp)}{' '} - - -
- )} - - {/* Advanced */} - {this.state.activeSetttingsTab === 'advanced' && ( -
- -

- {intl.formatMessage(messages.sectionAdvanced)} -

- - - -

- {intl.formatMessage(messages.appRestartRequired)} -

- -
- - this.submit(e)} - field={form.$('userAgentPref')} - /> -

- {intl.formatMessage(globalMessages.userAgentHelp)} -

-

- {intl.formatMessage(messages.appRestartRequired)} -

- -
- -
-

{intl.formatMessage(messages.subheadlineCache)}

-

- {intl.formatMessage(messages.cacheInfo, { - size: cacheSize, - })} -

- {notCleared && ( -

{intl.formatMessage(messages.cacheNotCleared)}

- )} -
-
-
-
-
- -
- -
-

- {intl.formatMessage(messages.subheadlineFerdiumProfile)} -

-

-

-
-

-
-
- )} - - {/* Updates */} - {this.state.activeSetttingsTab === 'updates' && ( -
-

- {intl.formatMessage(messages.sectionUpdates)} -

- - - {automaticUpdates && ( - <> - <> -
- - {updateIsReadyToInstall ? ( -
-

- {intl.formatMessage(messages.currentVersion)} {ferdiumVersion} -

- {noUpdateAvailable && ( -

- {intl.formatMessage(messages.updateStatusUpToDate)}. -

- )} - {updateFailed && ( - -  An error occurred (check the console for more details) - - )} - - {showServicesUpdatedInfoBar ? ( - <> -

- - {intl.formatMessage(messages.servicesUpdated)} -

-
- )} - -
- - ); - } -} - -export default injectIntl(observer(EditSettingsForm)); diff --git a/src/components/settings/settings/EditSettingsForm.jsx b/src/components/settings/settings/EditSettingsForm.jsx new file mode 100644 index 000000000..a2168f4fc --- /dev/null +++ b/src/components/settings/settings/EditSettingsForm.jsx @@ -0,0 +1,1039 @@ +import { systemPreferences } from '@electron/remote'; +import { Component } from 'react'; +import PropTypes from 'prop-types'; +import { observer } from 'mobx-react'; +import prettyBytes from 'pretty-bytes'; +import { defineMessages, injectIntl } from 'react-intl'; + +import { mdiGithub, mdiOpenInNew, mdiPowerPlug } from '@mdi/js'; + +import Form from '../../../lib/Form'; +import Button from '../../ui/button'; +import Toggle from '../../ui/Toggle'; +import Select from '../../ui/Select'; +import Input from '../../ui/Input'; +import ColorPickerInput from '../../ui/ColorPickerInput'; +import Infobox from '../../ui/Infobox'; +import { H1, H2, H3, H5 } from '../../ui/headline'; + +import { + DEFAULT_APP_SETTINGS, + FRANZ_TRANSLATION, + GITHUB_FRANZ_URL, + SPLIT_COLUMNS_MAX, + SPLIT_COLUMNS_MIN, +} from '../../../config'; +import { isMac, isWindows, lockFerdiumShortcutKey } from '../../../environment'; +import { + ferdiumVersion, + userDataPath, + userDataRecipesPath, +} from '../../../environment-remote'; +import { openPath } from '../../../helpers/url-helpers'; +import globalMessages from '../../../i18n/globalMessages'; +import Icon from '../../ui/icon'; +import Slider from '../../ui/Slider'; + +const debug = require('../../../preload-safe-debug')( + 'Ferdium:EditSettingsForm', +); + +const messages = defineMessages({ + headlineGeneral: { + id: 'settings.app.headlineGeneral', + defaultMessage: 'General', + }, + hibernateInfo: { + id: 'settings.app.hibernateInfo', + defaultMessage: + 'By default, Ferdium will keep all your services open and loaded in the background so they are ready when you want to use them. Service Hibernation will unload your services after a specified amount. This is useful to save RAM or keeping services from slowing down your computer.', + }, + inactivityLockInfo: { + id: 'settings.app.inactivityLockInfo', + defaultMessage: + 'Minutes of inactivity, after which Ferdium should automatically lock. Use 0 to disable', + }, + todoServerInfo: { + id: 'settings.app.todoServerInfo', + defaultMessage: 'This server will be used for the "Ferdium Todo" feature.', + }, + lockedPassword: { + id: 'settings.app.lockedPassword', + defaultMessage: 'Password', + }, + lockedPasswordInfo: { + id: 'settings.app.lockedPasswordInfo', + defaultMessage: + "Please make sure to set a password you'll remember.\nIf you loose this password, you will have to reinstall Ferdium.", + }, + lockInfo: { + id: 'settings.app.lockInfo', + defaultMessage: + 'Password Lock allows you to keep your messages protected.\nUsing Password Lock, you will be prompted to enter your password everytime you start Ferdium or lock Ferdium yourself using the lock symbol in the bottom left corner or the shortcut {lockShortcut}.', + }, + scheduledDNDTimeInfo: { + id: 'settings.app.scheduledDNDTimeInfo', + defaultMessage: + 'Times in 24-Hour-Format. End time can be before start time (e.g. start 17:00, end 09:00) to enable Do-not-Disturb overnight.', + }, + scheduledDNDInfo: { + id: 'settings.app.scheduledDNDInfo', + defaultMessage: + 'Scheduled Do-not-Disturb allows you to define a period of time in which you do not want to get Notifications from Ferdium.', + }, + headlineLanguage: { + id: 'settings.app.headlineLanguage', + defaultMessage: 'Language', + }, + headlineUpdates: { + id: 'settings.app.headlineUpdates', + defaultMessage: 'Updates', + }, + headlineAppearance: { + id: 'settings.app.headlineAppearance', + defaultMessage: 'Appearance', + }, + sectionMain: { + id: 'settings.app.sectionMain', + defaultMessage: 'Main', + }, + sectionHibernation: { + id: 'settings.app.sectionHibernation', + defaultMessage: 'Hibernation', + }, + sectionGeneralUi: { + id: 'settings.app.sectionGeneralUi', + defaultMessage: 'General UI', + }, + sectionSidebarSettings: { + id: 'settings.app.sectionSidebarSettings', + defaultMessage: 'Sidebar Settings', + }, + sectionPrivacy: { + id: 'settings.app.sectionPrivacy', + defaultMessage: 'Privacy Settings', + }, + sectionLanguage: { + id: 'settings.app.sectionLanguage', + defaultMessage: 'Language Settings', + }, + sectionAdvanced: { + id: 'settings.app.sectionAdvanced', + defaultMessage: 'Advanced Settings', + }, + sectionUpdates: { + id: 'settings.app.sectionUpdates', + defaultMessage: 'App Updates Settings', + }, + sectionServiceIconsSettings: { + id: 'settings.app.sectionServiceIconsSettings', + defaultMessage: 'Service Icons Settings', + }, + sectionAccentColorSettings: { + id: 'settings.app.sectionAccentColorSettings', + defaultMessage: 'Accent Color Settings', + }, + accentColorInfo: { + id: 'settings.app.accentColorInfo', + defaultMessage: + 'Write your color choice in a CSS-compatible format. (Default: {defaultAccentColor} or clear the input field)', + }, + overallTheme: { + id: 'settings.app.overallTheme', + defaultMessage: 'Overall Theme', + }, + progressbarTheme: { + id: 'settings.app.progressbarTheme', + defaultMessage: 'Progressbar Theme', + }, + universalDarkModeInfo: { + id: 'settings.app.universalDarkModeInfo', + defaultMessage: + 'Universal Dark Mode tries to dynamically generate dark mode styles for services that are otherwise not currently supported.', + }, + headlinePrivacy: { + id: 'settings.app.headlinePrivacy', + defaultMessage: 'Privacy', + }, + headlineAdvanced: { + id: 'settings.app.headlineAdvanced', + defaultMessage: 'Advanced', + }, + translationHelp: { + id: 'settings.app.translationHelp', + defaultMessage: 'Help us to translate Ferdium into your language.', + }, + spellCheckerLanguageInfo: { + id: 'settings.app.spellCheckerLanguageInfo', + defaultMessage: + "Ferdium uses your Mac's build-in spellchecker to check for typos. If you want to change the languages the spellchecker checks for, you can do so in your Mac's System Preferences.", + }, + subheadlineCache: { + id: 'settings.app.subheadlineCache', + defaultMessage: 'Cache', + }, + cacheInfo: { + id: 'settings.app.cacheInfo', + defaultMessage: 'Ferdium cache is currently using {size} of disk space.', + }, + cacheNotCleared: { + id: 'settings.app.cacheNotCleared', + defaultMessage: "Couldn't clear all cache", + }, + buttonClearAllCache: { + id: 'settings.app.buttonClearAllCache', + defaultMessage: 'Clear cache', + }, + subheadlineFerdiumProfile: { + id: 'settings.app.subheadlineFerdiumProfile', + defaultMessage: 'Ferdium Profile', + }, + buttonOpenFerdiumProfileFolder: { + id: 'settings.app.buttonOpenFerdiumProfileFolder', + defaultMessage: 'Open Profile folder', + }, + buttonOpenFerdiumServiceRecipesFolder: { + id: 'settings.app.buttonOpenFerdiumServiceRecipesFolder', + defaultMessage: 'Open Service Recipes folder', + }, + buttonSearchForUpdate: { + id: 'settings.app.buttonSearchForUpdate', + defaultMessage: 'Check for updates', + }, + buttonInstallUpdate: { + id: 'settings.app.buttonInstallUpdate', + defaultMessage: 'Restart & install update', + }, + updateStatusSearching: { + id: 'settings.app.updateStatusSearching', + defaultMessage: 'Searching for updates...', + }, + updateStatusAvailable: { + id: 'settings.app.updateStatusAvailable', + defaultMessage: 'Update available, downloading...', + }, + updateStatusUpToDate: { + id: 'settings.app.updateStatusUpToDate', + defaultMessage: 'You are using the latest version of Ferdium', + }, + currentVersion: { + id: 'settings.app.currentVersion', + defaultMessage: 'Current version:', + }, + appRestartRequired: { + id: 'settings.app.restartRequired', + defaultMessage: 'Changes require restart', + }, + servicesUpdated: { + id: 'infobar.servicesUpdated', + defaultMessage: 'Your services have been updated.', + }, + buttonReloadServices: { + id: 'infobar.buttonReloadServices', + defaultMessage: 'Reload services', + }, + numberOfColumns: { + id: 'settings.app.form.splitColumns', + defaultMessage: 'Number of columns', + }, +}); + +const Hr = () => ( +
+); +const HrSections = () => ( +
+); + +class EditSettingsForm extends Component { + static propTypes = { + checkForUpdates: PropTypes.func.isRequired, + installUpdate: PropTypes.func.isRequired, + form: PropTypes.instanceOf(Form).isRequired, + onSubmit: PropTypes.func.isRequired, + isCheckingForUpdates: PropTypes.bool.isRequired, + isUpdateAvailable: PropTypes.bool.isRequired, + noUpdateAvailable: PropTypes.bool.isRequired, + updateIsReadyToInstall: PropTypes.bool.isRequired, + updateFailed: PropTypes.bool.isRequired, + isClearingAllCache: PropTypes.bool.isRequired, + onClearAllCache: PropTypes.func.isRequired, + getCacheSize: PropTypes.func.isRequired, + isTodosActivated: PropTypes.bool.isRequired, + automaticUpdates: PropTypes.bool.isRequired, + isDarkmodeEnabled: PropTypes.bool.isRequired, + isAdaptableDarkModeEnabled: PropTypes.bool.isRequired, + isUseGrayscaleServicesEnabled: PropTypes.bool.isRequired, + openProcessManager: PropTypes.func.isRequired, + isSplitModeEnabled: PropTypes.bool.isRequired, + isOnline: PropTypes.bool.isRequired, + }; + + constructor(props) { + super(props); + + this.state = { + activeSetttingsTab: 'general', + clearCacheButtonClicked: false, + }; + } + + setActiveSettingsTab(tab) { + this.setState({ + activeSetttingsTab: tab, + }); + } + + onClearCacheClicked = () => { + this.setState({ clearCacheButtonClicked: true }); + }; + + submit(e) { + e.preventDefault(); + this.props.form.submit({ + onSuccess: form => { + const values = form.values(); + this.props.onSubmit(values); + }, + onError: () => {}, + }); + } + + render() { + const { + checkForUpdates, + installUpdate, + form, + isCheckingForUpdates, + isAdaptableDarkModeEnabled, + isUseGrayscaleServicesEnabled, + isUpdateAvailable, + noUpdateAvailable, + updateIsReadyToInstall, + updateFailed, + showServicesUpdatedInfoBar, + isClearingAllCache, + onClearAllCache, + getCacheSize, + automaticUpdates, + isDarkmodeEnabled, + isSplitModeEnabled, + openProcessManager, + isTodosActivated, + isOnline, + } = this.props; + const { intl } = this.props; + + let updateButtonLabelMessage = messages.buttonSearchForUpdate; + if (isCheckingForUpdates) { + updateButtonLabelMessage = messages.updateStatusSearching; + } else if (isUpdateAvailable) { + updateButtonLabelMessage = messages.updateStatusAvailable; + } else { + updateButtonLabelMessage = messages.buttonSearchForUpdate; + } + + const { lockingFeatureEnabled, scheduledDNDEnabled, reloadAfterResume } = + window['ferdium'].stores.settings.all.app; + + let cacheSize; + let notCleared; + if (this.state.activeSetttingsTab === 'advanced') { + const cacheSizeBytes = getCacheSize(); + debug('cacheSizeBytes:', cacheSizeBytes); + if (typeof cacheSizeBytes === 'number') { + cacheSize = prettyBytes(cacheSizeBytes); + debug('cacheSize:', cacheSize); + notCleared = + this.state.clearCacheButtonClicked && + isClearingAllCache === false && + cacheSizeBytes !== 0; + } else { + cacheSize = '…'; + notCleared = false; + } + } + + const profileFolder = userDataPath(); + const recipeFolder = userDataRecipesPath(); + + return ( +
+
+

{intl.formatMessage(globalMessages.settings)}

+
+
+
this.submit(e)} + onChange={e => this.submit(e)} + id="form" + > + {/* Titles */} +
+
{ + this.setActiveSettingsTab('general'); + }} + > + {intl.formatMessage(messages.headlineGeneral)} +
+
{ + this.setActiveSettingsTab('appearance'); + }} + > + {intl.formatMessage(messages.headlineAppearance)} +
+
{ + this.setActiveSettingsTab('privacy'); + }} + > + {intl.formatMessage(messages.headlinePrivacy)} +
+
{ + this.setActiveSettingsTab('language'); + }} + > + {intl.formatMessage(messages.headlineLanguage)} +
+
{ + this.setActiveSettingsTab('advanced'); + }} + > + {intl.formatMessage(messages.headlineAdvanced)} +
+
{ + this.setActiveSettingsTab('updates'); + }} + > + {intl.formatMessage(messages.headlineUpdates)} + {automaticUpdates && + (updateIsReadyToInstall || + isUpdateAvailable || + showServicesUpdatedInfoBar) && ( + + )} +
+
+ + {/* General */} + {this.state.activeSetttingsTab === 'general' && ( +
+

+ {intl.formatMessage(messages.sectionMain)} +

+ + + + + {reloadAfterResume &&
} + + {reloadAfterResume && ( +
+ +
+
+ )} + + {isWindows && } + {isWindows && } + + + + {isTodosActivated &&
} + + {isTodosActivated && ( +
+ this.submit(e)} + field={form.$('customTodoServer')} + /> +

+ {intl.formatMessage(messages.todoServerInfo)} +

+
+ )} +
+ )} + {isTodosActivated &&
} + + {scheduledDNDEnabled &&
} + + + {scheduledDNDEnabled && ( + <> +
+
+ this.submit(e)} + field={form.$('scheduledDNDStart')} + type="time" + /> +
+
+ this.submit(e)} + field={form.$('scheduledDNDEnd')} + type="time" + /> +
+
+

{intl.formatMessage(messages.scheduledDNDTimeInfo)}

+ + )} +

+ {intl.formatMessage(messages.scheduledDNDInfo)} +

+ +
+ + + +

+ {intl.formatMessage(messages.hibernateInfo)} +

+ + + +
+ )} + + {/* Appearance */} + {this.state.activeSetttingsTab === 'appearance' && ( +
+

+ {intl.formatMessage(messages.sectionGeneralUi)} +

+ {isMac && } + + + {!isAdaptableDarkModeEnabled && ( + + )} + {(isDarkmodeEnabled || isAdaptableDarkModeEnabled) && ( + <> + +

+ + {intl.formatMessage(messages.universalDarkModeInfo)} + +

+ + )} + + {isSplitModeEnabled &&
} + + {isSplitModeEnabled && ( + this.submit(e)} + field={form.$('splitColumns')} + /> + )} + + +

+ {intl.formatMessage(messages.sectionAccentColorSettings)} +

+

+ {intl.formatMessage(messages.accentColorInfo, { + defaultAccentColor: DEFAULT_APP_SETTINGS.accentColor, + })} +

+

+ {intl.formatMessage(messages.overallTheme)} +

+ this.submit(e)} + field={form.$('accentColor')} + className="color-picker-input" + /> +
+

+

+ {intl.formatMessage(messages.progressbarTheme)} +

+ this.submit(e)} + field={form.$('progressbarAccentColor')} + className="color-picker-input" + /> +
+

+

+

+
+

+ + +

+ {intl.formatMessage(messages.sectionSidebarSettings)} +

+ + + + + + + + + + + + + + + + + + + + + +

+ {intl.formatMessage(messages.sectionServiceIconsSettings)} +

+ + + + + {isUseGrayscaleServicesEnabled &&
} + + + + {isUseGrayscaleServicesEnabled && ( + <> + this.submit(e)} + field={form.$('grayscaleServicesDim')} + /> +
+ + )} + + + + + +

+ {intl.formatMessage(messages.appRestartRequired)} +

+ +
+ + + {lockingFeatureEnabled && ( + <> + {isMac && systemPreferences.canPromptTouchID() && ( + + )} + + this.submit(e)} + field={form.$('lockedPassword')} + type="password" + scorePassword + showPasswordToggle + /> +

{intl.formatMessage(messages.lockedPasswordInfo)}

+ + this.submit(e)} + field={form.$('inactivityLock')} + autoFocus + /> +

{intl.formatMessage(messages.inactivityLockInfo)}

+ + )} +

+ + {intl.formatMessage(messages.lockInfo, { + lockShortcut: `${lockFerdiumShortcutKey(false)}`, + })} + +

+
+ )} + + {/* Language */} + {this.state.activeSetttingsTab === 'language' && ( +
+

+ {intl.formatMessage(messages.sectionLanguage)} +

+ + + )} + {isMac && form.$('enableSpellchecking').value && ( +

+ {intl.formatMessage(messages.spellCheckerLanguageInfo)} +

+ )} +

+ {intl.formatMessage(messages.appRestartRequired)} +

+ +
+ + + {intl.formatMessage(messages.translationHelp)}{' '} + + +
+ )} + + {/* Advanced */} + {this.state.activeSetttingsTab === 'advanced' && ( +
+

+ {intl.formatMessage(messages.sectionAdvanced)} +

+ + + +

+ {intl.formatMessage(messages.appRestartRequired)} +

+ +
+ + this.submit(e)} + field={form.$('userAgentPref')} + /> +

+ {intl.formatMessage(globalMessages.userAgentHelp)} +

+

+ {intl.formatMessage(messages.appRestartRequired)} +

+ +
+ +
+

{intl.formatMessage(messages.subheadlineCache)}

+

+ {intl.formatMessage(messages.cacheInfo, { + size: cacheSize, + })} +

+ {notCleared && ( +

{intl.formatMessage(messages.cacheNotCleared)}

+ )} +
+
+
+
+
+ +
+ +
+

+ {intl.formatMessage(messages.subheadlineFerdiumProfile)} +

+

+

+
+

+
+
+ )} + + {/* Updates */} + {this.state.activeSetttingsTab === 'updates' && ( +
+

+ {intl.formatMessage(messages.sectionUpdates)} +

+ + + {automaticUpdates && ( + <> + <> +
+ + {updateIsReadyToInstall ? ( +
+

+ {intl.formatMessage(messages.currentVersion)}{' '} + {ferdiumVersion} +

+ {noUpdateAvailable && ( +

+ {intl.formatMessage(messages.updateStatusUpToDate)}. +

+ )} + {updateFailed && ( + +  An error occurred (check the console for more + details) + + )} + + {showServicesUpdatedInfoBar ? ( + <> +

+ + {intl.formatMessage(messages.servicesUpdated)} +

+
+ )} + +
+ + ); + } +} + +export default injectIntl(observer(EditSettingsForm)); diff --git a/src/containers/settings/EditSettingsScreen.tsx b/src/containers/settings/EditSettingsScreen.tsx index b2604ae0e..8f0884737 100644 --- a/src/containers/settings/EditSettingsScreen.tsx +++ b/src/containers/settings/EditSettingsScreen.tsx @@ -849,7 +849,7 @@ class EditSettingsScreen extends Component { } render(): ReactElement { - const { app, services } = this.props.stores; + const { app } = this.props.stores; const { updateStatus, updateStatusTypes, @@ -893,7 +893,6 @@ class EditSettingsScreen extends Component { this.props.stores.todos.isUsingCustomTodoService } openProcessManager={() => this.openProcessManager()} - hasAddedTodosAsService={services.isTodosServiceAdded} isOnline={app.isOnline} /> -- cgit v1.2.3-54-g00ecf