aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/settings/services/EditServiceForm.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/settings/services/EditServiceForm.js')
-rw-r--r--src/components/settings/services/EditServiceForm.js124
1 files changed, 41 insertions, 83 deletions
diff --git a/src/components/settings/services/EditServiceForm.js b/src/components/settings/services/EditServiceForm.js
index 513c75eed..0f7c29de5 100644
--- a/src/components/settings/services/EditServiceForm.js
+++ b/src/components/settings/services/EditServiceForm.js
@@ -6,7 +6,6 @@ import { defineMessages, intlShape } from 'react-intl';
6import normalizeUrl from 'normalize-url'; 6import normalizeUrl from 'normalize-url';
7 7
8import Form from '../../../lib/Form'; 8import Form from '../../../lib/Form';
9import User from '../../../models/User';
10import Recipe from '../../../models/Recipe'; 9import Recipe from '../../../models/Recipe';
11import Service from '../../../models/Service'; 10import Service from '../../../models/Service';
12import Tabs, { TabItem } from '../../ui/Tabs'; 11import Tabs, { TabItem } from '../../ui/Tabs';
@@ -17,9 +16,6 @@ import Button from '../../ui/Button';
17import ImageUpload from '../../ui/ImageUpload'; 16import ImageUpload from '../../ui/ImageUpload';
18import Select from '../../ui/Select'; 17import Select from '../../ui/Select';
19 18
20import PremiumFeatureContainer from '../../ui/PremiumFeatureContainer';
21import LimitReachedInfobox from '../../../features/serviceLimit/components/LimitReachedInfobox';
22import { serviceLimitStore } from '../../../features/serviceLimit';
23import { isMac } from '../../../environment'; 19import { isMac } from '../../../environment';
24import globalMessages from '../../../i18n/globalMessages'; 20import globalMessages from '../../../i18n/globalMessages';
25 21
@@ -80,14 +76,6 @@ const messages = defineMessages({
80 id: 'settings.service.form.customUrlValidationError', 76 id: 'settings.service.form.customUrlValidationError',
81 defaultMessage: '!!!Could not validate custom {name} server.', 77 defaultMessage: '!!!Could not validate custom {name} server.',
82 }, 78 },
83 customUrlPremiumInfo: {
84 id: 'settings.service.form.customUrlPremiumInfo',
85 defaultMessage: '!!!To add self hosted services, you need a Ferdi Premium Supporter Account.',
86 },
87 customUrlUpgradeAccount: {
88 id: 'settings.service.form.customUrlUpgradeAccount',
89 defaultMessage: '!!!Upgrade your account',
90 },
91 indirectMessageInfo: { 79 indirectMessageInfo: {
92 id: 'settings.service.form.indirectMessageInfo', 80 id: 'settings.service.form.indirectMessageInfo',
93 defaultMessage: '!!!You will be notified about all new messages in a channel, not just @username, @channel, @here, ...', 81 defaultMessage: '!!!You will be notified about all new messages in a channel, not just @username, @channel, @here, ...',
@@ -149,7 +137,6 @@ export default @observer class EditServiceForm extends Component {
149 137
150 return null; 138 return null;
151 }, 139 },
152 user: PropTypes.instanceOf(User).isRequired,
153 action: PropTypes.string.isRequired, 140 action: PropTypes.string.isRequired,
154 form: PropTypes.instanceOf(Form).isRequired, 141 form: PropTypes.instanceOf(Form).isRequired,
155 onSubmit: PropTypes.func.isRequired, 142 onSubmit: PropTypes.func.isRequired,
@@ -158,8 +145,6 @@ export default @observer class EditServiceForm extends Component {
158 isSaving: PropTypes.bool.isRequired, 145 isSaving: PropTypes.bool.isRequired,
159 isDeleting: PropTypes.bool.isRequired, 146 isDeleting: PropTypes.bool.isRequired,
160 isProxyFeatureEnabled: PropTypes.bool.isRequired, 147 isProxyFeatureEnabled: PropTypes.bool.isRequired,
161 isServiceProxyIncludedInCurrentPlan: PropTypes.bool.isRequired,
162 isSpellcheckerIncludedInCurrentPlan: PropTypes.bool.isRequired,
163 isHibernationFeatureActive: PropTypes.bool.isRequired, 148 isHibernationFeatureActive: PropTypes.bool.isRequired,
164 }; 149 };
165 150
@@ -217,15 +202,12 @@ export default @observer class EditServiceForm extends Component {
217 recipe, 202 recipe,
218 service, 203 service,
219 action, 204 action,
220 user,
221 form, 205 form,
222 isSaving, 206 isSaving,
223 isDeleting, 207 isDeleting,
224 onDelete, 208 onDelete,
225 openRecipeFile, 209 openRecipeFile,
226 isProxyFeatureEnabled, 210 isProxyFeatureEnabled,
227 isServiceProxyIncludedInCurrentPlan,
228 isSpellcheckerIncludedInCurrentPlan,
229 isHibernationFeatureActive, 211 isHibernationFeatureActive,
230 } = this.props; 212 } = this.props;
231 const { intl } = this.context; 213 const { intl } = this.context;
@@ -285,7 +267,6 @@ export default @observer class EditServiceForm extends Component {
285 )} 267 )}
286 </span> 268 </span>
287 </div> 269 </div>
288 <LimitReachedInfobox />
289 <div className="settings__body"> 270 <div className="settings__body">
290 <form onSubmit={e => this.submit(e)} id="form"> 271 <form onSubmit={e => this.submit(e)} id="form">
291 <div className="service-name"> 272 <div className="service-name">
@@ -311,24 +292,11 @@ export default @observer class EditServiceForm extends Component {
311 )} 292 )}
312 {recipe.hasCustomUrl && ( 293 {recipe.hasCustomUrl && (
313 <TabItem title={intl.formatMessage(messages.tabOnPremise)}> 294 <TabItem title={intl.formatMessage(messages.tabOnPremise)}>
314 {user.isPremium || recipe.author.find(a => a.email === user.email) ? ( 295 <Input field={form.$('customUrl')} />
315 <> 296 {form.error === 'url-validation-error' && (
316 <Input field={form.$('customUrl')} /> 297 <p className="franz-form__error">
317 {form.error === 'url-validation-error' && ( 298 {intl.formatMessage(messages.customUrlValidationError, { name: recipe.name })}
318 <p className="franz-form__error"> 299 </p>
319 {intl.formatMessage(messages.customUrlValidationError, { name: recipe.name })}
320 </p>
321 )}
322 </>
323 ) : (
324 <div className="center premium-info">
325 <p>{intl.formatMessage(messages.customUrlPremiumInfo)}</p>
326 <p>
327 <Link to="/settings/user" className="button">
328 {intl.formatMessage(messages.customUrlUpgradeAccount)}
329 </Link>
330 </p>
331 </div>
332 )} 300 )}
333 </TabItem> 301 </TabItem>
334 )} 302 )}
@@ -403,56 +371,46 @@ export default @observer class EditServiceForm extends Component {
403 </div> 371 </div>
404 372
405 {!isMac && ( 373 {!isMac && (
406 <PremiumFeatureContainer 374 <div className="settings__settings-group">
407 condition={!isSpellcheckerIncludedInCurrentPlan} 375 <Select field={form.$('spellcheckerLanguage')} />
408 gaEventInfo={{ category: 'User', event: 'upgrade', label: 'spellchecker' }} 376 </div>
409 >
410 <div className="settings__settings-group">
411 <Select field={form.$('spellcheckerLanguage')} />
412 </div>
413 </PremiumFeatureContainer>
414 )} 377 )}
415 378
416 {isProxyFeatureEnabled && ( 379 {isProxyFeatureEnabled && (
417 <PremiumFeatureContainer 380 <div className="settings__settings-group">
418 condition={!isServiceProxyIncludedInCurrentPlan} 381 <h3>
419 gaEventInfo={{ category: 'User', event: 'upgrade', label: 'proxy' }} 382 {intl.formatMessage(messages.headlineProxy)}
420 > 383 <span className="badge badge--success">beta</span>
421 <div className="settings__settings-group"> 384 </h3>
422 <h3> 385 <Toggle field={form.$('proxy.isEnabled')} />
423 {intl.formatMessage(messages.headlineProxy)} 386 {form.$('proxy.isEnabled').value && (
424 <span className="badge badge--success">beta</span> 387 <>
425 </h3> 388 <div className="grid">
426 <Toggle field={form.$('proxy.isEnabled')} /> 389 <div className="grid__row">
427 {form.$('proxy.isEnabled').value && ( 390 <Input field={form.$('proxy.host')} className="proxyHost" />
428 <> 391 <Input field={form.$('proxy.port')} />
429 <div className="grid">
430 <div className="grid__row">
431 <Input field={form.$('proxy.host')} className="proxyHost" />
432 <Input field={form.$('proxy.port')} />
433 </div>
434 </div> 392 </div>
435 <div className="grid"> 393 </div>
436 <div className="grid__row"> 394 <div className="grid">
437 <Input field={form.$('proxy.user')} /> 395 <div className="grid__row">
438 <Input 396 <Input field={form.$('proxy.user')} />
439 field={form.$('proxy.password')} 397 <Input
440 showPasswordToggle 398 field={form.$('proxy.password')}
441 /> 399 showPasswordToggle
442 </div> 400 />
443 </div> 401 </div>
444 <p> 402 </div>
445 <span className="mdi mdi-information" /> 403 <p>
446 {intl.formatMessage(messages.proxyRestartInfo)} 404 <span className="mdi mdi-information" />
447 </p> 405 {intl.formatMessage(messages.proxyRestartInfo)}
448 <p> 406 </p>
449 <span className="mdi mdi-information" /> 407 <p>
450 {intl.formatMessage(messages.proxyInfo)} 408 <span className="mdi mdi-information" />
451 </p> 409 {intl.formatMessage(messages.proxyInfo)}
452 </> 410 </p>
453 )} 411 </>
454 </div> 412 )}
455 </PremiumFeatureContainer> 413 </div>
456 )} 414 )}
457 415
458 <div className="user-agent"> 416 <div className="user-agent">
@@ -512,7 +470,7 @@ export default @observer class EditServiceForm extends Component {
512 type="submit" 470 type="submit"
513 label={intl.formatMessage(messages.saveService)} 471 label={intl.formatMessage(messages.saveService)}
514 htmlForm="form" 472 htmlForm="form"
515 disabled={action !== 'edit' && ((form.isPristine && requiresUserInput) || serviceLimitStore.userHasReachedServiceLimit)} 473 disabled={action !== 'edit' && (form.isPristine && requiresUserInput)}
516 /> 474 />
517 )} 475 )}
518 </div> 476 </div>