diff options
author | 2019-02-12 20:42:21 +0100 | |
---|---|---|
committer | 2019-02-12 20:42:21 +0100 | |
commit | 2d5a303b1cc559339c3ecc7a176e9d8bd66755ef (patch) | |
tree | 2a97c1db68a72b8e208bd177af7faad5df2c9f48 /src/containers | |
parent | feat(Windows): Add option to quit Franz from Taskbar icon (diff) | |
parent | feat(Spell checking): Add option to automatically detect language (diff) | |
download | ferdium-app-2d5a303b1cc559339c3ecc7a176e9d8bd66755ef.tar.gz ferdium-app-2d5a303b1cc559339c3ecc7a176e9d8bd66755ef.tar.zst ferdium-app-2d5a303b1cc559339c3ecc7a176e9d8bd66755ef.zip |
Merge branch 'feature/spellcheck-autodetect' into develop
Diffstat (limited to 'src/containers')
-rw-r--r-- | src/containers/settings/EditServiceScreen.js | 40 | ||||
-rw-r--r-- | src/containers/settings/EditSettingsScreen.js | 16 |
2 files changed, 32 insertions, 24 deletions
diff --git a/src/containers/settings/EditServiceScreen.js b/src/containers/settings/EditServiceScreen.js index b46908344..d08f0a52e 100644 --- a/src/containers/settings/EditServiceScreen.js +++ b/src/containers/settings/EditServiceScreen.js | |||
@@ -19,9 +19,12 @@ import { required, url, oneRequired } from '../../helpers/validation-helpers'; | |||
19 | import { getSelectOptions } from '../../helpers/i18n-helpers'; | 19 | import { getSelectOptions } from '../../helpers/i18n-helpers'; |
20 | 20 | ||
21 | import { config as proxyFeature } from '../../features/serviceProxy'; | 21 | import { config as proxyFeature } from '../../features/serviceProxy'; |
22 | import { config as spellcheckerFeature } from '../../features/spellchecker'; | ||
22 | 23 | ||
23 | import { SPELLCHECKER_LOCALES } from '../../i18n/languages'; | 24 | import { SPELLCHECKER_LOCALES } from '../../i18n/languages'; |
24 | 25 | ||
26 | import globalMessages from '../../i18n/globalMessages'; | ||
27 | |||
25 | const messages = defineMessages({ | 28 | const messages = defineMessages({ |
26 | name: { | 29 | name: { |
27 | id: 'settings.service.form.name', | 30 | id: 'settings.service.form.name', |
@@ -83,14 +86,6 @@ const messages = defineMessages({ | |||
83 | id: 'settings.service.form.proxy.password', | 86 | id: 'settings.service.form.proxy.password', |
84 | defaultMessage: '!!!Password', | 87 | defaultMessage: '!!!Password', |
85 | }, | 88 | }, |
86 | spellcheckerLanguage: { | ||
87 | id: 'settings.service.form.spellcheckerLanguage', | ||
88 | defaultMessage: '!!!Spell checking Language', | ||
89 | }, | ||
90 | spellcheckerSystemDefault: { | ||
91 | id: 'settings.service.form.spellcheckerLanguage.default', | ||
92 | defaultMessage: '!!!Use System Default ({default})', | ||
93 | }, | ||
94 | }); | 89 | }); |
95 | 90 | ||
96 | export default @inject('stores', 'actions') @observer class EditServiceScreen extends Component { | 91 | export default @inject('stores', 'actions') @observer class EditServiceScreen extends Component { |
@@ -118,12 +113,26 @@ export default @inject('stores', 'actions') @observer class EditServiceScreen ex | |||
118 | } | 113 | } |
119 | 114 | ||
120 | prepareForm(recipe, service, proxy) { | 115 | prepareForm(recipe, service, proxy) { |
116 | const { | ||
117 | intl, | ||
118 | } = this.context; | ||
119 | |||
120 | const { | ||
121 | stores, | ||
122 | } = this.props; | ||
123 | |||
124 | let defaultSpellcheckerLanguage = SPELLCHECKER_LOCALES[stores.settings.app.spellcheckerLanguage]; | ||
125 | |||
126 | if (stores.settings.app.spellcheckerLanguage === 'automatic') { | ||
127 | defaultSpellcheckerLanguage = intl.formatMessage(globalMessages.spellcheckerAutomaticDetectionShort); | ||
128 | } | ||
129 | |||
121 | const spellcheckerLanguage = getSelectOptions({ | 130 | const spellcheckerLanguage = getSelectOptions({ |
122 | locales: SPELLCHECKER_LOCALES, | 131 | locales: SPELLCHECKER_LOCALES, |
123 | resetToDefaultText: this.context.intl.formatMessage(messages.spellcheckerSystemDefault, { default: SPELLCHECKER_LOCALES[this.props.stores.settings.app.spellcheckerLanguage] }), | 132 | resetToDefaultText: intl.formatMessage(globalMessages.spellcheckerSystemDefault, { default: defaultSpellcheckerLanguage }), |
133 | automaticDetectionText: stores.settings.app.spellcheckerLanguage !== 'automatic' ? intl.formatMessage(globalMessages.spellcheckerAutomaticDetection) : '', | ||
124 | }); | 134 | }); |
125 | 135 | ||
126 | const { intl } = this.context; | ||
127 | const config = { | 136 | const config = { |
128 | fields: { | 137 | fields: { |
129 | name: { | 138 | name: { |
@@ -160,13 +169,13 @@ export default @inject('stores', 'actions') @observer class EditServiceScreen ex | |||
160 | isDarkModeEnabled: { | 169 | isDarkModeEnabled: { |
161 | label: intl.formatMessage(messages.enableDarkMode), | 170 | label: intl.formatMessage(messages.enableDarkMode), |
162 | value: service.isDarkModeEnabled, | 171 | value: service.isDarkModeEnabled, |
163 | default: this.props.stores.settings.app.darkMode, | 172 | default: stores.settings.app.darkMode, |
164 | }, | 173 | }, |
165 | spellcheckerLanguage: { | 174 | spellcheckerLanguage: { |
166 | label: intl.formatMessage(messages.spellcheckerLanguage), | 175 | label: intl.formatMessage(globalMessages.spellcheckerLanguage), |
167 | value: service.spellcheckerLanguage, | 176 | value: service.spellcheckerLanguage, |
168 | options: spellcheckerLanguage, | 177 | options: spellcheckerLanguage, |
169 | disabled: !this.props.stores.settings.app.enableSpellchecking, | 178 | disabled: !stores.settings.app.enableSpellchecking, |
170 | }, | 179 | }, |
171 | }, | 180 | }, |
172 | }; | 181 | }; |
@@ -220,7 +229,7 @@ export default @inject('stores', 'actions') @observer class EditServiceScreen ex | |||
220 | } | 229 | } |
221 | 230 | ||
222 | if (proxy.isEnabled) { | 231 | if (proxy.isEnabled) { |
223 | const serviceProxyConfig = this.props.stores.settings.proxy[service.id] || {}; | 232 | const serviceProxyConfig = stores.settings.proxy[service.id] || {}; |
224 | 233 | ||
225 | Object.assign(config.fields, { | 234 | Object.assign(config.fields, { |
226 | proxy: { | 235 | proxy: { |
@@ -326,7 +335,8 @@ export default @inject('stores', 'actions') @observer class EditServiceScreen ex | |||
326 | onSubmit={d => this.onSubmit(d)} | 335 | onSubmit={d => this.onSubmit(d)} |
327 | onDelete={() => this.deleteService()} | 336 | onDelete={() => this.deleteService()} |
328 | isProxyFeatureEnabled={proxyFeature.isEnabled} | 337 | isProxyFeatureEnabled={proxyFeature.isEnabled} |
329 | isProxyFeaturePremiumFeature={proxyFeature.isPremium} | 338 | isProxyPremiumFeature={proxyFeature.isPremium} |
339 | isSpellcheckerPremiumFeature={spellcheckerFeature.isPremium} | ||
330 | /> | 340 | /> |
331 | </ErrorBoundary> | 341 | </ErrorBoundary> |
332 | ); | 342 | ); |
diff --git a/src/containers/settings/EditSettingsScreen.js b/src/containers/settings/EditSettingsScreen.js index f1706a721..992c49b09 100644 --- a/src/containers/settings/EditSettingsScreen.js +++ b/src/containers/settings/EditSettingsScreen.js | |||
@@ -14,10 +14,11 @@ import { config as spellcheckerConfig } from '../../features/spellchecker'; | |||
14 | 14 | ||
15 | import { getSelectOptions } from '../../helpers/i18n-helpers'; | 15 | import { getSelectOptions } from '../../helpers/i18n-helpers'; |
16 | 16 | ||
17 | |||
18 | import EditSettingsForm from '../../components/settings/settings/EditSettingsForm'; | 17 | import EditSettingsForm from '../../components/settings/settings/EditSettingsForm'; |
19 | import ErrorBoundary from '../../components/util/ErrorBoundary'; | 18 | import ErrorBoundary from '../../components/util/ErrorBoundary'; |
20 | 19 | ||
20 | import globalMessages from '../../i18n/globalMessages'; | ||
21 | |||
21 | const messages = defineMessages({ | 22 | const messages = defineMessages({ |
22 | autoLaunchOnStart: { | 23 | autoLaunchOnStart: { |
23 | id: 'settings.app.form.autoLaunchOnStart', | 24 | id: 'settings.app.form.autoLaunchOnStart', |
@@ -63,10 +64,6 @@ const messages = defineMessages({ | |||
63 | id: 'settings.app.form.enableGPUAcceleration', | 64 | id: 'settings.app.form.enableGPUAcceleration', |
64 | defaultMessage: '!!!Enable GPU Acceleration', | 65 | defaultMessage: '!!!Enable GPU Acceleration', |
65 | }, | 66 | }, |
66 | spellcheckerLanguage: { | ||
67 | id: 'settings.app.form.spellcheckerLanguage', | ||
68 | defaultMessage: '!!!Language for spell checking', | ||
69 | }, | ||
70 | beta: { | 67 | beta: { |
71 | id: 'settings.app.form.beta', | 68 | id: 'settings.app.form.beta', |
72 | defaultMessage: '!!!Include beta versions', | 69 | defaultMessage: '!!!Include beta versions', |
@@ -125,6 +122,7 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e | |||
125 | 122 | ||
126 | const spellcheckingLanguages = getSelectOptions({ | 123 | const spellcheckingLanguages = getSelectOptions({ |
127 | locales: SPELLCHECKER_LOCALES, | 124 | locales: SPELLCHECKER_LOCALES, |
125 | automaticDetectionText: this.context.intl.formatMessage(globalMessages.spellcheckerAutomaticDetection), | ||
128 | }); | 126 | }); |
129 | 127 | ||
130 | const config = { | 128 | const config = { |
@@ -166,11 +164,11 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e | |||
166 | }, | 164 | }, |
167 | enableSpellchecking: { | 165 | enableSpellchecking: { |
168 | label: intl.formatMessage(messages.enableSpellchecking), | 166 | label: intl.formatMessage(messages.enableSpellchecking), |
169 | value: !this.props.stores.user.data.isPremium && spellcheckerConfig.isPremiumFeature ? false : settings.all.app.enableSpellchecking, | 167 | value: !this.props.stores.user.data.isPremium && spellcheckerConfig.isPremium ? false : settings.all.app.enableSpellchecking, |
170 | default: !this.props.stores.user.data.isPremium && spellcheckerConfig.isPremiumFeature ? false : DEFAULT_APP_SETTINGS.enableSpellchecking, | 168 | default: !this.props.stores.user.data.isPremium && spellcheckerConfig.isPremium ? false : DEFAULT_APP_SETTINGS.enableSpellchecking, |
171 | }, | 169 | }, |
172 | spellcheckerLanguage: { | 170 | spellcheckerLanguage: { |
173 | label: intl.formatMessage(messages.spellcheckerLanguage), | 171 | label: intl.formatMessage(globalMessages.spellcheckerLanguage), |
174 | value: settings.all.app.spellcheckerLanguage, | 172 | value: settings.all.app.spellcheckerLanguage, |
175 | options: spellcheckingLanguages, | 173 | options: spellcheckingLanguages, |
176 | default: DEFAULT_APP_SETTINGS.spellcheckerLanguage, | 174 | default: DEFAULT_APP_SETTINGS.spellcheckerLanguage, |
@@ -230,7 +228,7 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e | |||
230 | cacheSize={cacheSize} | 228 | cacheSize={cacheSize} |
231 | isClearingAllCache={isClearingAllCache} | 229 | isClearingAllCache={isClearingAllCache} |
232 | onClearAllCache={clearAllCache} | 230 | onClearAllCache={clearAllCache} |
233 | isSpellcheckerPremiumFeature={spellcheckerConfig.isPremiumFeature} | 231 | isSpellcheckerPremiumFeature={spellcheckerConfig.isPremium} |
234 | /> | 232 | /> |
235 | </ErrorBoundary> | 233 | </ErrorBoundary> |
236 | ); | 234 | ); |