From 4960927289b88bcacbf7af2baa9c551deac64072 Mon Sep 17 00:00:00 2001 From: Vijay A Date: Wed, 8 Sep 2021 23:44:24 +0530 Subject: Revert "chore: proxy feature is always turned on: remove 'enabled' flag" This reverts commit 2772cb2e3e75f16b3dc96a2441518ed0772e3ba1. --- src/containers/settings/EditServiceScreen.js | 77 +++++++++++++++------------- 1 file changed, 41 insertions(+), 36 deletions(-) (limited to 'src/containers/settings') 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'; import { required, url, oneRequired } from '../../helpers/validation-helpers'; import { getSelectOptions } from '../../helpers/i18n-helpers'; +import { config as proxyFeature } from '../../features/serviceProxy'; + import { SPELLCHECKER_LOCALES } from '../../i18n/languages'; import globalMessages from '../../i18n/globalMessages'; @@ -129,7 +131,7 @@ export default @inject('stores', 'actions') @observer class EditServiceScreen ex } } - prepareForm(recipe, service) { + prepareForm(recipe, service, proxy) { const { intl, } = this.context; @@ -273,42 +275,44 @@ export default @inject('stores', 'actions') @observer class EditServiceScreen ex }); } - const serviceProxyConfig = stores.settings.proxy[service.id] || {}; - - Object.assign(config.fields, { - proxy: { - name: 'proxy', - label: 'proxy', - fields: { - isEnabled: { - label: intl.formatMessage(messages.enableProxy), - value: serviceProxyConfig.isEnabled, - default: false, - }, - host: { - label: intl.formatMessage(messages.proxyHost), - value: serviceProxyConfig.host, - default: '', - }, - port: { - label: intl.formatMessage(messages.proxyPort), - value: serviceProxyConfig.port, - default: '', - }, - user: { - label: intl.formatMessage(messages.proxyUser), - value: serviceProxyConfig.user, - default: '', - }, - password: { - label: intl.formatMessage(messages.proxyPassword), - value: serviceProxyConfig.password, - default: '', - type: 'password', + if (proxy.isEnabled) { + const serviceProxyConfig = stores.settings.proxy[service.id] || {}; + + Object.assign(config.fields, { + proxy: { + name: 'proxy', + label: 'proxy', + fields: { + isEnabled: { + label: intl.formatMessage(messages.enableProxy), + value: serviceProxyConfig.isEnabled, + default: false, + }, + host: { + label: intl.formatMessage(messages.proxyHost), + value: serviceProxyConfig.host, + default: '', + }, + port: { + label: intl.formatMessage(messages.proxyPort), + value: serviceProxyConfig.port, + default: '', + }, + user: { + label: intl.formatMessage(messages.proxyUser), + value: serviceProxyConfig.user, + default: '', + }, + password: { + label: intl.formatMessage(messages.proxyPassword), + value: serviceProxyConfig.password, + default: '', + type: 'password', + }, }, }, - }, - }); + }); + } return new Form(config); } @@ -377,7 +381,7 @@ export default @inject('stores', 'actions') @observer class EditServiceScreen ex ); } - const form = this.prepareForm(recipe, service); + const form = this.prepareForm(recipe, service, proxyFeature); return ( @@ -393,6 +397,7 @@ export default @inject('stores', 'actions') @observer class EditServiceScreen ex onSubmit={(d) => this.onSubmit(d)} onDelete={() => this.deleteService()} openRecipeFile={(file) => this.openRecipeFile(file)} + isProxyFeatureEnabled={proxyFeature.isEnabled} /> ); -- cgit v1.2.3-54-g00ecf