diff options
author | Ricardo Cino <ricardo@cino.io> | 2022-07-07 09:31:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-07 09:31:50 +0200 |
commit | 71c52373f81cace664047edd19d9d289f45a4dff (patch) | |
tree | 69b3f1d45a8b3f1ceab9497ea3c96e9dc18e3166 /src/features/workspaces | |
parent | 6.0.0-nightly.91 [skip ci] (diff) | |
download | ferdium-app-71c52373f81cace664047edd19d9d289f45a4dff.tar.gz ferdium-app-71c52373f81cace664047edd19d9d289f45a4dff.tar.zst ferdium-app-71c52373f81cace664047edd19d9d289f45a4dff.zip |
chore: Mobx & React-Router upgrade (#406)
Co-authored-by: Vijay A <vraravam@users.noreply.github.com>
Diffstat (limited to 'src/features/workspaces')
-rw-r--r-- | src/features/workspaces/components/EditWorkspaceForm.js | 2 | ||||
-rw-r--r-- | src/features/workspaces/components/WorkspaceDrawer.jsx (renamed from src/features/workspaces/components/WorkspaceDrawer.js) | 4 | ||||
-rw-r--r-- | src/features/workspaces/containers/EditWorkspaceScreen.tsx | 13 | ||||
-rw-r--r-- | src/features/workspaces/containers/WorkspacesScreen.tsx | 10 | ||||
-rw-r--r-- | src/features/workspaces/models/Workspace.ts | 4 | ||||
-rw-r--r-- | src/features/workspaces/store.js | 8 |
6 files changed, 16 insertions, 25 deletions
diff --git a/src/features/workspaces/components/EditWorkspaceForm.js b/src/features/workspaces/components/EditWorkspaceForm.js index 3c7c36a3d..7e8541c44 100644 --- a/src/features/workspaces/components/EditWorkspaceForm.js +++ b/src/features/workspaces/components/EditWorkspaceForm.js | |||
@@ -2,7 +2,7 @@ import { 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 { defineMessages, injectIntl } from 'react-intl'; | 4 | import { defineMessages, injectIntl } from 'react-intl'; |
5 | import { Link } from 'react-router'; | 5 | import { Link } from 'react-router-dom'; |
6 | import injectSheet from 'react-jss'; | 6 | import injectSheet from 'react-jss'; |
7 | 7 | ||
8 | import Infobox from '../../../components/ui/infobox/index'; | 8 | import Infobox from '../../../components/ui/infobox/index'; |
diff --git a/src/features/workspaces/components/WorkspaceDrawer.js b/src/features/workspaces/components/WorkspaceDrawer.jsx index 3454fdbe9..b0b0e639a 100644 --- a/src/features/workspaces/components/WorkspaceDrawer.js +++ b/src/features/workspaces/components/WorkspaceDrawer.jsx | |||
@@ -12,9 +12,7 @@ import Icon from '../../../components/ui/icon'; | |||
12 | import WorkspaceDrawerItem from './WorkspaceDrawerItem'; | 12 | import WorkspaceDrawerItem from './WorkspaceDrawerItem'; |
13 | import workspaceActions from '../actions'; | 13 | import workspaceActions from '../actions'; |
14 | import { workspaceStore } from '../index'; | 14 | import { workspaceStore } from '../index'; |
15 | import { | 15 | import { getUserWorkspacesRequest } from '../api'; |
16 | getUserWorkspacesRequest, | ||
17 | } from '../api'; | ||
18 | 16 | ||
19 | const messages = defineMessages({ | 17 | const messages = defineMessages({ |
20 | headline: { | 18 | headline: { |
diff --git a/src/features/workspaces/containers/EditWorkspaceScreen.tsx b/src/features/workspaces/containers/EditWorkspaceScreen.tsx index f0c7e4574..0b66db0d0 100644 --- a/src/features/workspaces/containers/EditWorkspaceScreen.tsx +++ b/src/features/workspaces/containers/EditWorkspaceScreen.tsx | |||
@@ -1,23 +1,14 @@ | |||
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 | 3 | ||
4 | import { StoresProps } from '../../../@types/ferdium-components.types'; | ||
4 | import ErrorBoundary from '../../../components/util/ErrorBoundary'; | 5 | import ErrorBoundary from '../../../components/util/ErrorBoundary'; |
5 | import EditWorkspaceForm from '../components/EditWorkspaceForm'; | 6 | import EditWorkspaceForm from '../components/EditWorkspaceForm'; |
6 | import Workspace from '../models/Workspace'; | 7 | import Workspace from '../models/Workspace'; |
7 | import { workspaceStore } from '../index'; | 8 | import { workspaceStore } from '../index'; |
8 | import { deleteWorkspaceRequest, updateWorkspaceRequest } from '../api'; | 9 | import { deleteWorkspaceRequest, updateWorkspaceRequest } from '../api'; |
9 | import { ServicesStore, WorkspacesStore } from '../../../@types/stores.types'; | ||
10 | 10 | ||
11 | type Props = { | 11 | class EditWorkspaceScreen extends Component<StoresProps> { |
12 | actions: { | ||
13 | workspaces: WorkspacesStore; | ||
14 | }; | ||
15 | stores: { | ||
16 | services: ServicesStore; | ||
17 | }; | ||
18 | }; | ||
19 | |||
20 | class EditWorkspaceScreen extends Component<Props> { | ||
21 | // @ts-expect-error Not all code paths return a value. | 12 | // @ts-expect-error Not all code paths return a value. |
22 | onDelete = () => { | 13 | onDelete = () => { |
23 | const { workspaceBeingEdited } = workspaceStore; | 14 | const { workspaceBeingEdited } = workspaceStore; |
diff --git a/src/features/workspaces/containers/WorkspacesScreen.tsx b/src/features/workspaces/containers/WorkspacesScreen.tsx index 5b153fb50..d43dc5efa 100644 --- a/src/features/workspaces/containers/WorkspacesScreen.tsx +++ b/src/features/workspaces/containers/WorkspacesScreen.tsx | |||
@@ -1,5 +1,6 @@ | |||
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 { StoresProps } from '../../../@types/ferdium-components.types'; | ||
3 | import WorkspacesDashboard from '../components/WorkspacesDashboard'; | 4 | import WorkspacesDashboard from '../components/WorkspacesDashboard'; |
4 | import ErrorBoundary from '../../../components/util/ErrorBoundary'; | 5 | import ErrorBoundary from '../../../components/util/ErrorBoundary'; |
5 | import { workspaceStore } from '../index'; | 6 | import { workspaceStore } from '../index'; |
@@ -9,15 +10,8 @@ import { | |||
9 | getUserWorkspacesRequest, | 10 | getUserWorkspacesRequest, |
10 | updateWorkspaceRequest, | 11 | updateWorkspaceRequest, |
11 | } from '../api'; | 12 | } from '../api'; |
12 | import { WorkspacesStore } from '../../../@types/stores.types'; | ||
13 | 13 | ||
14 | type Props = { | 14 | class WorkspacesScreen extends Component<StoresProps> { |
15 | actions: { | ||
16 | workspaces: WorkspacesStore; | ||
17 | }; | ||
18 | }; | ||
19 | |||
20 | class WorkspacesScreen extends Component<Props> { | ||
21 | render() { | 15 | render() { |
22 | const { actions } = this.props; | 16 | const { actions } = this.props; |
23 | return ( | 17 | return ( |
diff --git a/src/features/workspaces/models/Workspace.ts b/src/features/workspaces/models/Workspace.ts index bc636011d..98086289f 100644 --- a/src/features/workspaces/models/Workspace.ts +++ b/src/features/workspaces/models/Workspace.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { observable } from 'mobx'; | 1 | import { makeObservable, observable } from 'mobx'; |
2 | 2 | ||
3 | import { KEEP_WS_LOADED_USID } from '../../../config'; | 3 | import { KEEP_WS_LOADED_USID } from '../../../config'; |
4 | 4 | ||
@@ -18,6 +18,8 @@ export default class Workspace { | |||
18 | throw new Error('Workspace requires Id'); | 18 | throw new Error('Workspace requires Id'); |
19 | } | 19 | } |
20 | 20 | ||
21 | makeObservable(this); | ||
22 | |||
21 | this.id = data.id; | 23 | this.id = data.id; |
22 | this.name = data.name; | 24 | this.name = data.name; |
23 | this.order = data.order; | 25 | this.order = data.order; |
diff --git a/src/features/workspaces/store.js b/src/features/workspaces/store.js index 9b4c4e928..e8c5d0590 100644 --- a/src/features/workspaces/store.js +++ b/src/features/workspaces/store.js | |||
@@ -1,4 +1,4 @@ | |||
1 | import { computed, observable, action } from 'mobx'; | 1 | import { computed, observable, action, makeObservable } from 'mobx'; |
2 | import localStorage from 'mobx-localstorage'; | 2 | import localStorage from 'mobx-localstorage'; |
3 | import matchRoute from '../../helpers/routing-helpers'; | 3 | import matchRoute from '../../helpers/routing-helpers'; |
4 | import workspaceActions from './actions'; | 4 | import workspaceActions from './actions'; |
@@ -32,6 +32,12 @@ export default class WorkspacesStore extends FeatureStore { | |||
32 | 32 | ||
33 | @observable isSettingsRouteActive = null; | 33 | @observable isSettingsRouteActive = null; |
34 | 34 | ||
35 | constructor() { | ||
36 | super(); | ||
37 | |||
38 | makeObservable(this); | ||
39 | } | ||
40 | |||
35 | @computed get workspaces() { | 41 | @computed get workspaces() { |
36 | if (!this.isFeatureActive) return []; | 42 | if (!this.isFeatureActive) return []; |
37 | return getUserWorkspacesRequest.result || []; | 43 | return getUserWorkspacesRequest.result || []; |