aboutsummaryrefslogtreecommitdiffstats
path: root/src/containers/settings/EditServiceScreen.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/containers/settings/EditServiceScreen.js')
-rw-r--r--src/containers/settings/EditServiceScreen.js77
1 files changed, 73 insertions, 4 deletions
diff --git a/src/containers/settings/EditServiceScreen.js b/src/containers/settings/EditServiceScreen.js
index 67c2731fc..639e8b070 100644
--- a/src/containers/settings/EditServiceScreen.js
+++ b/src/containers/settings/EditServiceScreen.js
@@ -6,6 +6,8 @@ import { defineMessages, intlShape } from 'react-intl';
6import UserStore from '../../stores/UserStore'; 6import UserStore from '../../stores/UserStore';
7import RecipesStore from '../../stores/RecipesStore'; 7import RecipesStore from '../../stores/RecipesStore';
8import ServicesStore from '../../stores/ServicesStore'; 8import ServicesStore from '../../stores/ServicesStore';
9import SettingsStore from '../../stores/SettingsStore';
10import FeaturesStore from '../../stores/FeaturesStore';
9import Form from '../../lib/Form'; 11import Form from '../../lib/Form';
10import { gaPage } from '../../lib/analytics'; 12import { gaPage } from '../../lib/analytics';
11 13
@@ -13,6 +15,8 @@ import ServiceError from '../../components/settings/services/ServiceError';
13import EditServiceForm from '../../components/settings/services/EditServiceForm'; 15import EditServiceForm from '../../components/settings/services/EditServiceForm';
14import { required, url, oneRequired } from '../../helpers/validation-helpers'; 16import { required, url, oneRequired } from '../../helpers/validation-helpers';
15 17
18import { config as proxyFeature } from '../../features/serviceProxy';
19
16const messages = defineMessages({ 20const messages = defineMessages({
17 name: { 21 name: {
18 id: 'settings.service.form.name', 22 id: 'settings.service.form.name',
@@ -50,10 +54,29 @@ const messages = defineMessages({
50 id: 'settings.service.form.icon', 54 id: 'settings.service.form.icon',
51 defaultMessage: '!!!Custom icon', 55 defaultMessage: '!!!Custom icon',
52 }, 56 },
57 enableDarkMode: {
58 id: 'settings.service.form.enableDarkMode',
59 defaultMessage: '!!!Enable Dark Mode',
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 },
53}); 77});
54 78
55@inject('stores', 'actions') @observer 79export default @inject('stores', 'actions') @observer class EditServiceScreen extends Component {
56export default class EditServiceScreen extends Component {
57 static contextTypes = { 80 static contextTypes = {
58 intl: intlShape, 81 intl: intlShape,
59 }; 82 };
@@ -77,7 +100,7 @@ export default class EditServiceScreen extends Component {
77 } 100 }
78 } 101 }
79 102
80 prepareForm(recipe, service) { 103 prepareForm(recipe, service, proxy) {
81 const { intl } = this.context; 104 const { intl } = this.context;
82 const config = { 105 const config = {
83 fields: { 106 fields: {
@@ -112,6 +135,11 @@ export default class EditServiceScreen extends Component {
112 default: null, 135 default: null,
113 type: 'file', 136 type: 'file',
114 }, 137 },
138 isDarkModeEnabled: {
139 label: intl.formatMessage(messages.enableDarkMode),
140 value: service.isDarkModeEnabled,
141 default: this.props.stores.settings.all.app.darkMode,
142 },
115 }, 143 },
116 }; 144 };
117 145
@@ -163,6 +191,40 @@ export default class EditServiceScreen extends Component {
163 }); 191 });
164 } 192 }
165 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
166 return new Form(config); 228 return new Form(config);
167 } 229 }
168 230
@@ -215,7 +277,7 @@ export default class EditServiceScreen extends Component {
215 ); 277 );
216 } 278 }
217 279
218 const form = this.prepareForm(recipe, service); 280 const form = this.prepareForm(recipe, service, proxyFeature);
219 281
220 return ( 282 return (
221 <EditServiceForm 283 <EditServiceForm
@@ -229,6 +291,8 @@ export default class EditServiceScreen extends Component {
229 isDeleting={services.deleteServiceRequest.isExecuting} 291 isDeleting={services.deleteServiceRequest.isExecuting}
230 onSubmit={d => this.onSubmit(d)} 292 onSubmit={d => this.onSubmit(d)}
231 onDelete={() => this.deleteService()} 293 onDelete={() => this.deleteService()}
294 isProxyFeatureEnabled={proxyFeature.isEnabled}
295 isProxyFeaturePremiumFeature={proxyFeature.isPremium}
232 /> 296 />
233 ); 297 );
234 } 298 }
@@ -239,6 +303,8 @@ EditServiceScreen.wrappedComponent.propTypes = {
239 user: PropTypes.instanceOf(UserStore).isRequired, 303 user: PropTypes.instanceOf(UserStore).isRequired,
240 recipes: PropTypes.instanceOf(RecipesStore).isRequired, 304 recipes: PropTypes.instanceOf(RecipesStore).isRequired,
241 services: PropTypes.instanceOf(ServicesStore).isRequired, 305 services: PropTypes.instanceOf(ServicesStore).isRequired,
306 settings: PropTypes.instanceOf(SettingsStore).isRequired,
307 features: PropTypes.instanceOf(FeaturesStore).isRequired,
242 }).isRequired, 308 }).isRequired,
243 router: PropTypes.shape({ 309 router: PropTypes.shape({
244 params: PropTypes.shape({ 310 params: PropTypes.shape({
@@ -251,5 +317,8 @@ EditServiceScreen.wrappedComponent.propTypes = {
251 updateService: PropTypes.func.isRequired, 317 updateService: PropTypes.func.isRequired,
252 deleteService: PropTypes.func.isRequired, 318 deleteService: PropTypes.func.isRequired,
253 }).isRequired, 319 }).isRequired,
320 // settings: PropTypes.shape({
321 // update: PropTypes.func.isRequred,
322 // }).isRequired,
254 }).isRequired, 323 }).isRequired,
255}; 324};