aboutsummaryrefslogtreecommitdiffstats
path: root/src/containers/settings/EditServiceScreen.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/containers/settings/EditServiceScreen.tsx')
-rw-r--r--src/containers/settings/EditServiceScreen.tsx30
1 files changed, 13 insertions, 17 deletions
diff --git a/src/containers/settings/EditServiceScreen.tsx b/src/containers/settings/EditServiceScreen.tsx
index f8532a7b4..ba8f374c3 100644
--- a/src/containers/settings/EditServiceScreen.tsx
+++ b/src/containers/settings/EditServiceScreen.tsx
@@ -2,7 +2,7 @@ import { Component, ReactElement } from 'react';
2import { inject, observer } from 'mobx-react'; 2import { inject, observer } from 'mobx-react';
3import { defineMessages, injectIntl } from 'react-intl'; 3import { defineMessages, injectIntl } from 'react-intl';
4 4
5import { RouterStore } from 'mobx-react-router'; 5import { Params } from 'react-router-dom';
6import { StoresProps } from '../../@types/ferdium-components.types'; 6import { StoresProps } from '../../@types/ferdium-components.types';
7import { IRecipe } from '../../models/Recipe'; 7import { IRecipe } from '../../models/Recipe';
8import Service from '../../models/Service'; 8import Service from '../../models/Service';
@@ -22,6 +22,7 @@ import { SPELLCHECKER_LOCALES } from '../../i18n/languages';
22 22
23import globalMessages from '../../i18n/globalMessages'; 23import globalMessages from '../../i18n/globalMessages';
24import { DEFAULT_APP_SETTINGS, DEFAULT_SERVICE_SETTINGS } from '../../config'; 24import { DEFAULT_APP_SETTINGS, DEFAULT_SERVICE_SETTINGS } from '../../config';
25import withParams from '../../components/util/WithParams';
25 26
26const messages = defineMessages({ 27const messages = defineMessages({
27 name: { 28 name: {
@@ -119,14 +120,13 @@ const messages = defineMessages({
119}); 120});
120 121
121interface EditServicesScreenProps extends StoresProps { 122interface EditServicesScreenProps extends StoresProps {
122 router: RouterStore;
123 intl: any; 123 intl: any;
124 params: Params;
124} 125}
125 126
126class EditServiceScreen extends Component<EditServicesScreenProps> { 127class EditServiceScreen extends Component<EditServicesScreenProps> {
127 onSubmit(data: any) { 128 onSubmit(data: any) {
128 // @ts-ignore TODO: This is actually there and we don't have a correct type right now. 129 const { action } = this.props.params;
129 const { action } = this.props.router.params;
130 const { recipes, services } = this.props.stores; 130 const { recipes, services } = this.props.stores;
131 const { createService, updateService } = this.props.actions.service; 131 const { createService, updateService } = this.props.actions.service;
132 data.darkReaderSettings = { 132 data.darkReaderSettings = {
@@ -151,10 +151,9 @@ class EditServiceScreen extends Component<EditServicesScreenProps> {
151 prepareForm(recipe: IRecipe, service: Service | null, proxy: any): Form { 151 prepareForm(recipe: IRecipe, service: Service | null, proxy: any): Form {
152 const { intl } = this.props; 152 const { intl } = this.props;
153 153
154 const { stores, router } = this.props; 154 const { stores } = this.props;
155 155
156 // @ts-ignore TODO: This is actually there and we don't have a correct type right now. 156 const { action } = stores.router.pathValue;
157 const { action } = router.params;
158 157
159 let defaultSpellcheckerLanguage = 158 let defaultSpellcheckerLanguage =
160 SPELLCHECKER_LOCALES[stores.settings.app.spellcheckerLanguage]; 159 SPELLCHECKER_LOCALES[stores.settings.app.spellcheckerLanguage];
@@ -389,8 +388,7 @@ class EditServiceScreen extends Component<EditServicesScreenProps> {
389 388
390 deleteService(): void { 389 deleteService(): void {
391 const { deleteService } = this.props.actions.service; 390 const { deleteService } = this.props.actions.service;
392 // @ts-ignore TODO: This is actually there and we don't have a correct type right now. 391 const { action } = this.props.params;
393 const { action } = this.props.router.params;
394 392
395 if (action === 'edit') { 393 if (action === 'edit') {
396 const { activeSettings: service } = this.props.stores.services; 394 const { activeSettings: service } = this.props.stores.services;
@@ -403,8 +401,7 @@ class EditServiceScreen extends Component<EditServicesScreenProps> {
403 401
404 openRecipeFile(file: any): void { 402 openRecipeFile(file: any): void {
405 const { openRecipeFile } = this.props.actions.service; 403 const { openRecipeFile } = this.props.actions.service;
406 // @ts-ignore TODO: This is actually there and we don't have a correct type right now. 404 const { action } = this.props.params;
407 const { action } = this.props.router.params;
408 405
409 if (action === 'edit') { 406 if (action === 'edit') {
410 const { activeSettings: service } = this.props.stores.services; 407 const { activeSettings: service } = this.props.stores.services;
@@ -417,9 +414,7 @@ class EditServiceScreen extends Component<EditServicesScreenProps> {
417 414
418 render(): ReactElement { 415 render(): ReactElement {
419 const { recipes, services, user } = this.props.stores; 416 const { recipes, services, user } = this.props.stores;
420 417 const { action } = this.props.params;
421 // @ts-ignore TODO: This is actually there and we don't have a correct type right now.
422 const { action } = this.props.router.params;
423 418
424 let recipe: null | IRecipe = null; 419 let recipe: null | IRecipe = null;
425 let service: null | Service = null; 420 let service: null | Service = null;
@@ -427,7 +422,6 @@ class EditServiceScreen extends Component<EditServicesScreenProps> {
427 422
428 if (action === 'add') { 423 if (action === 'add') {
429 recipe = recipes.active; 424 recipe = recipes.active;
430
431 // TODO: render error message when recipe is `null` 425 // TODO: render error message when recipe is `null`
432 if (!recipe) { 426 if (!recipe) {
433 return <ServiceError />; 427 return <ServiceError />;
@@ -475,6 +469,8 @@ class EditServiceScreen extends Component<EditServicesScreenProps> {
475 } 469 }
476} 470}
477 471
478export default injectIntl<'intl', EditServicesScreenProps>( 472export default withParams(
479 inject('stores', 'actions')(observer(EditServiceScreen)), 473 injectIntl<'intl', EditServicesScreenProps>(
474 inject('stores', 'actions')(observer(EditServiceScreen)),
475 ),
480); 476);