diff options
Diffstat (limited to 'src/features/workspaces')
-rw-r--r-- | src/features/workspaces/components/WorkspaceItem.tsx (renamed from src/features/workspaces/components/WorkspaceItem.js) | 8 | ||||
-rw-r--r-- | src/features/workspaces/components/WorkspaceServiceListItem.tsx (renamed from src/features/workspaces/components/WorkspaceServiceListItem.js) | 33 | ||||
-rw-r--r-- | src/features/workspaces/containers/EditWorkspaceScreen.tsx (renamed from src/features/workspaces/containers/EditWorkspaceScreen.js) | 34 | ||||
-rw-r--r-- | src/features/workspaces/containers/WorkspacesScreen.tsx (renamed from src/features/workspaces/containers/WorkspacesScreen.js) | 20 |
4 files changed, 47 insertions, 48 deletions
diff --git a/src/features/workspaces/components/WorkspaceItem.js b/src/features/workspaces/components/WorkspaceItem.tsx index ff3f69dd9..6fb02d2f5 100644 --- a/src/features/workspaces/components/WorkspaceItem.js +++ b/src/features/workspaces/components/WorkspaceItem.tsx | |||
@@ -16,9 +16,15 @@ const styles = theme => ({ | |||
16 | columnName: {}, | 16 | columnName: {}, |
17 | }); | 17 | }); |
18 | 18 | ||
19 | type Props = { | ||
20 | classes: any; | ||
21 | workspace: any; | ||
22 | onItemClick: (workspace) => void; | ||
23 | }; | ||
24 | |||
19 | @injectSheet(styles) | 25 | @injectSheet(styles) |
20 | @observer | 26 | @observer |
21 | class WorkspaceItem extends Component { | 27 | class WorkspaceItem extends Component<Props> { |
22 | static propTypes = { | 28 | static propTypes = { |
23 | classes: PropTypes.object.isRequired, | 29 | classes: PropTypes.object.isRequired, |
24 | workspace: PropTypes.instanceOf(Workspace).isRequired, | 30 | workspace: PropTypes.instanceOf(Workspace).isRequired, |
diff --git a/src/features/workspaces/components/WorkspaceServiceListItem.js b/src/features/workspaces/components/WorkspaceServiceListItem.tsx index c06f3c61c..b6faaf4ce 100644 --- a/src/features/workspaces/components/WorkspaceServiceListItem.js +++ b/src/features/workspaces/components/WorkspaceServiceListItem.tsx | |||
@@ -1,14 +1,12 @@ | |||
1 | import { Component } from 'react'; | 1 | import { Component } from 'react'; |
2 | import PropTypes from 'prop-types'; | ||
3 | import { observer } from 'mobx-react'; | 2 | import { observer } from 'mobx-react'; |
4 | import injectSheet from 'react-jss'; | 3 | import injectSheet from 'react-jss'; |
5 | import classnames from 'classnames'; | 4 | import classnames from 'classnames'; |
6 | import { Toggle } from '@meetfranz/forms'; | 5 | import { Toggle } from '@meetfranz/forms'; |
7 | 6 | ||
8 | import Service from '../../../models/Service'; | ||
9 | import ServiceIcon from '../../../components/ui/ServiceIcon'; | 7 | import ServiceIcon from '../../../components/ui/ServiceIcon'; |
10 | 8 | ||
11 | const styles = (theme) => ({ | 9 | const styles = theme => ({ |
12 | listItem: { | 10 | listItem: { |
13 | height: theme.workspaces.settings.listItems.height, | 11 | height: theme.workspaces.settings.listItems.height, |
14 | borderBottom: `1px solid ${theme.workspaces.settings.listItems.borderColor}`, | 12 | borderBottom: `1px solid ${theme.workspaces.settings.listItems.borderColor}`, |
@@ -31,29 +29,22 @@ const styles = (theme) => ({ | |||
31 | }, | 29 | }, |
32 | }); | 30 | }); |
33 | 31 | ||
34 | @injectSheet(styles) @observer | 32 | type Props = { |
35 | class WorkspaceServiceListItem extends Component { | 33 | classes: any; |
36 | static propTypes = { | 34 | isInWorkspace: boolean; |
37 | classes: PropTypes.object.isRequired, | 35 | onToggle: () => void; |
38 | isInWorkspace: PropTypes.bool.isRequired, | 36 | service: any; |
39 | onToggle: PropTypes.func.isRequired, | 37 | }; |
40 | service: PropTypes.instanceOf(Service).isRequired, | ||
41 | }; | ||
42 | 38 | ||
39 | @injectSheet(styles) | ||
40 | @observer | ||
41 | class WorkspaceServiceListItem extends Component<Props> { | ||
43 | render() { | 42 | render() { |
44 | const { | 43 | const { classes, isInWorkspace, onToggle, service } = this.props; |
45 | classes, | ||
46 | isInWorkspace, | ||
47 | onToggle, | ||
48 | service, | ||
49 | } = this.props; | ||
50 | 44 | ||
51 | return ( | 45 | return ( |
52 | <div className={classes.listItem}> | 46 | <div className={classes.listItem}> |
53 | <ServiceIcon | 47 | <ServiceIcon className={classes.serviceIcon} service={service} /> |
54 | className={classes.serviceIcon} | ||
55 | service={service} | ||
56 | /> | ||
57 | <span | 48 | <span |
58 | className={classnames([ | 49 | className={classnames([ |
59 | classes.label, | 50 | classes.label, |
diff --git a/src/features/workspaces/containers/EditWorkspaceScreen.js b/src/features/workspaces/containers/EditWorkspaceScreen.tsx index bd9e235e3..8e8f8179d 100644 --- a/src/features/workspaces/containers/EditWorkspaceScreen.js +++ b/src/features/workspaces/containers/EditWorkspaceScreen.tsx | |||
@@ -1,26 +1,26 @@ | |||
1 | import { Component } from 'react'; | 1 | import { Component } from 'react'; |
2 | import { inject, observer } from 'mobx-react'; | 2 | import { inject, observer } from 'mobx-react'; |
3 | import PropTypes from 'prop-types'; | ||
4 | 3 | ||
5 | import ErrorBoundary from '../../../components/util/ErrorBoundary'; | 4 | import ErrorBoundary from '../../../components/util/ErrorBoundary'; |
6 | import EditWorkspaceForm from '../components/EditWorkspaceForm'; | 5 | import EditWorkspaceForm from '../components/EditWorkspaceForm'; |
7 | import ServicesStore from '../../../stores/ServicesStore'; | ||
8 | import Workspace from '../models/Workspace'; | 6 | import Workspace from '../models/Workspace'; |
9 | import { workspaceStore } from '../index'; | 7 | import { workspaceStore } from '../index'; |
10 | import { deleteWorkspaceRequest, updateWorkspaceRequest } from '../api'; | 8 | import { deleteWorkspaceRequest, updateWorkspaceRequest } from '../api'; |
11 | import WorkspacesStore from '../store'; | 9 | import { ServicesStore, WorkspacesStore } from '../../../stores.types'; |
12 | 10 | ||
13 | @inject('stores', 'actions') @observer | 11 | type Props = { |
14 | class EditWorkspaceScreen extends Component { | 12 | actions: { |
15 | static propTypes = { | 13 | workspaces: WorkspacesStore; |
16 | actions: PropTypes.shape({ | ||
17 | workspaces: PropTypes.instanceOf(WorkspacesStore), | ||
18 | }).isRequired, | ||
19 | stores: PropTypes.shape({ | ||
20 | services: PropTypes.instanceOf(ServicesStore).isRequired, | ||
21 | }).isRequired, | ||
22 | }; | 14 | }; |
15 | stores: { | ||
16 | services: ServicesStore; | ||
17 | }; | ||
18 | }; | ||
23 | 19 | ||
20 | @inject('stores', 'actions') | ||
21 | @observer | ||
22 | class EditWorkspaceScreen extends Component<Props> { | ||
23 | // @ts-expect-error Not all code paths return a value. | ||
24 | onDelete = () => { | 24 | onDelete = () => { |
25 | const { workspaceBeingEdited } = workspaceStore; | 25 | const { workspaceBeingEdited } = workspaceStore; |
26 | const { actions } = this.props; | 26 | const { actions } = this.props; |
@@ -28,12 +28,14 @@ class EditWorkspaceScreen extends Component { | |||
28 | actions.workspaces.delete({ workspace: workspaceBeingEdited }); | 28 | actions.workspaces.delete({ workspace: workspaceBeingEdited }); |
29 | }; | 29 | }; |
30 | 30 | ||
31 | onSave = (values) => { | 31 | onSave = values => { |
32 | const { workspaceBeingEdited } = workspaceStore; | 32 | const { workspaceBeingEdited } = workspaceStore; |
33 | const { actions } = this.props; | 33 | const { actions } = this.props; |
34 | const workspace = new Workspace( | 34 | const workspace = new Workspace({ |
35 | ({ saving: true, ...workspaceBeingEdited, ...values }), | 35 | saving: true, |
36 | ); | 36 | ...workspaceBeingEdited, |
37 | ...values, | ||
38 | }); | ||
37 | actions.workspaces.update({ workspace }); | 39 | actions.workspaces.update({ workspace }); |
38 | }; | 40 | }; |
39 | 41 | ||
diff --git a/src/features/workspaces/containers/WorkspacesScreen.js b/src/features/workspaces/containers/WorkspacesScreen.tsx index 2ba3784cb..a07e92439 100644 --- a/src/features/workspaces/containers/WorkspacesScreen.js +++ b/src/features/workspaces/containers/WorkspacesScreen.tsx | |||
@@ -1,6 +1,5 @@ | |||
1 | import { Component } from 'react'; | 1 | import { Component } from 'react'; |
2 | import { inject, observer } from 'mobx-react'; | 2 | import { inject, observer } from 'mobx-react'; |
3 | import PropTypes from 'prop-types'; | ||
4 | import WorkspacesDashboard from '../components/WorkspacesDashboard'; | 3 | import WorkspacesDashboard from '../components/WorkspacesDashboard'; |
5 | import ErrorBoundary from '../../../components/util/ErrorBoundary'; | 4 | import ErrorBoundary from '../../../components/util/ErrorBoundary'; |
6 | import { workspaceStore } from '../index'; | 5 | import { workspaceStore } from '../index'; |
@@ -10,16 +9,17 @@ import { | |||
10 | getUserWorkspacesRequest, | 9 | getUserWorkspacesRequest, |
11 | updateWorkspaceRequest, | 10 | updateWorkspaceRequest, |
12 | } from '../api'; | 11 | } from '../api'; |
13 | import WorkspacesStore from '../store'; | 12 | import { WorkspacesStore } from '../../../stores.types'; |
14 | 13 | ||
15 | @inject('stores', 'actions') @observer | 14 | type Props = { |
16 | class WorkspacesScreen extends Component { | 15 | actions: { |
17 | static propTypes = { | 16 | workspaces: WorkspacesStore; |
18 | actions: PropTypes.shape({ | ||
19 | workspaces: PropTypes.instanceOf(WorkspacesStore), | ||
20 | }).isRequired, | ||
21 | }; | 17 | }; |
18 | }; | ||
22 | 19 | ||
20 | @inject('stores', 'actions') | ||
21 | @observer | ||
22 | class WorkspacesScreen extends Component<Props> { | ||
23 | render() { | 23 | render() { |
24 | const { actions } = this.props; | 24 | const { actions } = this.props; |
25 | return ( | 25 | return ( |
@@ -30,8 +30,8 @@ class WorkspacesScreen extends Component { | |||
30 | createWorkspaceRequest={createWorkspaceRequest} | 30 | createWorkspaceRequest={createWorkspaceRequest} |
31 | deleteWorkspaceRequest={deleteWorkspaceRequest} | 31 | deleteWorkspaceRequest={deleteWorkspaceRequest} |
32 | updateWorkspaceRequest={updateWorkspaceRequest} | 32 | updateWorkspaceRequest={updateWorkspaceRequest} |
33 | onCreateWorkspaceSubmit={(data) => actions.workspaces.create(data)} | 33 | onCreateWorkspaceSubmit={data => actions.workspaces.create(data)} |
34 | onWorkspaceClick={(w) => actions.workspaces.edit({ workspace: w })} | 34 | onWorkspaceClick={w => actions.workspaces.edit({ workspace: w })} |
35 | /> | 35 | /> |
36 | </ErrorBoundary> | 36 | </ErrorBoundary> |
37 | ); | 37 | ); |