diff options
author | 2022-11-07 01:11:48 +0530 | |
---|---|---|
committer | 2022-11-08 17:25:27 +0530 | |
commit | a1f5e31bfce97b4bbe492e24bf7d57ec2803c31a (patch) | |
tree | 881417b8917e8212fcf94547b92bba2701592745 /src/features | |
parent | 6.2.1-nightly.42 [skip ci] (diff) | |
download | ferdium-app-a1f5e31bfce97b4bbe492e24bf7d57ec2803c31a.tar.gz ferdium-app-a1f5e31bfce97b4bbe492e24bf7d57ec2803c31a.tar.zst ferdium-app-a1f5e31bfce97b4bbe492e24bf7d57ec2803c31a.zip |
refactor: remove toggle component's duplicate
Diffstat (limited to 'src/features')
-rw-r--r-- | src/features/workspaces/components/EditWorkspaceForm.js | 7 | ||||
-rw-r--r-- | src/features/workspaces/components/WorkspaceServiceListItem.tsx | 26 |
2 files changed, 15 insertions, 18 deletions
diff --git a/src/features/workspaces/components/EditWorkspaceForm.js b/src/features/workspaces/components/EditWorkspaceForm.js index 6bc9ae6f0..ff4e71260 100644 --- a/src/features/workspaces/components/EditWorkspaceForm.js +++ b/src/features/workspaces/components/EditWorkspaceForm.js | |||
@@ -4,7 +4,6 @@ import { observer } from 'mobx-react'; | |||
4 | import { defineMessages, injectIntl } from 'react-intl'; | 4 | import { defineMessages, injectIntl } from 'react-intl'; |
5 | import { Link } from 'react-router-dom'; | 5 | import { Link } from 'react-router-dom'; |
6 | import injectSheet from 'react-jss'; | 6 | import injectSheet from 'react-jss'; |
7 | |||
8 | import Infobox from '../../../components/ui/infobox/index'; | 7 | import Infobox from '../../../components/ui/infobox/index'; |
9 | import Input from '../../../components/ui/input/index'; | 8 | import Input from '../../../components/ui/input/index'; |
10 | import Button from '../../../components/ui/button'; | 9 | import Button from '../../../components/ui/button'; |
@@ -14,10 +13,8 @@ import Form from '../../../lib/Form'; | |||
14 | import { required } from '../../../helpers/validation-helpers'; | 13 | import { required } from '../../../helpers/validation-helpers'; |
15 | import WorkspaceServiceListItem from './WorkspaceServiceListItem'; | 14 | import WorkspaceServiceListItem from './WorkspaceServiceListItem'; |
16 | import Request from '../../../stores/lib/Request'; | 15 | import Request from '../../../stores/lib/Request'; |
17 | |||
18 | import { KEEP_WS_LOADED_USID } from '../../../config'; | 16 | import { KEEP_WS_LOADED_USID } from '../../../config'; |
19 | 17 | import Toggle from '../../../components/ui/toggle'; | |
20 | import Toggle from '../../../components/ui/Toggle'; | ||
21 | import { H2 } from '../../../components/ui/headline'; | 18 | import { H2 } from '../../../components/ui/headline'; |
22 | 19 | ||
23 | const messages = defineMessages({ | 20 | const messages = defineMessages({ |
@@ -176,7 +173,7 @@ class EditWorkspaceForm extends Component { | |||
176 | )} | 173 | )} |
177 | <div className={classes.nameInput}> | 174 | <div className={classes.nameInput}> |
178 | <Input {...form.$('name').bind()} /> | 175 | <Input {...form.$('name').bind()} /> |
179 | <Toggle field={form.$('keepLoaded')} /> | 176 | <Toggle {...form.$('keepLoaded').bind()} /> |
180 | <p className={`${classes.keepLoadedInfo} franz-form__label`}> | 177 | <p className={`${classes.keepLoadedInfo} franz-form__label`}> |
181 | {intl.formatMessage(messages.keepLoadedInfo)} | 178 | {intl.formatMessage(messages.keepLoadedInfo)} |
182 | </p> | 179 | </p> |
diff --git a/src/features/workspaces/components/WorkspaceServiceListItem.tsx b/src/features/workspaces/components/WorkspaceServiceListItem.tsx index 0233d5749..420aed595 100644 --- a/src/features/workspaces/components/WorkspaceServiceListItem.tsx +++ b/src/features/workspaces/components/WorkspaceServiceListItem.tsx | |||
@@ -1,10 +1,10 @@ | |||
1 | import { Component } from 'react'; | 1 | import { Component, ReactElement } from 'react'; |
2 | import { observer } from 'mobx-react'; | 2 | import { observer } from 'mobx-react'; |
3 | import injectSheet from 'react-jss'; | 3 | import withStyles, { WithStylesProps } from 'react-jss'; |
4 | import classnames from 'classnames'; | 4 | import classnames from 'classnames'; |
5 | 5 | import Toggle from '../../../components/ui/toggle'; | |
6 | import Toggle from '../../../components/ui/toggle/index'; | ||
7 | import ServiceIcon from '../../../components/ui/ServiceIcon'; | 6 | import ServiceIcon from '../../../components/ui/ServiceIcon'; |
7 | import Service from '../../../models/Service'; | ||
8 | 8 | ||
9 | const styles = theme => ({ | 9 | const styles = theme => ({ |
10 | listItem: { | 10 | listItem: { |
@@ -29,15 +29,15 @@ const styles = theme => ({ | |||
29 | }, | 29 | }, |
30 | }); | 30 | }); |
31 | 31 | ||
32 | type Props = { | 32 | interface IProps extends WithStylesProps<typeof styles> { |
33 | classes: any; | ||
34 | isInWorkspace: boolean; | 33 | isInWorkspace: boolean; |
35 | onToggle: () => void; | 34 | onToggle: () => void; |
36 | service: any; | 35 | service: Service; |
37 | }; | 36 | } |
38 | 37 | ||
39 | class WorkspaceServiceListItem extends Component<Props> { | 38 | @observer |
40 | render() { | 39 | class WorkspaceServiceListItem extends Component<IProps> { |
40 | render(): ReactElement { | ||
41 | const { classes, isInWorkspace, onToggle, service } = this.props; | 41 | const { classes, isInWorkspace, onToggle, service } = this.props; |
42 | 42 | ||
43 | return ( | 43 | return ( |
@@ -53,7 +53,7 @@ class WorkspaceServiceListItem extends Component<Props> { | |||
53 | </span> | 53 | </span> |
54 | <Toggle | 54 | <Toggle |
55 | className={classes.toggle} | 55 | className={classes.toggle} |
56 | checked={isInWorkspace} | 56 | value={isInWorkspace} |
57 | onChange={onToggle} | 57 | onChange={onToggle} |
58 | /> | 58 | /> |
59 | </div> | 59 | </div> |
@@ -61,6 +61,6 @@ class WorkspaceServiceListItem extends Component<Props> { | |||
61 | } | 61 | } |
62 | } | 62 | } |
63 | 63 | ||
64 | export default injectSheet(styles, { injectTheme: true })( | 64 | export default withStyles(styles, { injectTheme: true })( |
65 | observer(WorkspaceServiceListItem), | 65 | WorkspaceServiceListItem, |
66 | ); | 66 | ); |