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
|
import { remote } from 'electron';
import React, { Component } 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';
const messages = defineMessages({
headline: {
id: 'settings.app.headline',
defaultMessage: '!!!Settings',
},
headlineGeneral: {
id: 'settings.app.headlineGeneral',
defaultMessage: '!!!General',
},
headlineLanguage: {
id: 'settings.app.headlineLanguage',
defaultMessage: '!!!Language',
},
headlineUpdates: {
id: 'settings.app.headlineUpdates',
defaultMessage: '!!!Updates',
},
headlineAppearance: {
id: 'settings.app.headlineAppearance',
defaultMessage: '!!!Appearance',
},
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:',
},
});
@observer
export default 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,
};
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,
} = 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;
}
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"
>
<h2>{intl.formatMessage(messages.headlineGeneral)}</h2>
<Toggle field={form.$('autoLaunchOnStart')} />
<Toggle field={form.$('runInBackground')} />
<Toggle field={form.$('enableSystemTray')} />
{process.platform === 'win32' && (
<Toggle field={form.$('minimizeToSystemTray')} />
)}
<h2>{intl.formatMessage(messages.headlineAppearance)}</h2>
<Toggle field={form.$('showDisabledServices')} />
<h2>{intl.formatMessage(messages.headlineLanguage)}</h2>
<Select field={form.$('locale')} showLabel={false} />
<h2>{intl.formatMessage(messages.headlineUpdates)}</h2>
{updateIsReadyToInstall ? (
<Button
label={intl.formatMessage(messages.buttonInstallUpdate)}
onClick={installUpdate}
/>
) : (
<Button
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()}
</form>
</div>
</div>
);
}
}
|