1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
|
import { remote } from 'electron';
import React, { Component, Fragment } from 'react';
import PropTypes from 'prop-types';
import { observer } from 'mobx-react';
import { defineMessages, intlShape } from 'react-intl';
import Form from '../../../lib/Form';
import Button from '../../ui/Button';
import Toggle from '../../ui/Toggle';
import Select from '../../ui/Select';
import PremiumFeatureContainer from '../../ui/PremiumFeatureContainer';
import Input from '../../ui/Input';
import { FRANZ_TRANSLATION } from '../../../config';
const messages = defineMessages({
headline: {
id: 'settings.app.headline',
defaultMessage: '!!!Settings',
},
headlineGeneral: {
id: 'settings.app.headlineGeneral',
defaultMessage: '!!!General',
},
serverInfo: {
id: 'settings.app.serverInfo',
defaultMessage: '!!!We advice you to logout after changing your server as your settings might not be saved otherwise.',
},
todoServerInfo: {
id: 'settings.app.todoServerInfo',
defaultMessage: '!!!This server will be used for the "Franz Todo" feature. The default server will only work for premium users. (default: https://app.franztodos.com)',
},
headlineLanguage: {
id: 'settings.app.headlineLanguage',
defaultMessage: '!!!Language',
},
headlineUpdates: {
id: 'settings.app.headlineUpdates',
defaultMessage: '!!!Updates',
},
headlineAppearance: {
id: 'settings.app.headlineAppearance',
defaultMessage: '!!!Appearance',
},
headlineAdvanced: {
id: 'settings.app.headlineAdvanced',
defaultMessage: '!!!Advanced',
},
translationHelp: {
id: 'settings.app.translationHelp',
defaultMessage: '!!!Help us to translate Ferdi into your language.',
},
subheadlineCache: {
id: 'settings.app.subheadlineCache',
defaultMessage: '!!!Cache',
},
cacheInfo: {
id: 'settings.app.cacheInfo',
defaultMessage: '!!!Ferdi cache is currently using {size} of disk space.',
},
buttonClearAllCache: {
id: 'settings.app.buttonClearAllCache',
defaultMessage: '!!!Clear cache',
},
buttonSearchForUpdate: {
id: 'settings.app.buttonSearchForUpdate',
defaultMessage: '!!!Check for updates',
},
buttonInstallUpdate: {
id: 'settings.app.buttonInstallUpdate',
defaultMessage: '!!!Restart & install update',
},
updateStatusSearching: {
id: 'settings.app.updateStatusSearching',
defaultMessage: '!!!Is searching for update',
},
updateStatusAvailable: {
id: 'settings.app.updateStatusAvailable',
defaultMessage: '!!!Update available, downloading...',
},
updateStatusUpToDate: {
id: 'settings.app.updateStatusUpToDate',
defaultMessage: '!!!You are using the latest version of Franz',
},
currentVersion: {
id: 'settings.app.currentVersion',
defaultMessage: '!!!Current version:',
},
enableGPUAccelerationInfo: {
id: 'settings.app.restartRequired',
defaultMessage: '!!!Changes require restart',
},
languageDisclaimer: {
id: 'settings.app.languageDisclaimer',
defaultMessage: '!!!Official translations are English & German. All other languages are community based translations.',
},
});
export default @observer 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,
isClearingAllCache: PropTypes.bool.isRequired,
onClearAllCache: PropTypes.func.isRequired,
cacheSize: PropTypes.string.isRequired,
isSpellcheckerIncludedInCurrentPlan: PropTypes.bool.isRequired,
isTodosEnabled: PropTypes.bool.isRequired,
};
static contextTypes = {
intl: intlShape,
};
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,
isUpdateAvailable,
noUpdateAvailable,
updateIsReadyToInstall,
isClearingAllCache,
onClearAllCache,
cacheSize,
isSpellcheckerIncludedInCurrentPlan,
isTodosEnabled,
} = this.props;
const { intl } = this.context;
let updateButtonLabelMessage = messages.buttonSearchForUpdate;
if (isCheckingForUpdates) {
updateButtonLabelMessage = messages.updateStatusSearching;
} else if (isUpdateAvailable) {
updateButtonLabelMessage = messages.updateStatusAvailable;
} else {
updateButtonLabelMessage = messages.buttonSearchForUpdate;
}
const isLoggedIn = Boolean(localStorage.getItem('authToken'));
return (
<div className="settings__main">
<div className="settings__header">
<h1>{intl.formatMessage(messages.headline)}</h1>
</div>
<div className="settings__body">
<form
onSubmit={e => this.submit(e)}
onChange={e => this.submit(e)}
id="form"
>
{/* General */}
<h2 id="general">{intl.formatMessage(messages.headlineGeneral)}</h2>
<Toggle field={form.$('autoLaunchOnStart')} />
<Toggle field={form.$('runInBackground')} />
<Toggle field={form.$('enableSystemTray')} />
{process.platform === 'win32' && (
<Toggle field={form.$('minimizeToSystemTray')} />
)}
<Input
placeholder="Server"
onChange={e => this.submit(e)}
field={form.$('server')}
autoFocus
/>
{ isLoggedIn && (
<p>{ intl.formatMessage(messages.serverInfo) }</p>
)}
{isTodosEnabled && (
<>
<Toggle field={form.$('enableTodos')} />
<Input
placeholder="Todo Server"
onChange={e => this.submit(e)}
field={form.$('todoServer')}
autoFocus
/>
<p>{ intl.formatMessage(messages.todoServerInfo) }</p>
</>
)}
{/* Appearance */}
<h2 id="apperance">{intl.formatMessage(messages.headlineAppearance)}</h2>
<Toggle field={form.$('showDisabledServices')} />
<Toggle field={form.$('showMessageBadgeWhenMuted')} />
<Toggle field={form.$('darkMode')} />
{/* Language */}
<h2 id="language">{intl.formatMessage(messages.headlineLanguage)}</h2>
<Select field={form.$('locale')} showLabel={false} />
<PremiumFeatureContainer
condition={!isSpellcheckerIncludedInCurrentPlan}
gaEventInfo={{ category: 'User', event: 'upgrade', label: 'spellchecker' }}
>
<Fragment>
<Toggle
field={form.$('enableSpellchecking')}
/>
{form.$('enableSpellchecking').value && (
<Select field={form.$('spellcheckerLanguage')} />
)}
</Fragment>
</PremiumFeatureContainer>
<a
href={FRANZ_TRANSLATION}
target="_blank"
className="link"
>
{intl.formatMessage(messages.translationHelp)}
{' '}
<i className="mdi mdi-open-in-new" />
</a>
{/* Advanced */}
<h2 id="advanced">{intl.formatMessage(messages.headlineAdvanced)}</h2>
<Toggle field={form.$('enableGPUAcceleration')} />
<p className="settings__help">{intl.formatMessage(messages.enableGPUAccelerationInfo)}</p>
<div className="settings__settings-group">
<h3>
{intl.formatMessage(messages.subheadlineCache)}
</h3>
<p>
{intl.formatMessage(messages.cacheInfo, {
size: cacheSize,
})}
</p>
<p>
<Button
buttonType="secondary"
label={intl.formatMessage(messages.buttonClearAllCache)}
onClick={onClearAllCache}
disabled={isClearingAllCache}
loaded={!isClearingAllCache}
/>
</p>
</div>
{/* Updates */}
<h2 id="updates">{intl.formatMessage(messages.headlineUpdates)}</h2>
{updateIsReadyToInstall ? (
<Button
label={intl.formatMessage(messages.buttonInstallUpdate)}
onClick={installUpdate}
/>
) : (
<Button
buttonType="secondary"
label={intl.formatMessage(updateButtonLabelMessage)}
onClick={checkForUpdates}
disabled={isCheckingForUpdates || isUpdateAvailable}
loaded={!isCheckingForUpdates || !isUpdateAvailable}
/>
)}
{noUpdateAvailable && (
<p>{intl.formatMessage(messages.updateStatusUpToDate)}</p>
)}
<br />
<Toggle field={form.$('beta')} />
{intl.formatMessage(messages.currentVersion)}
{' '}
{remote.app.getVersion()}
<p className="settings__message">
<span className="mdi mdi-information" />
{intl.formatMessage(messages.languageDisclaimer)}
</p>
<p className="settings__message">
<span className="mdi mdi-github-face" />
Ferdi is based on
{' '}
<a href="https://github.com/meetfranz/franz" target="_blank">Franz</a>
, a project published
under the
{' '}
<a href="https://github.com/meetfranz/franz/blob/master/LICENSE" target="_blank">Apache-2.0 License</a>
</p>
</form>
</div>
</div>
);
}
}
|