aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Vijay A <avijayr@protonmail.com>2021-09-08 23:44:24 +0530
committerLibravatar Vijay A <avijayr@protonmail.com>2021-09-08 23:52:06 +0530
commit4960927289b88bcacbf7af2baa9c551deac64072 (patch)
tree4a338c63d2d42e06d37e6f01d14c5f2048c76ace
parentfix: U2F devices not recognised in snapcraft image (#1892) (diff)
downloadferdium-app-4960927289b88bcacbf7af2baa9c551deac64072.tar.gz
ferdium-app-4960927289b88bcacbf7af2baa9c551deac64072.tar.zst
ferdium-app-4960927289b88bcacbf7af2baa9c551deac64072.zip
Revert "chore: proxy feature is always turned on: remove 'enabled' flag"
-rw-r--r--src/components/settings/services/EditServiceForm.js68
-rw-r--r--src/containers/settings/EditServiceScreen.js77
-rw-r--r--src/features/serviceProxy/index.js29
-rw-r--r--src/i18n/messages/src/containers/settings/EditServiceScreen.json76
4 files changed, 135 insertions, 115 deletions
diff --git a/src/components/settings/services/EditServiceForm.js b/src/components/settings/services/EditServiceForm.js
index 23c667b82..c41cdd56a 100644
--- a/src/components/settings/services/EditServiceForm.js
+++ b/src/components/settings/services/EditServiceForm.js
@@ -144,6 +144,7 @@ export default @observer class EditServiceForm extends Component {
144 openRecipeFile: PropTypes.func.isRequired, 144 openRecipeFile: PropTypes.func.isRequired,
145 isSaving: PropTypes.bool.isRequired, 145 isSaving: PropTypes.bool.isRequired,
146 isDeleting: PropTypes.bool.isRequired, 146 isDeleting: PropTypes.bool.isRequired,
147 isProxyFeatureEnabled: PropTypes.bool.isRequired,
147 }; 148 };
148 149
149 static defaultProps = { 150 static defaultProps = {
@@ -205,6 +206,7 @@ export default @observer class EditServiceForm extends Component {
205 isDeleting, 206 isDeleting,
206 onDelete, 207 onDelete,
207 openRecipeFile, 208 openRecipeFile,
209 isProxyFeatureEnabled,
208 } = this.props; 210 } = this.props;
209 const { intl } = this.context; 211 const { intl } = this.context;
210 212
@@ -368,40 +370,42 @@ export default @observer class EditServiceForm extends Component {
368 </div> 370 </div>
369 )} 371 )}
370 372
371 <div className="settings__settings-group"> 373 {isProxyFeatureEnabled && (
372 <h3> 374 <div className="settings__settings-group">
373 {intl.formatMessage(messages.headlineProxy)} 375 <h3>
374 <span className="badge badge--success">beta</span> 376 {intl.formatMessage(messages.headlineProxy)}
375 </h3> 377 <span className="badge badge--success">beta</span>
376 <Toggle field={form.$('proxy.isEnabled')} /> 378 </h3>
377 {form.$('proxy.isEnabled').value && ( 379 <Toggle field={form.$('proxy.isEnabled')} />
378 <> 380 {form.$('proxy.isEnabled').value && (
379 <div className="grid"> 381 <>
380 <div className="grid__row"> 382 <div className="grid">
381 <Input field={form.$('proxy.host')} className="proxyHost" /> 383 <div className="grid__row">
382 <Input field={form.$('proxy.port')} /> 384 <Input field={form.$('proxy.host')} className="proxyHost" />
385 <Input field={form.$('proxy.port')} />
386 </div>
383 </div> 387 </div>
384 </div> 388 <div className="grid">
385 <div className="grid"> 389 <div className="grid__row">
386 <div className="grid__row"> 390 <Input field={form.$('proxy.user')} />
387 <Input field={form.$('proxy.user')} /> 391 <Input
388 <Input 392 field={form.$('proxy.password')}
389 field={form.$('proxy.password')} 393 showPasswordToggle
390 showPasswordToggle 394 />
391 /> 395 </div>
392 </div> 396 </div>
393 </div> 397 <p>
394 <p> 398 <span className="mdi mdi-information" />
395 <span className="mdi mdi-information" /> 399 {intl.formatMessage(messages.proxyRestartInfo)}
396 {intl.formatMessage(messages.proxyRestartInfo)} 400 </p>
397 </p> 401 <p>
398 <p> 402 <span className="mdi mdi-information" />
399 <span className="mdi mdi-information" /> 403 {intl.formatMessage(messages.proxyInfo)}
400 {intl.formatMessage(messages.proxyInfo)} 404 </p>
401 </p> 405 </>
402 </> 406 )}
403 )} 407 </div>
404 </div> 408 )}
405 409
406 <div className="user-agent"> 410 <div className="user-agent">
407 <Input field={form.$('userAgentPref')} /> 411 <Input field={form.$('userAgentPref')} />
diff --git a/src/containers/settings/EditServiceScreen.js b/src/containers/settings/EditServiceScreen.js
index 3a66a27e6..c880e97ae 100644
--- a/src/containers/settings/EditServiceScreen.js
+++ b/src/containers/settings/EditServiceScreen.js
@@ -18,6 +18,8 @@ import ErrorBoundary from '../../components/util/ErrorBoundary';
18import { required, url, oneRequired } from '../../helpers/validation-helpers'; 18import { required, url, oneRequired } from '../../helpers/validation-helpers';
19import { getSelectOptions } from '../../helpers/i18n-helpers'; 19import { getSelectOptions } from '../../helpers/i18n-helpers';
20 20
21import { config as proxyFeature } from '../../features/serviceProxy';
22
21import { SPELLCHECKER_LOCALES } from '../../i18n/languages'; 23import { SPELLCHECKER_LOCALES } from '../../i18n/languages';
22 24
23import globalMessages from '../../i18n/globalMessages'; 25import globalMessages from '../../i18n/globalMessages';
@@ -129,7 +131,7 @@ export default @inject('stores', 'actions') @observer class EditServiceScreen ex
129 } 131 }
130 } 132 }
131 133
132 prepareForm(recipe, service) { 134 prepareForm(recipe, service, proxy) {
133 const { 135 const {
134 intl, 136 intl,
135 } = this.context; 137 } = this.context;
@@ -273,42 +275,44 @@ export default @inject('stores', 'actions') @observer class EditServiceScreen ex
273 }); 275 });
274 } 276 }
275 277
276 const serviceProxyConfig = stores.settings.proxy[service.id] || {}; 278 if (proxy.isEnabled) {
277 279 const serviceProxyConfig = stores.settings.proxy[service.id] || {};
278 Object.assign(config.fields, { 280
279 proxy: { 281 Object.assign(config.fields, {
280 name: 'proxy', 282 proxy: {
281 label: 'proxy', 283 name: 'proxy',
282 fields: { 284 label: 'proxy',
283 isEnabled: { 285 fields: {
284 label: intl.formatMessage(messages.enableProxy), 286 isEnabled: {
285 value: serviceProxyConfig.isEnabled, 287 label: intl.formatMessage(messages.enableProxy),
286 default: false, 288 value: serviceProxyConfig.isEnabled,
287 }, 289 default: false,
288 host: { 290 },
289 label: intl.formatMessage(messages.proxyHost), 291 host: {
290 value: serviceProxyConfig.host, 292 label: intl.formatMessage(messages.proxyHost),
291 default: '', 293 value: serviceProxyConfig.host,
292 }, 294 default: '',
293 port: { 295 },
294 label: intl.formatMessage(messages.proxyPort), 296 port: {
295 value: serviceProxyConfig.port, 297 label: intl.formatMessage(messages.proxyPort),
296 default: '', 298 value: serviceProxyConfig.port,
297 }, 299 default: '',
298 user: { 300 },
299 label: intl.formatMessage(messages.proxyUser), 301 user: {
300 value: serviceProxyConfig.user, 302 label: intl.formatMessage(messages.proxyUser),
301 default: '', 303 value: serviceProxyConfig.user,
302 }, 304 default: '',
303 password: { 305 },
304 label: intl.formatMessage(messages.proxyPassword), 306 password: {
305 value: serviceProxyConfig.password, 307 label: intl.formatMessage(messages.proxyPassword),
306 default: '', 308 value: serviceProxyConfig.password,
307 type: 'password', 309 default: '',
310 type: 'password',
311 },
308 }, 312 },
309 }, 313 },
310 }, 314 });
311 }); 315 }
312 316
313 return new Form(config); 317 return new Form(config);
314 } 318 }
@@ -377,7 +381,7 @@ export default @inject('stores', 'actions') @observer class EditServiceScreen ex
377 ); 381 );
378 } 382 }
379 383
380 const form = this.prepareForm(recipe, service); 384 const form = this.prepareForm(recipe, service, proxyFeature);
381 385
382 return ( 386 return (
383 <ErrorBoundary> 387 <ErrorBoundary>
@@ -393,6 +397,7 @@ export default @inject('stores', 'actions') @observer class EditServiceScreen ex
393 onSubmit={(d) => this.onSubmit(d)} 397 onSubmit={(d) => this.onSubmit(d)}
394 onDelete={() => this.deleteService()} 398 onDelete={() => this.deleteService()}
395 openRecipeFile={(file) => this.openRecipeFile(file)} 399 openRecipeFile={(file) => this.openRecipeFile(file)}
400 isProxyFeatureEnabled={proxyFeature.isEnabled}
396 /> 401 />
397 </ErrorBoundary> 402 </ErrorBoundary>
398 ); 403 );
diff --git a/src/features/serviceProxy/index.js b/src/features/serviceProxy/index.js
index 125b4729f..eb7116651 100644
--- a/src/features/serviceProxy/index.js
+++ b/src/features/serviceProxy/index.js
@@ -1,26 +1,37 @@
1import { autorun } from 'mobx'; 1import { autorun, observable } from 'mobx';
2import { session } from '@electron/remote'; 2import { session } from '@electron/remote';
3 3
4const debug = require('debug')('Ferdi:feature:serviceProxy'); 4const debug = require('debug')('Ferdi:feature:serviceProxy');
5 5
6export const config = observable({
7 isEnabled: true,
8});
9
6export default function init(stores) { 10export default function init(stores) {
7 debug('Initializing `serviceProxy` feature'); 11 debug('Initializing `serviceProxy` feature');
8 12
9 autorun(() => { 13 autorun(() => {
14 config.isEnabled = true;
15
10 const services = stores.services.enabled; 16 const services = stores.services.enabled;
11 const proxySettings = stores.settings.proxy; 17 const proxySettings = stores.settings.proxy;
12 18
13 debug('Service Proxy autorun'); 19 debug('Service Proxy autorun');
14 20
15 services.forEach((service) => { 21 services.forEach((service) => {
16 const serviceProxyConfig = proxySettings[service.id]; 22 const s = session.fromPartition(`persist:service-${service.id}`);
17 if (serviceProxyConfig && serviceProxyConfig.isEnabled && serviceProxyConfig.host) { 23
18 const proxyHost = `${serviceProxyConfig.host}${serviceProxyConfig.port ? `:${serviceProxyConfig.port}` : ''}`; 24 if (config.isEnabled) {
19 debug(`Setting proxy config from service settings for "${service.name}" (${service.id}) to`, proxyHost); 25 const serviceProxyConfig = proxySettings[service.id];
20 26
21 session.fromPartition(`persist:service-${service.id}`).setProxy({ proxyRules: proxyHost }, () => { 27 if (serviceProxyConfig && serviceProxyConfig.isEnabled && serviceProxyConfig.host) {
22 debug(`Using proxy "${proxyHost}" for "${service.name}" (${service.id})`); 28 const proxyHost = `${serviceProxyConfig.host}${serviceProxyConfig.port ? `:${serviceProxyConfig.port}` : ''}`;
23 }); 29 debug(`Setting proxy config from service settings for "${service.name}" (${service.id}) to`, proxyHost);
30
31 s.setProxy({ proxyRules: proxyHost }, () => {
32 debug(`Using proxy "${proxyHost}" for "${service.name}" (${service.id})`);
33 });
34 }
24 } 35 }
25 }); 36 });
26 }); 37 });
diff --git a/src/i18n/messages/src/containers/settings/EditServiceScreen.json b/src/i18n/messages/src/containers/settings/EditServiceScreen.json
index 4e44b3c8c..6744a9ff3 100644
--- a/src/i18n/messages/src/containers/settings/EditServiceScreen.json
+++ b/src/i18n/messages/src/containers/settings/EditServiceScreen.json
@@ -4,11 +4,11 @@
4 "defaultMessage": "!!!Name", 4 "defaultMessage": "!!!Name",
5 "file": "src/containers/settings/EditServiceScreen.js", 5 "file": "src/containers/settings/EditServiceScreen.js",
6 "start": { 6 "start": {
7 "line": 26, 7 "line": 28,
8 "column": 8 8 "column": 8
9 }, 9 },
10 "end": { 10 "end": {
11 "line": 29, 11 "line": 31,
12 "column": 3 12 "column": 3
13 } 13 }
14 }, 14 },
@@ -17,11 +17,11 @@
17 "defaultMessage": "!!!Enable service", 17 "defaultMessage": "!!!Enable service",
18 "file": "src/containers/settings/EditServiceScreen.js", 18 "file": "src/containers/settings/EditServiceScreen.js",
19 "start": { 19 "start": {
20 "line": 30, 20 "line": 32,
21 "column": 17 21 "column": 17
22 }, 22 },
23 "end": { 23 "end": {
24 "line": 33, 24 "line": 35,
25 "column": 3 25 "column": 3
26 } 26 }
27 }, 27 },
@@ -30,11 +30,11 @@
30 "defaultMessage": "!!!Enable hibernation", 30 "defaultMessage": "!!!Enable hibernation",
31 "file": "src/containers/settings/EditServiceScreen.js", 31 "file": "src/containers/settings/EditServiceScreen.js",
32 "start": { 32 "start": {
33 "line": 34, 33 "line": 36,
34 "column": 21 34 "column": 21
35 }, 35 },
36 "end": { 36 "end": {
37 "line": 37, 37 "line": 39,
38 "column": 3 38 "column": 3
39 } 39 }
40 }, 40 },
@@ -43,11 +43,11 @@
43 "defaultMessage": "!!!Enable Notifications", 43 "defaultMessage": "!!!Enable Notifications",
44 "file": "src/containers/settings/EditServiceScreen.js", 44 "file": "src/containers/settings/EditServiceScreen.js",
45 "start": { 45 "start": {
46 "line": 38, 46 "line": 40,
47 "column": 22 47 "column": 22
48 }, 48 },
49 "end": { 49 "end": {
50 "line": 41, 50 "line": 43,
51 "column": 3 51 "column": 3
52 } 52 }
53 }, 53 },
@@ -56,11 +56,11 @@
56 "defaultMessage": "!!!Show unread message badges", 56 "defaultMessage": "!!!Show unread message badges",
57 "file": "src/containers/settings/EditServiceScreen.js", 57 "file": "src/containers/settings/EditServiceScreen.js",
58 "start": { 58 "start": {
59 "line": 42, 59 "line": 44,
60 "column": 15 60 "column": 15
61 }, 61 },
62 "end": { 62 "end": {
63 "line": 45, 63 "line": 47,
64 "column": 3 64 "column": 3
65 } 65 }
66 }, 66 },
@@ -69,11 +69,11 @@
69 "defaultMessage": "!!!Enable audio", 69 "defaultMessage": "!!!Enable audio",
70 "file": "src/containers/settings/EditServiceScreen.js", 70 "file": "src/containers/settings/EditServiceScreen.js",
71 "start": { 71 "start": {
72 "line": 46, 72 "line": 48,
73 "column": 15 73 "column": 15
74 }, 74 },
75 "end": { 75 "end": {
76 "line": 49, 76 "line": 51,
77 "column": 3 77 "column": 3
78 } 78 }
79 }, 79 },
@@ -82,11 +82,11 @@
82 "defaultMessage": "!!!Team", 82 "defaultMessage": "!!!Team",
83 "file": "src/containers/settings/EditServiceScreen.js", 83 "file": "src/containers/settings/EditServiceScreen.js",
84 "start": { 84 "start": {
85 "line": 50, 85 "line": 52,
86 "column": 8 86 "column": 8
87 }, 87 },
88 "end": { 88 "end": {
89 "line": 53, 89 "line": 55,
90 "column": 3 90 "column": 3
91 } 91 }
92 }, 92 },
@@ -95,11 +95,11 @@
95 "defaultMessage": "!!!Service URL", 95 "defaultMessage": "!!!Service URL",
96 "file": "src/containers/settings/EditServiceScreen.js", 96 "file": "src/containers/settings/EditServiceScreen.js",
97 "start": { 97 "start": {
98 "line": 54, 98 "line": 56,
99 "column": 13 99 "column": 13
100 }, 100 },
101 "end": { 101 "end": {
102 "line": 57, 102 "line": 59,
103 "column": 3 103 "column": 3
104 } 104 }
105 }, 105 },
@@ -108,11 +108,11 @@
108 "defaultMessage": "!!!Show message badge for all new messages", 108 "defaultMessage": "!!!Show message badge for all new messages",
109 "file": "src/containers/settings/EditServiceScreen.js", 109 "file": "src/containers/settings/EditServiceScreen.js",
110 "start": { 110 "start": {
111 "line": 58, 111 "line": 60,
112 "column": 20 112 "column": 20
113 }, 113 },
114 "end": { 114 "end": {
115 "line": 61, 115 "line": 63,
116 "column": 3 116 "column": 3
117 } 117 }
118 }, 118 },
@@ -121,11 +121,11 @@
121 "defaultMessage": "!!!Custom icon", 121 "defaultMessage": "!!!Custom icon",
122 "file": "src/containers/settings/EditServiceScreen.js", 122 "file": "src/containers/settings/EditServiceScreen.js",
123 "start": { 123 "start": {
124 "line": 62, 124 "line": 64,
125 "column": 8 125 "column": 8
126 }, 126 },
127 "end": { 127 "end": {
128 "line": 65, 128 "line": 67,
129 "column": 3 129 "column": 3
130 } 130 }
131 }, 131 },
@@ -134,11 +134,11 @@
134 "defaultMessage": "!!!Enable Dark Mode", 134 "defaultMessage": "!!!Enable Dark Mode",
135 "file": "src/containers/settings/EditServiceScreen.js", 135 "file": "src/containers/settings/EditServiceScreen.js",
136 "start": { 136 "start": {
137 "line": 66, 137 "line": 68,
138 "column": 18 138 "column": 18
139 }, 139 },
140 "end": { 140 "end": {
141 "line": 69, 141 "line": 71,
142 "column": 3 142 "column": 3
143 } 143 }
144 }, 144 },
@@ -147,11 +147,11 @@
147 "defaultMessage": "!!!Dark Reader Brightness", 147 "defaultMessage": "!!!Dark Reader Brightness",
148 "file": "src/containers/settings/EditServiceScreen.js", 148 "file": "src/containers/settings/EditServiceScreen.js",
149 "start": { 149 "start": {
150 "line": 70, 150 "line": 72,
151 "column": 24 151 "column": 24
152 }, 152 },
153 "end": { 153 "end": {
154 "line": 73, 154 "line": 75,
155 "column": 3 155 "column": 3
156 } 156 }
157 }, 157 },
@@ -160,11 +160,11 @@
160 "defaultMessage": "!!!Dark Reader Contrast", 160 "defaultMessage": "!!!Dark Reader Contrast",
161 "file": "src/containers/settings/EditServiceScreen.js", 161 "file": "src/containers/settings/EditServiceScreen.js",
162 "start": { 162 "start": {
163 "line": 74, 163 "line": 76,
164 "column": 22 164 "column": 22
165 }, 165 },
166 "end": { 166 "end": {
167 "line": 77, 167 "line": 79,
168 "column": 3 168 "column": 3
169 } 169 }
170 }, 170 },
@@ -173,11 +173,11 @@
173 "defaultMessage": "!!!Dark Reader Sepia", 173 "defaultMessage": "!!!Dark Reader Sepia",
174 "file": "src/containers/settings/EditServiceScreen.js", 174 "file": "src/containers/settings/EditServiceScreen.js",
175 "start": { 175 "start": {
176 "line": 78, 176 "line": 80,
177 "column": 19 177 "column": 19
178 }, 178 },
179 "end": { 179 "end": {
180 "line": 81, 180 "line": 83,
181 "column": 3 181 "column": 3
182 } 182 }
183 }, 183 },
@@ -186,11 +186,11 @@
186 "defaultMessage": "!!!Use Proxy", 186 "defaultMessage": "!!!Use Proxy",
187 "file": "src/containers/settings/EditServiceScreen.js", 187 "file": "src/containers/settings/EditServiceScreen.js",
188 "start": { 188 "start": {
189 "line": 82, 189 "line": 84,
190 "column": 15 190 "column": 15
191 }, 191 },
192 "end": { 192 "end": {
193 "line": 85, 193 "line": 87,
194 "column": 3 194 "column": 3
195 } 195 }
196 }, 196 },
@@ -199,11 +199,11 @@
199 "defaultMessage": "!!!Proxy Host/IP", 199 "defaultMessage": "!!!Proxy Host/IP",
200 "file": "src/containers/settings/EditServiceScreen.js", 200 "file": "src/containers/settings/EditServiceScreen.js",
201 "start": { 201 "start": {
202 "line": 86, 202 "line": 88,
203 "column": 13 203 "column": 13
204 }, 204 },
205 "end": { 205 "end": {
206 "line": 89, 206 "line": 91,
207 "column": 3 207 "column": 3
208 } 208 }
209 }, 209 },
@@ -212,11 +212,11 @@
212 "defaultMessage": "!!!Port", 212 "defaultMessage": "!!!Port",
213 "file": "src/containers/settings/EditServiceScreen.js", 213 "file": "src/containers/settings/EditServiceScreen.js",
214 "start": { 214 "start": {
215 "line": 90, 215 "line": 92,
216 "column": 13 216 "column": 13
217 }, 217 },
218 "end": { 218 "end": {
219 "line": 93, 219 "line": 95,
220 "column": 3 220 "column": 3
221 } 221 }
222 }, 222 },
@@ -225,11 +225,11 @@
225 "defaultMessage": "!!!User", 225 "defaultMessage": "!!!User",
226 "file": "src/containers/settings/EditServiceScreen.js", 226 "file": "src/containers/settings/EditServiceScreen.js",
227 "start": { 227 "start": {
228 "line": 94, 228 "line": 96,
229 "column": 13 229 "column": 13
230 }, 230 },
231 "end": { 231 "end": {
232 "line": 97, 232 "line": 99,
233 "column": 3 233 "column": 3
234 } 234 }
235 }, 235 },
@@ -238,11 +238,11 @@
238 "defaultMessage": "!!!Password", 238 "defaultMessage": "!!!Password",
239 "file": "src/containers/settings/EditServiceScreen.js", 239 "file": "src/containers/settings/EditServiceScreen.js",
240 "start": { 240 "start": {
241 "line": 98, 241 "line": 100,
242 "column": 17 242 "column": 17
243 }, 243 },
244 "end": { 244 "end": {
245 "line": 101, 245 "line": 103,
246 "column": 3 246 "column": 3
247 } 247 }
248 } 248 }