aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/workspaces
diff options
context:
space:
mode:
authorLibravatar Ricardo Cino <ricardo@cino.io>2022-07-07 09:31:50 +0200
committerLibravatar GitHub <noreply@github.com>2022-07-07 09:31:50 +0200
commit71c52373f81cace664047edd19d9d289f45a4dff (patch)
tree69b3f1d45a8b3f1ceab9497ea3c96e9dc18e3166 /src/features/workspaces
parent6.0.0-nightly.91 [skip ci] (diff)
downloadferdium-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.js2
-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.tsx13
-rw-r--r--src/features/workspaces/containers/WorkspacesScreen.tsx10
-rw-r--r--src/features/workspaces/models/Workspace.ts4
-rw-r--r--src/features/workspaces/store.js8
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';
2import PropTypes from 'prop-types'; 2import PropTypes from 'prop-types';
3import { observer } from 'mobx-react'; 3import { observer } from 'mobx-react';
4import { defineMessages, injectIntl } from 'react-intl'; 4import { defineMessages, injectIntl } from 'react-intl';
5import { Link } from 'react-router'; 5import { Link } from 'react-router-dom';
6import injectSheet from 'react-jss'; 6import injectSheet from 'react-jss';
7 7
8import Infobox from '../../../components/ui/infobox/index'; 8import 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';
12import WorkspaceDrawerItem from './WorkspaceDrawerItem'; 12import WorkspaceDrawerItem from './WorkspaceDrawerItem';
13import workspaceActions from '../actions'; 13import workspaceActions from '../actions';
14import { workspaceStore } from '../index'; 14import { workspaceStore } from '../index';
15import { 15import { getUserWorkspacesRequest } from '../api';
16 getUserWorkspacesRequest,
17} from '../api';
18 16
19const messages = defineMessages({ 17const 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 @@
1import { Component } from 'react'; 1import { Component } from 'react';
2import { inject, observer } from 'mobx-react'; 2import { inject, observer } from 'mobx-react';
3 3
4import { StoresProps } from '../../../@types/ferdium-components.types';
4import ErrorBoundary from '../../../components/util/ErrorBoundary'; 5import ErrorBoundary from '../../../components/util/ErrorBoundary';
5import EditWorkspaceForm from '../components/EditWorkspaceForm'; 6import EditWorkspaceForm from '../components/EditWorkspaceForm';
6import Workspace from '../models/Workspace'; 7import Workspace from '../models/Workspace';
7import { workspaceStore } from '../index'; 8import { workspaceStore } from '../index';
8import { deleteWorkspaceRequest, updateWorkspaceRequest } from '../api'; 9import { deleteWorkspaceRequest, updateWorkspaceRequest } from '../api';
9import { ServicesStore, WorkspacesStore } from '../../../@types/stores.types';
10 10
11type Props = { 11class EditWorkspaceScreen extends Component<StoresProps> {
12 actions: {
13 workspaces: WorkspacesStore;
14 };
15 stores: {
16 services: ServicesStore;
17 };
18};
19
20class 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 @@
1import { Component } from 'react'; 1import { Component } from 'react';
2import { inject, observer } from 'mobx-react'; 2import { inject, observer } from 'mobx-react';
3import { StoresProps } from '../../../@types/ferdium-components.types';
3import WorkspacesDashboard from '../components/WorkspacesDashboard'; 4import WorkspacesDashboard from '../components/WorkspacesDashboard';
4import ErrorBoundary from '../../../components/util/ErrorBoundary'; 5import ErrorBoundary from '../../../components/util/ErrorBoundary';
5import { workspaceStore } from '../index'; 6import { workspaceStore } from '../index';
@@ -9,15 +10,8 @@ import {
9 getUserWorkspacesRequest, 10 getUserWorkspacesRequest,
10 updateWorkspaceRequest, 11 updateWorkspaceRequest,
11} from '../api'; 12} from '../api';
12import { WorkspacesStore } from '../../../@types/stores.types';
13 13
14type Props = { 14class WorkspacesScreen extends Component<StoresProps> {
15 actions: {
16 workspaces: WorkspacesStore;
17 };
18};
19
20class 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 @@
1import { observable } from 'mobx'; 1import { makeObservable, observable } from 'mobx';
2 2
3import { KEEP_WS_LOADED_USID } from '../../../config'; 3import { 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 @@
1import { computed, observable, action } from 'mobx'; 1import { computed, observable, action, makeObservable } from 'mobx';
2import localStorage from 'mobx-localstorage'; 2import localStorage from 'mobx-localstorage';
3import matchRoute from '../../helpers/routing-helpers'; 3import matchRoute from '../../helpers/routing-helpers';
4import workspaceActions from './actions'; 4import 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 || [];