diff options
author | 2018-01-03 23:46:54 +0100 | |
---|---|---|
committer | 2018-01-03 23:46:54 +0100 | |
commit | be801ff55d765e519f58a34d9854fb464a1ff77e (patch) | |
tree | 48c7972577c6b73cb5ca0d1947c5a8b198b98614 /src/components/settings | |
parent | Fix lint issues (diff) | |
download | ferdium-app-be801ff55d765e519f58a34d9854fb464a1ff77e.tar.gz ferdium-app-be801ff55d765e519f58a34d9854fb464a1ff77e.tar.zst ferdium-app-be801ff55d765e519f58a34d9854fb464a1ff77e.zip |
feat(App): Add option to clear app cache (@dannyqiu)
Diffstat (limited to 'src/components/settings')
-rw-r--r-- | src/components/settings/services/EditServiceForm.js | 30 | ||||
-rw-r--r-- | src/components/settings/settings/EditSettingsForm.js | 51 |
2 files changed, 28 insertions, 53 deletions
diff --git a/src/components/settings/services/EditServiceForm.js b/src/components/settings/services/EditServiceForm.js index b5300f605..4458c4c5a 100644 --- a/src/components/settings/services/EditServiceForm.js +++ b/src/components/settings/services/EditServiceForm.js | |||
@@ -71,14 +71,6 @@ const messages = defineMessages({ | |||
71 | id: 'settings.service.form.isMutedInfo', | 71 | id: 'settings.service.form.isMutedInfo', |
72 | defaultMessage: '!!!When disabled, all notification sounds and audio playback are muted', | 72 | defaultMessage: '!!!When disabled, all notification sounds and audio playback are muted', |
73 | }, | 73 | }, |
74 | buttonClearCache: { | ||
75 | id: 'settings.service.form.buttonClearCache', | ||
76 | defaultMessage: '!!!Clear cache', | ||
77 | }, | ||
78 | buttonClearingCache: { | ||
79 | id: 'settings.service.form.buttonClearingCache', | ||
80 | defaultMessage: '!!!Clearing cache', | ||
81 | }, | ||
82 | headlineNotifications: { | 74 | headlineNotifications: { |
83 | id: 'settings.service.form.headlineNotifications', | 75 | id: 'settings.service.form.headlineNotifications', |
84 | defaultMessage: '!!!Notifications', | 76 | defaultMessage: '!!!Notifications', |
@@ -110,10 +102,8 @@ export default class EditServiceForm extends Component { | |||
110 | form: PropTypes.instanceOf(Form).isRequired, | 102 | form: PropTypes.instanceOf(Form).isRequired, |
111 | onSubmit: PropTypes.func.isRequired, | 103 | onSubmit: PropTypes.func.isRequired, |
112 | onDelete: PropTypes.func.isRequired, | 104 | onDelete: PropTypes.func.isRequired, |
113 | onClearCache: PropTypes.func.isRequired, | ||
114 | isSaving: PropTypes.bool.isRequired, | 105 | isSaving: PropTypes.bool.isRequired, |
115 | isDeleting: PropTypes.bool.isRequired, | 106 | isDeleting: PropTypes.bool.isRequired, |
116 | isClearingCache: PropTypes.bool.isRequired, | ||
117 | }; | 107 | }; |
118 | 108 | ||
119 | static defaultProps = { | 109 | static defaultProps = { |
@@ -168,9 +158,7 @@ export default class EditServiceForm extends Component { | |||
168 | form, | 158 | form, |
169 | isSaving, | 159 | isSaving, |
170 | isDeleting, | 160 | isDeleting, |
171 | isClearingCache, | ||
172 | onDelete, | 161 | onDelete, |
173 | onClearCache, | ||
174 | } = this.props; | 162 | } = this.props; |
175 | const { intl } = this.context; | 163 | const { intl } = this.context; |
176 | 164 | ||
@@ -193,23 +181,6 @@ export default class EditServiceForm extends Component { | |||
193 | /> | 181 | /> |
194 | ); | 182 | ); |
195 | 183 | ||
196 | const clearCacheButton = isClearingCache ? ( | ||
197 | <Button | ||
198 | buttonType="secondary" | ||
199 | className="settings__clear-cache-button" | ||
200 | loaded={false} | ||
201 | label={intl.formatMessage(messages.buttonClearingCache)} | ||
202 | disabled | ||
203 | /> | ||
204 | ) : ( | ||
205 | <Button | ||
206 | buttonType="warning" | ||
207 | className="settings__clear-cache-button" | ||
208 | label={intl.formatMessage(messages.buttonClearCache)} | ||
209 | onClick={onClearCache} | ||
210 | /> | ||
211 | ); | ||
212 | |||
213 | let activeTabIndex = 0; | 184 | let activeTabIndex = 0; |
214 | if (recipe.hasHostedOption && service.team) { | 185 | if (recipe.hasHostedOption && service.team) { |
215 | activeTabIndex = 1; | 186 | activeTabIndex = 1; |
@@ -316,7 +287,6 @@ export default class EditServiceForm extends Component { | |||
316 | <div className="settings__settings-group"> | 287 | <div className="settings__settings-group"> |
317 | <h3>{intl.formatMessage(messages.headlineGeneral)}</h3> | 288 | <h3>{intl.formatMessage(messages.headlineGeneral)}</h3> |
318 | <Toggle field={form.$('isEnabled')} /> | 289 | <Toggle field={form.$('isEnabled')} /> |
319 | {clearCacheButton} | ||
320 | </div> | 290 | </div> |
321 | </div> | 291 | </div> |
322 | {recipe.message && ( | 292 | {recipe.message && ( |
diff --git a/src/components/settings/settings/EditSettingsForm.js b/src/components/settings/settings/EditSettingsForm.js index 074a4b731..4f027638c 100644 --- a/src/components/settings/settings/EditSettingsForm.js +++ b/src/components/settings/settings/EditSettingsForm.js | |||
@@ -40,13 +40,13 @@ const messages = defineMessages({ | |||
40 | id: 'settings.app.translationHelp', | 40 | id: 'settings.app.translationHelp', |
41 | defaultMessage: '!!!Help us to translate Franz into your language.', | 41 | defaultMessage: '!!!Help us to translate Franz into your language.', |
42 | }, | 42 | }, |
43 | cacheInfo: { | ||
44 | id: 'settings.app.cacheInfo', | ||
45 | defaultMessage: '!!!Franz cache is currently using {size} of disk space.', | ||
46 | }, | ||
43 | buttonClearAllCache: { | 47 | buttonClearAllCache: { |
44 | id: 'settings.app.buttonClearAllCache', | 48 | id: 'settings.app.buttonClearAllCache', |
45 | defaultMessage: '!!!Clear global cache for Franz and all services', | 49 | defaultMessage: '!!!Clear cache', |
46 | }, | ||
47 | buttonClearingAllCache: { | ||
48 | id: 'settings.app.buttonClearingAllCache', | ||
49 | defaultMessage: '!!!Clearing global cache...', | ||
50 | }, | 50 | }, |
51 | buttonSearchForUpdate: { | 51 | buttonSearchForUpdate: { |
52 | id: 'settings.app.buttonSearchForUpdate', | 52 | id: 'settings.app.buttonSearchForUpdate', |
@@ -87,6 +87,7 @@ export default class EditSettingsForm extends Component { | |||
87 | updateIsReadyToInstall: PropTypes.bool.isRequired, | 87 | updateIsReadyToInstall: PropTypes.bool.isRequired, |
88 | isClearingAllCache: PropTypes.bool.isRequired, | 88 | isClearingAllCache: PropTypes.bool.isRequired, |
89 | onClearAllCache: PropTypes.func.isRequired, | 89 | onClearAllCache: PropTypes.func.isRequired, |
90 | cacheSize: PropTypes.string.isRequired, | ||
90 | }; | 91 | }; |
91 | 92 | ||
92 | static contextTypes = { | 93 | static contextTypes = { |
@@ -115,6 +116,7 @@ export default class EditSettingsForm extends Component { | |||
115 | updateIsReadyToInstall, | 116 | updateIsReadyToInstall, |
116 | isClearingAllCache, | 117 | isClearingAllCache, |
117 | onClearAllCache, | 118 | onClearAllCache, |
119 | cacheSize, | ||
118 | } = this.props; | 120 | } = this.props; |
119 | const { intl } = this.context; | 121 | const { intl } = this.context; |
120 | 122 | ||
@@ -127,23 +129,6 @@ export default class EditSettingsForm extends Component { | |||
127 | updateButtonLabelMessage = messages.buttonSearchForUpdate; | 129 | updateButtonLabelMessage = messages.buttonSearchForUpdate; |
128 | } | 130 | } |
129 | 131 | ||
130 | const clearAllCacheButton = isClearingAllCache ? ( | ||
131 | <Button | ||
132 | buttonType="secondary" | ||
133 | className="settings__clear-all-cache-button" | ||
134 | loaded={false} | ||
135 | label={intl.formatMessage(messages.buttonClearingAllCache)} | ||
136 | disabled | ||
137 | /> | ||
138 | ) : ( | ||
139 | <Button | ||
140 | buttonType="warning" | ||
141 | className="settings__clear-all-cache-button" | ||
142 | label={intl.formatMessage(messages.buttonClearAllCache)} | ||
143 | onClick={onClearAllCache} | ||
144 | /> | ||
145 | ); | ||
146 | |||
147 | return ( | 132 | return ( |
148 | <div className="settings__main"> | 133 | <div className="settings__main"> |
149 | <div className="settings__header"> | 134 | <div className="settings__header"> |
@@ -184,7 +169,26 @@ export default class EditSettingsForm extends Component { | |||
184 | <h2 id="advanced">{intl.formatMessage(messages.headlineAdvanced)}</h2> | 169 | <h2 id="advanced">{intl.formatMessage(messages.headlineAdvanced)}</h2> |
185 | <Toggle field={form.$('enableSpellchecking')} /> | 170 | <Toggle field={form.$('enableSpellchecking')} /> |
186 | {/* <Select field={form.$('spellcheckingLanguage')} /> */} | 171 | {/* <Select field={form.$('spellcheckingLanguage')} /> */} |
187 | {clearAllCacheButton} | 172 | <div className="settings__settings-group"> |
173 | <h3> | ||
174 | {/* {intl.formatMessage(messages.headlineGeneral)} */} | ||
175 | Service cache | ||
176 | </h3> | ||
177 | <p> | ||
178 | {intl.formatMessage(messages.cacheInfo, { | ||
179 | size: cacheSize, | ||
180 | })} | ||
181 | </p> | ||
182 | <p> | ||
183 | <Button | ||
184 | buttonType="secondary" | ||
185 | label={intl.formatMessage(messages.buttonClearAllCache)} | ||
186 | onClick={onClearAllCache} | ||
187 | disabled={isClearingAllCache} | ||
188 | loaded={!isClearingAllCache} | ||
189 | /> | ||
190 | </p> | ||
191 | </div> | ||
188 | 192 | ||
189 | {/* Updates */} | 193 | {/* Updates */} |
190 | <h2 id="updates">{intl.formatMessage(messages.headlineUpdates)}</h2> | 194 | <h2 id="updates">{intl.formatMessage(messages.headlineUpdates)}</h2> |
@@ -195,6 +199,7 @@ export default class EditSettingsForm extends Component { | |||
195 | /> | 199 | /> |
196 | ) : ( | 200 | ) : ( |
197 | <Button | 201 | <Button |
202 | buttonType="secondary" | ||
198 | label={intl.formatMessage(updateButtonLabelMessage)} | 203 | label={intl.formatMessage(updateButtonLabelMessage)} |
199 | onClick={checkForUpdates} | 204 | onClick={checkForUpdates} |
200 | disabled={isCheckingForUpdates || isUpdateAvailable} | 205 | disabled={isCheckingForUpdates || isUpdateAvailable} |