diff options
author | 2021-08-13 00:45:01 +0530 | |
---|---|---|
committer | 2021-08-13 00:45:01 +0530 | |
commit | 2d27d5e66649d4f5baf127a53ee5ae524eae3a59 (patch) | |
tree | c592ea219ac8cd987fc367f57b54034c450ab2ab /src/components/settings/services/EditServiceForm.js | |
parent | Ferdi v5.6.0 (diff) | |
parent | 5.6.1-nightly.24 [skip ci] (diff) | |
download | ferdium-app-2d27d5e66649d4f5baf127a53ee5ae524eae3a59.tar.gz ferdium-app-2d27d5e66649d4f5baf127a53ee5ae524eae3a59.tar.zst ferdium-app-2d27d5e66649d4f5baf127a53ee5ae524eae3a59.zip |
chore: merge from nightly branch into release branch in prep for next beta
Diffstat (limited to 'src/components/settings/services/EditServiceForm.js')
-rw-r--r-- | src/components/settings/services/EditServiceForm.js | 142 |
1 files changed, 47 insertions, 95 deletions
diff --git a/src/components/settings/services/EditServiceForm.js b/src/components/settings/services/EditServiceForm.js index 513c75eed..c41cdd56a 100644 --- a/src/components/settings/services/EditServiceForm.js +++ b/src/components/settings/services/EditServiceForm.js | |||
@@ -1,4 +1,4 @@ | |||
1 | import React, { Component, Fragment } from 'react'; | 1 | import React, { Component } from 'react'; |
2 | import PropTypes from 'prop-types'; | 2 | import PropTypes from 'prop-types'; |
3 | import { observer } from 'mobx-react'; | 3 | import { observer } from 'mobx-react'; |
4 | import { Link } from 'react-router'; | 4 | import { Link } from 'react-router'; |
@@ -6,7 +6,6 @@ import { defineMessages, intlShape } from 'react-intl'; | |||
6 | import normalizeUrl from 'normalize-url'; | 6 | import normalizeUrl from 'normalize-url'; |
7 | 7 | ||
8 | import Form from '../../../lib/Form'; | 8 | import Form from '../../../lib/Form'; |
9 | import User from '../../../models/User'; | ||
10 | import Recipe from '../../../models/Recipe'; | 9 | import Recipe from '../../../models/Recipe'; |
11 | import Service from '../../../models/Service'; | 10 | import Service from '../../../models/Service'; |
12 | import Tabs, { TabItem } from '../../ui/Tabs'; | 11 | import Tabs, { TabItem } from '../../ui/Tabs'; |
@@ -17,9 +16,6 @@ import Button from '../../ui/Button'; | |||
17 | import ImageUpload from '../../ui/ImageUpload'; | 16 | import ImageUpload from '../../ui/ImageUpload'; |
18 | import Select from '../../ui/Select'; | 17 | import Select from '../../ui/Select'; |
19 | 18 | ||
20 | import PremiumFeatureContainer from '../../ui/PremiumFeatureContainer'; | ||
21 | import LimitReachedInfobox from '../../../features/serviceLimit/components/LimitReachedInfobox'; | ||
22 | import { serviceLimitStore } from '../../../features/serviceLimit'; | ||
23 | import { isMac } from '../../../environment'; | 19 | import { isMac } from '../../../environment'; |
24 | import globalMessages from '../../../i18n/globalMessages'; | 20 | import 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,9 +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, | ||
164 | }; | 148 | }; |
165 | 149 | ||
166 | static defaultProps = { | 150 | static defaultProps = { |
@@ -217,16 +201,12 @@ export default @observer class EditServiceForm extends Component { | |||
217 | recipe, | 201 | recipe, |
218 | service, | 202 | service, |
219 | action, | 203 | action, |
220 | user, | ||
221 | form, | 204 | form, |
222 | isSaving, | 205 | isSaving, |
223 | isDeleting, | 206 | isDeleting, |
224 | onDelete, | 207 | onDelete, |
225 | openRecipeFile, | 208 | openRecipeFile, |
226 | isProxyFeatureEnabled, | 209 | isProxyFeatureEnabled, |
227 | isServiceProxyIncludedInCurrentPlan, | ||
228 | isSpellcheckerIncludedInCurrentPlan, | ||
229 | isHibernationFeatureActive, | ||
230 | } = this.props; | 210 | } = this.props; |
231 | const { intl } = this.context; | 211 | const { intl } = this.context; |
232 | 212 | ||
@@ -285,9 +265,8 @@ export default @observer class EditServiceForm extends Component { | |||
285 | )} | 265 | )} |
286 | </span> | 266 | </span> |
287 | </div> | 267 | </div> |
288 | <LimitReachedInfobox /> | ||
289 | <div className="settings__body"> | 268 | <div className="settings__body"> |
290 | <form onSubmit={e => this.submit(e)} id="form"> | 269 | <form onSubmit={(e) => this.submit(e)} id="form"> |
291 | <div className="service-name"> | 270 | <div className="service-name"> |
292 | <Input field={form.$('name')} focus /> | 271 | <Input field={form.$('name')} focus /> |
293 | </div> | 272 | </div> |
@@ -311,24 +290,11 @@ export default @observer class EditServiceForm extends Component { | |||
311 | )} | 290 | )} |
312 | {recipe.hasCustomUrl && ( | 291 | {recipe.hasCustomUrl && ( |
313 | <TabItem title={intl.formatMessage(messages.tabOnPremise)}> | 292 | <TabItem title={intl.formatMessage(messages.tabOnPremise)}> |
314 | {user.isPremium || recipe.author.find(a => a.email === user.email) ? ( | 293 | <Input field={form.$('customUrl')} /> |
315 | <> | 294 | {form.error === 'url-validation-error' && ( |
316 | <Input field={form.$('customUrl')} /> | 295 | <p className="franz-form__error"> |
317 | {form.error === 'url-validation-error' && ( | 296 | {intl.formatMessage(messages.customUrlValidationError, { name: recipe.name })} |
318 | <p className="franz-form__error"> | 297 | </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 | )} | 298 | )} |
333 | </TabItem> | 299 | </TabItem> |
334 | )} | 300 | )} |
@@ -373,14 +339,10 @@ export default @observer class EditServiceForm extends Component { | |||
373 | <div className="settings__settings-group"> | 339 | <div className="settings__settings-group"> |
374 | <h3>{intl.formatMessage(messages.headlineGeneral)}</h3> | 340 | <h3>{intl.formatMessage(messages.headlineGeneral)}</h3> |
375 | <Toggle field={form.$('isEnabled')} /> | 341 | <Toggle field={form.$('isEnabled')} /> |
376 | {isHibernationFeatureActive && ( | 342 | <Toggle field={form.$('isHibernationEnabled')} /> |
377 | <> | 343 | <p className="settings__help indented__help"> |
378 | <Toggle field={form.$('isHibernationEnabled')} /> | 344 | {intl.formatMessage(messages.isHibernationEnabledInfo)} |
379 | <p className="settings__help indented__help"> | 345 | </p> |
380 | {intl.formatMessage(messages.isHibernationEnabledInfo)} | ||
381 | </p> | ||
382 | </> | ||
383 | )} | ||
384 | <Toggle field={form.$('isDarkModeEnabled')} /> | 346 | <Toggle field={form.$('isDarkModeEnabled')} /> |
385 | {form.$('isDarkModeEnabled').value | 347 | {form.$('isDarkModeEnabled').value |
386 | && ( | 348 | && ( |
@@ -403,56 +365,46 @@ export default @observer class EditServiceForm extends Component { | |||
403 | </div> | 365 | </div> |
404 | 366 | ||
405 | {!isMac && ( | 367 | {!isMac && ( |
406 | <PremiumFeatureContainer | 368 | <div className="settings__settings-group"> |
407 | condition={!isSpellcheckerIncludedInCurrentPlan} | 369 | <Select field={form.$('spellcheckerLanguage')} /> |
408 | gaEventInfo={{ category: 'User', event: 'upgrade', label: 'spellchecker' }} | 370 | </div> |
409 | > | ||
410 | <div className="settings__settings-group"> | ||
411 | <Select field={form.$('spellcheckerLanguage')} /> | ||
412 | </div> | ||
413 | </PremiumFeatureContainer> | ||
414 | )} | 371 | )} |
415 | 372 | ||
416 | {isProxyFeatureEnabled && ( | 373 | {isProxyFeatureEnabled && ( |
417 | <PremiumFeatureContainer | 374 | <div className="settings__settings-group"> |
418 | condition={!isServiceProxyIncludedInCurrentPlan} | 375 | <h3> |
419 | gaEventInfo={{ category: 'User', event: 'upgrade', label: 'proxy' }} | 376 | {intl.formatMessage(messages.headlineProxy)} |
420 | > | 377 | <span className="badge badge--success">beta</span> |
421 | <div className="settings__settings-group"> | 378 | </h3> |
422 | <h3> | 379 | <Toggle field={form.$('proxy.isEnabled')} /> |
423 | {intl.formatMessage(messages.headlineProxy)} | 380 | {form.$('proxy.isEnabled').value && ( |
424 | <span className="badge badge--success">beta</span> | 381 | <> |
425 | </h3> | 382 | <div className="grid"> |
426 | <Toggle field={form.$('proxy.isEnabled')} /> | 383 | <div className="grid__row"> |
427 | {form.$('proxy.isEnabled').value && ( | 384 | <Input field={form.$('proxy.host')} className="proxyHost" /> |
428 | <> | 385 | <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> | 386 | </div> |
435 | <div className="grid"> | 387 | </div> |
436 | <div className="grid__row"> | 388 | <div className="grid"> |
437 | <Input field={form.$('proxy.user')} /> | 389 | <div className="grid__row"> |
438 | <Input | 390 | <Input field={form.$('proxy.user')} /> |
439 | field={form.$('proxy.password')} | 391 | <Input |
440 | showPasswordToggle | 392 | field={form.$('proxy.password')} |
441 | /> | 393 | showPasswordToggle |
442 | </div> | 394 | /> |
443 | </div> | 395 | </div> |
444 | <p> | 396 | </div> |
445 | <span className="mdi mdi-information" /> | 397 | <p> |
446 | {intl.formatMessage(messages.proxyRestartInfo)} | 398 | <span className="mdi mdi-information" /> |
447 | </p> | 399 | {intl.formatMessage(messages.proxyRestartInfo)} |
448 | <p> | 400 | </p> |
449 | <span className="mdi mdi-information" /> | 401 | <p> |
450 | {intl.formatMessage(messages.proxyInfo)} | 402 | <span className="mdi mdi-information" /> |
451 | </p> | 403 | {intl.formatMessage(messages.proxyInfo)} |
452 | </> | 404 | </p> |
453 | )} | 405 | </> |
454 | </div> | 406 | )} |
455 | </PremiumFeatureContainer> | 407 | </div> |
456 | )} | 408 | )} |
457 | 409 | ||
458 | <div className="user-agent"> | 410 | <div className="user-agent"> |
@@ -512,7 +464,7 @@ export default @observer class EditServiceForm extends Component { | |||
512 | type="submit" | 464 | type="submit" |
513 | label={intl.formatMessage(messages.saveService)} | 465 | label={intl.formatMessage(messages.saveService)} |
514 | htmlForm="form" | 466 | htmlForm="form" |
515 | disabled={action !== 'edit' && ((form.isPristine && requiresUserInput) || serviceLimitStore.userHasReachedServiceLimit)} | 467 | disabled={action !== 'edit' && (form.isPristine && requiresUserInput)} |
516 | /> | 468 | /> |
517 | )} | 469 | )} |
518 | </div> | 470 | </div> |