diff options
author | 2018-11-27 18:06:14 +0100 | |
---|---|---|
committer | 2018-11-27 18:06:14 +0100 | |
commit | 62972747866740dae84fc7b519fcedd731572329 (patch) | |
tree | 3a74610caa47350ff6b3cc07482f8472f18c1764 /src/containers | |
parent | Fix listening key (diff) | |
download | ferdium-app-62972747866740dae84fc7b519fcedd731572329.tar.gz ferdium-app-62972747866740dae84fc7b519fcedd731572329.tar.zst ferdium-app-62972747866740dae84fc7b519fcedd731572329.zip |
feat(App): Add proxy support for services
Diffstat (limited to 'src/containers')
-rw-r--r-- | src/containers/settings/EditServiceScreen.js | 71 | ||||
-rw-r--r-- | src/containers/settings/EditSettingsScreen.js | 1 | ||||
-rw-r--r-- | src/containers/subscription/SubscriptionFormScreen.js | 1 |
3 files changed, 62 insertions, 11 deletions
diff --git a/src/containers/settings/EditServiceScreen.js b/src/containers/settings/EditServiceScreen.js index 17d727642..639e8b070 100644 --- a/src/containers/settings/EditServiceScreen.js +++ b/src/containers/settings/EditServiceScreen.js | |||
@@ -6,8 +6,8 @@ import { defineMessages, intlShape } from 'react-intl'; | |||
6 | import UserStore from '../../stores/UserStore'; | 6 | import UserStore from '../../stores/UserStore'; |
7 | import RecipesStore from '../../stores/RecipesStore'; | 7 | import RecipesStore from '../../stores/RecipesStore'; |
8 | import ServicesStore from '../../stores/ServicesStore'; | 8 | import ServicesStore from '../../stores/ServicesStore'; |
9 | import FeaturesStore from '../../stores/FeaturesStore'; | ||
10 | import SettingsStore from '../../stores/SettingsStore'; | 9 | import SettingsStore from '../../stores/SettingsStore'; |
10 | import FeaturesStore from '../../stores/FeaturesStore'; | ||
11 | import Form from '../../lib/Form'; | 11 | import Form from '../../lib/Form'; |
12 | import { gaPage } from '../../lib/analytics'; | 12 | import { gaPage } from '../../lib/analytics'; |
13 | 13 | ||
@@ -15,6 +15,8 @@ import ServiceError from '../../components/settings/services/ServiceError'; | |||
15 | import EditServiceForm from '../../components/settings/services/EditServiceForm'; | 15 | import EditServiceForm from '../../components/settings/services/EditServiceForm'; |
16 | import { required, url, oneRequired } from '../../helpers/validation-helpers'; | 16 | import { required, url, oneRequired } from '../../helpers/validation-helpers'; |
17 | 17 | ||
18 | import { config as proxyFeature } from '../../features/serviceProxy'; | ||
19 | |||
18 | const messages = defineMessages({ | 20 | const messages = defineMessages({ |
19 | name: { | 21 | name: { |
20 | id: 'settings.service.form.name', | 22 | id: 'settings.service.form.name', |
@@ -56,6 +58,22 @@ const messages = defineMessages({ | |||
56 | id: 'settings.service.form.enableDarkMode', | 58 | id: 'settings.service.form.enableDarkMode', |
57 | defaultMessage: '!!!Enable Dark Mode', | 59 | defaultMessage: '!!!Enable Dark Mode', |
58 | }, | 60 | }, |
61 | enableProxy: { | ||
62 | id: 'settings.service.form.proxy.isEnabled', | ||
63 | defaultMessage: '!!!Use Proxy', | ||
64 | }, | ||
65 | proxyHost: { | ||
66 | id: 'settings.service.form.proxy.host', | ||
67 | defaultMessage: '!!!Proxy Host/IP', | ||
68 | }, | ||
69 | proxyUser: { | ||
70 | id: 'settings.service.form.proxy.user', | ||
71 | defaultMessage: '!!!User', | ||
72 | }, | ||
73 | proxyPassword: { | ||
74 | id: 'settings.service.form.proxy.password', | ||
75 | defaultMessage: '!!!Password', | ||
76 | }, | ||
59 | }); | 77 | }); |
60 | 78 | ||
61 | export default @inject('stores', 'actions') @observer class EditServiceScreen extends Component { | 79 | export default @inject('stores', 'actions') @observer class EditServiceScreen extends Component { |
@@ -82,7 +100,7 @@ export default @inject('stores', 'actions') @observer class EditServiceScreen ex | |||
82 | } | 100 | } |
83 | } | 101 | } |
84 | 102 | ||
85 | prepareForm(recipe, service, userCanManageServices) { | 103 | prepareForm(recipe, service, proxy) { |
86 | const { intl } = this.context; | 104 | const { intl } = this.context; |
87 | const config = { | 105 | const config = { |
88 | fields: { | 106 | fields: { |
@@ -128,7 +146,6 @@ export default @inject('stores', 'actions') @observer class EditServiceScreen ex | |||
128 | if (recipe.hasTeamId) { | 146 | if (recipe.hasTeamId) { |
129 | Object.assign(config.fields, { | 147 | Object.assign(config.fields, { |
130 | team: { | 148 | team: { |
131 | disabled: !userCanManageServices, | ||
132 | label: intl.formatMessage(messages.team), | 149 | label: intl.formatMessage(messages.team), |
133 | placeholder: intl.formatMessage(messages.team), | 150 | placeholder: intl.formatMessage(messages.team), |
134 | value: service.team, | 151 | value: service.team, |
@@ -140,7 +157,6 @@ export default @inject('stores', 'actions') @observer class EditServiceScreen ex | |||
140 | if (recipe.hasCustomUrl) { | 157 | if (recipe.hasCustomUrl) { |
141 | Object.assign(config.fields, { | 158 | Object.assign(config.fields, { |
142 | customUrl: { | 159 | customUrl: { |
143 | disabled: !userCanManageServices, | ||
144 | label: intl.formatMessage(messages.customUrl), | 160 | label: intl.formatMessage(messages.customUrl), |
145 | placeholder: 'https://', | 161 | placeholder: 'https://', |
146 | value: service.customUrl, | 162 | value: service.customUrl, |
@@ -175,6 +191,40 @@ export default @inject('stores', 'actions') @observer class EditServiceScreen ex | |||
175 | }); | 191 | }); |
176 | } | 192 | } |
177 | 193 | ||
194 | if (proxy.isEnabled) { | ||
195 | const serviceProxyConfig = this.props.stores.settings.proxy[service.id] || {}; | ||
196 | |||
197 | Object.assign(config.fields, { | ||
198 | proxy: { | ||
199 | name: 'proxy', | ||
200 | label: 'proxy', | ||
201 | fields: { | ||
202 | isEnabled: { | ||
203 | label: intl.formatMessage(messages.enableProxy), | ||
204 | value: serviceProxyConfig.isEnabled, | ||
205 | default: false, | ||
206 | }, | ||
207 | host: { | ||
208 | label: intl.formatMessage(messages.proxyHost), | ||
209 | value: serviceProxyConfig.host, | ||
210 | default: '', | ||
211 | }, | ||
212 | user: { | ||
213 | label: intl.formatMessage(messages.proxyUser), | ||
214 | value: serviceProxyConfig.user, | ||
215 | default: '', | ||
216 | }, | ||
217 | password: { | ||
218 | label: intl.formatMessage(messages.proxyPassword), | ||
219 | value: serviceProxyConfig.password, | ||
220 | default: '', | ||
221 | type: 'password', | ||
222 | }, | ||
223 | }, | ||
224 | }, | ||
225 | }); | ||
226 | } | ||
227 | |||
178 | return new Form(config); | 228 | return new Form(config); |
179 | } | 229 | } |
180 | 230 | ||
@@ -192,7 +242,7 @@ export default @inject('stores', 'actions') @observer class EditServiceScreen ex | |||
192 | } | 242 | } |
193 | 243 | ||
194 | render() { | 244 | render() { |
195 | const { recipes, services, user, features } = this.props.stores; | 245 | const { recipes, services, user } = this.props.stores; |
196 | const { action } = this.props.router.params; | 246 | const { action } = this.props.router.params; |
197 | 247 | ||
198 | let recipe; | 248 | let recipe; |
@@ -227,8 +277,7 @@ export default @inject('stores', 'actions') @observer class EditServiceScreen ex | |||
227 | ); | 277 | ); |
228 | } | 278 | } |
229 | 279 | ||
230 | const userCanManageServices = features.features.userCanManageServices; | 280 | const form = this.prepareForm(recipe, service, proxyFeature); |
231 | const form = this.prepareForm(recipe, service, userCanManageServices); | ||
232 | 281 | ||
233 | return ( | 282 | return ( |
234 | <EditServiceForm | 283 | <EditServiceForm |
@@ -236,13 +285,14 @@ export default @inject('stores', 'actions') @observer class EditServiceScreen ex | |||
236 | recipe={recipe} | 285 | recipe={recipe} |
237 | service={service} | 286 | service={service} |
238 | user={user.data} | 287 | user={user.data} |
239 | userCanManageServices={userCanManageServices} | ||
240 | form={form} | 288 | form={form} |
241 | status={services.actionStatus} | 289 | status={services.actionStatus} |
242 | isSaving={services.updateServiceRequest.isExecuting || services.createServiceRequest.isExecuting} | 290 | isSaving={services.updateServiceRequest.isExecuting || services.createServiceRequest.isExecuting} |
243 | isDeleting={services.deleteServiceRequest.isExecuting} | 291 | isDeleting={services.deleteServiceRequest.isExecuting} |
244 | onSubmit={d => this.onSubmit(d)} | 292 | onSubmit={d => this.onSubmit(d)} |
245 | onDelete={() => this.deleteService()} | 293 | onDelete={() => this.deleteService()} |
294 | isProxyFeatureEnabled={proxyFeature.isEnabled} | ||
295 | isProxyFeaturePremiumFeature={proxyFeature.isPremium} | ||
246 | /> | 296 | /> |
247 | ); | 297 | ); |
248 | } | 298 | } |
@@ -253,8 +303,8 @@ EditServiceScreen.wrappedComponent.propTypes = { | |||
253 | user: PropTypes.instanceOf(UserStore).isRequired, | 303 | user: PropTypes.instanceOf(UserStore).isRequired, |
254 | recipes: PropTypes.instanceOf(RecipesStore).isRequired, | 304 | recipes: PropTypes.instanceOf(RecipesStore).isRequired, |
255 | services: PropTypes.instanceOf(ServicesStore).isRequired, | 305 | services: PropTypes.instanceOf(ServicesStore).isRequired, |
256 | features: PropTypes.instanceOf(FeaturesStore).isRequired, | ||
257 | settings: PropTypes.instanceOf(SettingsStore).isRequired, | 306 | settings: PropTypes.instanceOf(SettingsStore).isRequired, |
307 | features: PropTypes.instanceOf(FeaturesStore).isRequired, | ||
258 | }).isRequired, | 308 | }).isRequired, |
259 | router: PropTypes.shape({ | 309 | router: PropTypes.shape({ |
260 | params: PropTypes.shape({ | 310 | params: PropTypes.shape({ |
@@ -267,5 +317,8 @@ EditServiceScreen.wrappedComponent.propTypes = { | |||
267 | updateService: PropTypes.func.isRequired, | 317 | updateService: PropTypes.func.isRequired, |
268 | deleteService: PropTypes.func.isRequired, | 318 | deleteService: PropTypes.func.isRequired, |
269 | }).isRequired, | 319 | }).isRequired, |
320 | // settings: PropTypes.shape({ | ||
321 | // update: PropTypes.func.isRequred, | ||
322 | // }).isRequired, | ||
270 | }).isRequired, | 323 | }).isRequired, |
271 | }; | 324 | }; |
diff --git a/src/containers/settings/EditSettingsScreen.js b/src/containers/settings/EditSettingsScreen.js index 2fb6bed5f..7da009c8b 100644 --- a/src/containers/settings/EditSettingsScreen.js +++ b/src/containers/settings/EditSettingsScreen.js | |||
@@ -219,7 +219,6 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e | |||
219 | cacheSize={cacheSize} | 219 | cacheSize={cacheSize} |
220 | isClearingAllCache={isClearingAllCache} | 220 | isClearingAllCache={isClearingAllCache} |
221 | onClearAllCache={clearAllCache} | 221 | onClearAllCache={clearAllCache} |
222 | isPremiumUser={this.props.stores.user.data.isPremium} | ||
223 | isSpellcheckerPremiumFeature={spellcheckerConfig.isPremiumFeature} | 222 | isSpellcheckerPremiumFeature={spellcheckerConfig.isPremiumFeature} |
224 | /> | 223 | /> |
225 | ); | 224 | ); |
diff --git a/src/containers/subscription/SubscriptionFormScreen.js b/src/containers/subscription/SubscriptionFormScreen.js index 9f7571bda..50ed19bef 100644 --- a/src/containers/subscription/SubscriptionFormScreen.js +++ b/src/containers/subscription/SubscriptionFormScreen.js | |||
@@ -79,7 +79,6 @@ export default @inject('stores', 'actions') @observer class SubscriptionFormScre | |||
79 | return ( | 79 | return ( |
80 | <SubscriptionForm | 80 | <SubscriptionForm |
81 | plan={stores.payment.plan} | 81 | plan={stores.payment.plan} |
82 | // form={this.prepareForm(stores.payment.plan)} | ||
83 | isLoading={stores.payment.plansRequest.isExecuting} | 82 | isLoading={stores.payment.plansRequest.isExecuting} |
84 | retryPlanRequest={() => stores.payment.plansRequest.reload()} | 83 | retryPlanRequest={() => stores.payment.plansRequest.reload()} |
85 | isCreatingHostedPage={stores.payment.createHostedPageRequest.isExecuting} | 84 | isCreatingHostedPage={stores.payment.createHostedPageRequest.isExecuting} |