diff options
author | Stefan Malzner <stefan@adlk.io> | 2019-09-07 00:53:10 +0200 |
---|---|---|
committer | Stefan Malzner <stefan@adlk.io> | 2019-09-07 00:53:10 +0200 |
commit | 5d03b91dd789ffd6d3d5753c223b4b6412887220 (patch) | |
tree | b48a93aadcd5e77cd4f42d635edc598255286d4f /src/containers/settings | |
parent | Update CHANGELOG.md (diff) | |
download | ferdium-app-5d03b91dd789ffd6d3d5753c223b4b6412887220.tar.gz ferdium-app-5d03b91dd789ffd6d3d5753c223b4b6412887220.tar.zst ferdium-app-5d03b91dd789ffd6d3d5753c223b4b6412887220.zip |
feat(Todos): Add option to disable todos
Diffstat (limited to 'src/containers/settings')
-rw-r--r-- | src/containers/settings/EditSettingsScreen.js | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/src/containers/settings/EditSettingsScreen.js b/src/containers/settings/EditSettingsScreen.js index 67d52f102..65b5a45df 100644 --- a/src/containers/settings/EditSettingsScreen.js +++ b/src/containers/settings/EditSettingsScreen.js | |||
@@ -6,6 +6,7 @@ import { defineMessages, intlShape } from 'react-intl'; | |||
6 | import AppStore from '../../stores/AppStore'; | 6 | import AppStore from '../../stores/AppStore'; |
7 | import SettingsStore from '../../stores/SettingsStore'; | 7 | import SettingsStore from '../../stores/SettingsStore'; |
8 | import UserStore from '../../stores/UserStore'; | 8 | import UserStore from '../../stores/UserStore'; |
9 | import TodosStore from '../../features/todos/store'; | ||
9 | import Form from '../../lib/Form'; | 10 | import Form from '../../lib/Form'; |
10 | import { APP_LOCALES, SPELLCHECKER_LOCALES } from '../../i18n/languages'; | 11 | import { APP_LOCALES, SPELLCHECKER_LOCALES } from '../../i18n/languages'; |
11 | import { DEFAULT_APP_SETTINGS } from '../../config'; | 12 | import { DEFAULT_APP_SETTINGS } from '../../config'; |
@@ -17,6 +18,7 @@ import EditSettingsForm from '../../components/settings/settings/EditSettingsFor | |||
17 | import ErrorBoundary from '../../components/util/ErrorBoundary'; | 18 | import ErrorBoundary from '../../components/util/ErrorBoundary'; |
18 | 19 | ||
19 | import globalMessages from '../../i18n/globalMessages'; | 20 | import globalMessages from '../../i18n/globalMessages'; |
21 | import { DEFAULT_IS_FEATURE_ENABLED_BY_USER } from '../../features/todos'; | ||
20 | 22 | ||
21 | const messages = defineMessages({ | 23 | const messages = defineMessages({ |
22 | autoLaunchOnStart: { | 24 | autoLaunchOnStart: { |
@@ -67,6 +69,10 @@ const messages = defineMessages({ | |||
67 | id: 'settings.app.form.beta', | 69 | id: 'settings.app.form.beta', |
68 | defaultMessage: '!!!Include beta versions', | 70 | defaultMessage: '!!!Include beta versions', |
69 | }, | 71 | }, |
72 | enableTodos: { | ||
73 | id: 'settings.app.form.enableTodos', | ||
74 | defaultMessage: '!!!Enable Franz Todos', | ||
75 | }, | ||
70 | }); | 76 | }); |
71 | 77 | ||
72 | export default @inject('stores', 'actions') @observer class EditSettingsScreen extends Component { | 78 | export default @inject('stores', 'actions') @observer class EditSettingsScreen extends Component { |
@@ -75,7 +81,13 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e | |||
75 | }; | 81 | }; |
76 | 82 | ||
77 | onSubmit(settingsData) { | 83 | onSubmit(settingsData) { |
78 | const { app, settings, user } = this.props.actions; | 84 | const { todos } = this.props.stores; |
85 | const { | ||
86 | app, | ||
87 | settings, | ||
88 | user, | ||
89 | todos: todosActions, | ||
90 | } = this.props.actions; | ||
79 | 91 | ||
80 | app.launchOnStartup({ | 92 | app.launchOnStartup({ |
81 | enable: settingsData.autoLaunchOnStart, | 93 | enable: settingsData.autoLaunchOnStart, |
@@ -105,10 +117,16 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e | |||
105 | locale: settingsData.locale, | 117 | locale: settingsData.locale, |
106 | }, | 118 | }, |
107 | }); | 119 | }); |
120 | |||
121 | if (todos.isFeatureActive) { | ||
122 | todosActions.toggleTodosFeatureVisibility(); | ||
123 | } | ||
108 | } | 124 | } |
109 | 125 | ||
110 | prepareForm() { | 126 | prepareForm() { |
111 | const { app, settings, user } = this.props.stores; | 127 | const { |
128 | app, settings, user, todos, | ||
129 | } = this.props.stores; | ||
112 | const { intl } = this.context; | 130 | const { intl } = this.context; |
113 | 131 | ||
114 | const locales = getSelectOptions({ | 132 | const locales = getSelectOptions({ |
@@ -192,16 +210,28 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e | |||
192 | }, | 210 | }, |
193 | }; | 211 | }; |
194 | 212 | ||
213 | if (todos.isFeatureActive) { | ||
214 | config.fields.enableTodos = { | ||
215 | label: intl.formatMessage(messages.enableTodos), | ||
216 | value: todos.settings.isFeatureEnabledByUser, | ||
217 | default: DEFAULT_IS_FEATURE_ENABLED_BY_USER, | ||
218 | }; | ||
219 | } | ||
220 | |||
195 | return new Form(config); | 221 | return new Form(config); |
196 | } | 222 | } |
197 | 223 | ||
198 | render() { | 224 | render() { |
199 | const { | 225 | const { |
226 | app, | ||
227 | todos, | ||
228 | } = this.props.stores; | ||
229 | const { | ||
200 | updateStatus, | 230 | updateStatus, |
201 | cacheSize, | 231 | cacheSize, |
202 | updateStatusTypes, | 232 | updateStatusTypes, |
203 | isClearingAllCache, | 233 | isClearingAllCache, |
204 | } = this.props.stores.app; | 234 | } = app; |
205 | const { | 235 | const { |
206 | checkForUpdates, | 236 | checkForUpdates, |
207 | installUpdate, | 237 | installUpdate, |
@@ -224,6 +254,7 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e | |||
224 | isClearingAllCache={isClearingAllCache} | 254 | isClearingAllCache={isClearingAllCache} |
225 | onClearAllCache={clearAllCache} | 255 | onClearAllCache={clearAllCache} |
226 | isSpellcheckerIncludedInCurrentPlan={spellcheckerConfig.isIncludedInCurrentPlan} | 256 | isSpellcheckerIncludedInCurrentPlan={spellcheckerConfig.isIncludedInCurrentPlan} |
257 | isTodosEnabled={todos.isFeatureActive} | ||
227 | /> | 258 | /> |
228 | </ErrorBoundary> | 259 | </ErrorBoundary> |
229 | ); | 260 | ); |
@@ -235,6 +266,7 @@ EditSettingsScreen.wrappedComponent.propTypes = { | |||
235 | app: PropTypes.instanceOf(AppStore).isRequired, | 266 | app: PropTypes.instanceOf(AppStore).isRequired, |
236 | user: PropTypes.instanceOf(UserStore).isRequired, | 267 | user: PropTypes.instanceOf(UserStore).isRequired, |
237 | settings: PropTypes.instanceOf(SettingsStore).isRequired, | 268 | settings: PropTypes.instanceOf(SettingsStore).isRequired, |
269 | todos: PropTypes.instanceOf(TodosStore).isRequired, | ||
238 | }).isRequired, | 270 | }).isRequired, |
239 | actions: PropTypes.shape({ | 271 | actions: PropTypes.shape({ |
240 | app: PropTypes.shape({ | 272 | app: PropTypes.shape({ |
@@ -249,5 +281,8 @@ EditSettingsScreen.wrappedComponent.propTypes = { | |||
249 | user: PropTypes.shape({ | 281 | user: PropTypes.shape({ |
250 | update: PropTypes.func.isRequired, | 282 | update: PropTypes.func.isRequired, |
251 | }).isRequired, | 283 | }).isRequired, |
284 | todos: PropTypes.shape({ | ||
285 | toggleTodosFeatureVisibility: PropTypes.func.isRequired, | ||
286 | }).isRequired, | ||
252 | }).isRequired, | 287 | }).isRequired, |
253 | }; | 288 | }; |