aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar Ricardo Cino <ricardo@cino.io>2022-06-26 23:59:32 +0200
committerLibravatar GitHub <noreply@github.com>2022-06-26 21:59:32 +0000
commit6bff2bb5439d25e0ab2a24a8ca1b28b89ef40ff9 (patch)
tree1676f5eef42b8086d28476c7eaad62c7b1753120 /src
parentReduce tab item layout shift (#376) (diff)
downloadferdium-app-6bff2bb5439d25e0ab2a24a8ca1b28b89ef40ff9.tar.gz
ferdium-app-6bff2bb5439d25e0ab2a24a8ca1b28b89ef40ff9.tar.zst
ferdium-app-6bff2bb5439d25e0ab2a24a8ca1b28b89ef40ff9.zip
chore: turned all auth containers into typescript (#375)
Diffstat (limited to 'src')
-rw-r--r--src/@types/ferdium-components.types.ts13
-rw-r--r--src/@types/ferdium.types.ts (renamed from src/types.ts)2
-rw-r--r--src/@types/stores.types.ts (renamed from src/stores.types.ts)19
-rw-r--r--src/I18n.tsx4
-rw-r--r--src/components/ui/Loader.tsx2
-rw-r--r--src/containers/auth/AuthLayoutContainer.tsx (renamed from src/containers/auth/AuthLayoutContainer.js)45
-rw-r--r--src/containers/auth/ChangeServerScreen.tsx (renamed from src/containers/auth/ChangeServerScreen.js)24
-rw-r--r--src/containers/auth/ImportScreen.tsx19
-rw-r--r--src/containers/auth/InviteScreen.js22
-rw-r--r--src/containers/auth/InviteScreen.tsx14
-rw-r--r--src/containers/auth/LockedScreen.tsx19
-rw-r--r--src/containers/auth/LoginScreen.tsx (renamed from src/containers/auth/LoginScreen.js)26
-rw-r--r--src/containers/auth/PasswordScreen.tsx17
-rw-r--r--src/containers/auth/SetupAssistantScreen.tsx27
-rw-r--r--src/containers/auth/SignupScreen.js46
-rw-r--r--src/containers/auth/SignupScreen.tsx32
-rw-r--r--src/containers/auth/WelcomeScreen.tsx16
-rw-r--r--src/features/workspaces/containers/EditWorkspaceScreen.tsx2
-rw-r--r--src/features/workspaces/containers/WorkspacesScreen.tsx2
-rw-r--r--src/helpers/async-helpers.ts2
-rw-r--r--src/stores/AppStore.ts2
-rw-r--r--src/stores/GlobalErrorStore.ts2
-rw-r--r--src/stores/RecipePreviewsStore.ts2
-rw-r--r--src/stores/RecipesStore.ts2
-rw-r--r--src/stores/RequestStore.ts2
-rw-r--r--src/stores/ServicesStore.ts2
-rw-r--r--src/stores/SettingsStore.ts2
-rw-r--r--src/stores/UIStore.ts2
-rw-r--r--src/stores/UserStore.ts2
-rw-r--r--src/stores/index.ts22
-rw-r--r--src/stores/lib/TypedStore.ts2
31 files changed, 151 insertions, 244 deletions
diff --git a/src/@types/ferdium-components.types.ts b/src/@types/ferdium-components.types.ts
new file mode 100644
index 000000000..df5e2f6ed
--- /dev/null
+++ b/src/@types/ferdium-components.types.ts
@@ -0,0 +1,13 @@
1import { Actions } from 'src/actions/lib/actions';
2import { RealStores } from 'src/stores';
3
4export interface DefaultProps {
5 actions: Actions;
6 stores: RealStores;
7}
8
9export interface GlobalError {
10 status: number;
11 message: string;
12 code: string;
13}
diff --git a/src/types.ts b/src/@types/ferdium.types.ts
index db8711cd3..0747f8e14 100644
--- a/src/types.ts
+++ b/src/@types/ferdium.types.ts
@@ -19,4 +19,4 @@ declare global {
19 * Workaround to make TS recognize this file as a module. 19 * Workaround to make TS recognize this file as a module.
20 * https://fettblog.eu/typescript-augmenting-global-lib-dom/ 20 * https://fettblog.eu/typescript-augmenting-global-lib-dom/
21 */ 21 */
22export {}; 22export { };
diff --git a/src/stores.types.ts b/src/@types/stores.types.ts
index 1899db92c..37b906239 100644
--- a/src/stores.types.ts
+++ b/src/@types/stores.types.ts
@@ -1,10 +1,13 @@
1import Workspace from './features/workspaces/models/Workspace'; 1import Workspace from '../features/workspaces/models/Workspace';
2import Recipe from './models/Recipe'; 2import Recipe from '../models/Recipe';
3import Service from './models/Service'; 3import Service from '../models/Service';
4import User from './models/User'; 4import User from '../models/User';
5import { Request } from './stores/lib/Request'; 5import { Request } from '../stores/lib/Request';
6import { CachedRequest } from './stores/lib/CachedRequest'; 6import { CachedRequest } from '../stores/lib/CachedRequest';
7import Reaction from './stores/lib/Reaction'; 7import Reaction from '../stores/lib/Reaction';
8
9// TODO: This file will be removed in the future when all stores are
10// correctly typed and the use of these interfaces are obsolete.
8 11
9export interface FerdiumStores { 12export interface FerdiumStores {
10 app: AppStore; 13 app: AppStore;
@@ -307,7 +310,7 @@ export interface UserStore extends TypedStore {
307 logoutReason: () => void; 310 logoutReason: () => void;
308 logoutReasonTypes: { SERVER: 'SERVER' }; 311 logoutReasonTypes: { SERVER: 'SERVER' };
309 passwordRequest: Request; 312 passwordRequest: Request;
310 retrievePassword: Promise<void> 313 retrievePassword: Promise<void>;
311 signupRequest: () => void; 314 signupRequest: () => void;
312 updateUserInfoRequest: () => void; 315 updateUserInfoRequest: () => void;
313 userData: () => void; 316 userData: () => void;
diff --git a/src/I18n.tsx b/src/I18n.tsx
index 1be6ab23d..b486758c3 100644
--- a/src/I18n.tsx
+++ b/src/I18n.tsx
@@ -8,13 +8,13 @@ import AppStore from './stores/AppStore';
8 8
9const translations = generatedTranslations(); 9const translations = generatedTranslations();
10 10
11type Props = { 11interface Props {
12 stores: { 12 stores: {
13 app: AppStore; 13 app: AppStore;
14 user: UserStore; 14 user: UserStore;
15 }; 15 };
16 children: ReactNode; 16 children: ReactNode;
17}; 17}
18 18
19class I18N extends Component<Props> { 19class I18N extends Component<Props> {
20 componentDidUpdate(): void { 20 componentDidUpdate(): void {
diff --git a/src/components/ui/Loader.tsx b/src/components/ui/Loader.tsx
index d4ed0d6bb..67c9db22e 100644
--- a/src/components/ui/Loader.tsx
+++ b/src/components/ui/Loader.tsx
@@ -2,7 +2,7 @@ import { Component, ReactChildren } from 'react';
2import { observer, inject } from 'mobx-react'; 2import { observer, inject } from 'mobx-react';
3import Loader from 'react-loader'; 3import Loader from 'react-loader';
4 4
5import { FerdiumStores } from '../../stores.types'; 5import { FerdiumStores } from '../../@types/stores.types';
6 6
7type Props = { 7type Props = {
8 children: ReactChildren; 8 children: ReactChildren;
diff --git a/src/containers/auth/AuthLayoutContainer.js b/src/containers/auth/AuthLayoutContainer.tsx
index e6d6dcf8a..8d65ec6f4 100644
--- a/src/containers/auth/AuthLayoutContainer.js
+++ b/src/containers/auth/AuthLayoutContainer.tsx
@@ -1,28 +1,19 @@
1import { Component } from 'react'; 1import { Component, ReactElement, ReactNode } from 'react';
2import PropTypes from 'prop-types';
3import { inject, observer } from 'mobx-react'; 2import { inject, observer } from 'mobx-react';
4import { ThemeProvider } from 'react-jss'; 3import { ThemeProvider } from 'react-jss';
5 4
5import { DefaultProps } from 'src/@types/ferdium-components.types';
6import { Location } from 'mobx-react-router';
6import AuthLayout from '../../components/auth/AuthLayout'; 7import AuthLayout from '../../components/auth/AuthLayout';
7import AppStore from '../../stores/AppStore';
8import UserStore from '../../stores/UserStore';
9import GlobalErrorStore from '../../stores/GlobalErrorStore';
10import UIStore from '../../stores/UIStore';
11import SettingsStore from '../../stores/SettingsStore';
12import AppLoader from '../../components/ui/AppLoader'; 8import AppLoader from '../../components/ui/AppLoader';
13 9
14import { oneOrManyChildElements } from '../../prop-types'; 10interface AuthLayoutContainerProps extends DefaultProps {
15import FeaturesStore from '../../stores/FeaturesStore'; 11 location: Location;
16 12 children: ReactNode[] | ReactNode;
17class AuthLayoutContainer extends Component { 13}
18 static propTypes = {
19 children: oneOrManyChildElements.isRequired,
20 location: PropTypes.shape({
21 pathname: PropTypes.string.isRequired,
22 }).isRequired,
23 };
24 14
25 render() { 15class AuthLayoutContainer extends Component<AuthLayoutContainerProps> {
16 render(): ReactElement {
26 const { stores, actions, children, location } = this.props; 17 const { stores, actions, children, location } = this.props;
27 const { app, features, globalError, user } = stores; 18 const { app, features, globalError, user } = stores;
28 19
@@ -33,7 +24,7 @@ class AuthLayoutContainer extends Component {
33 if (isLoadingBaseFeatures) { 24 if (isLoadingBaseFeatures) {
34 return ( 25 return (
35 <ThemeProvider theme={stores.ui.theme}> 26 <ThemeProvider theme={stores.ui.theme}>
36 <AppLoader /> 27 <AppLoader theme={stores.ui.theme} />
37 </ThemeProvider> 28 </ThemeProvider>
38 ); 29 );
39 } 30 }
@@ -42,7 +33,7 @@ class AuthLayoutContainer extends Component {
42 if (isLoggingOut) { 33 if (isLoggingOut) {
43 return ( 34 return (
44 <ThemeProvider theme={stores.ui.theme}> 35 <ThemeProvider theme={stores.ui.theme}>
45 <AppLoader texts={['Logging you out...']} /> 36 <AppLoader theme={stores.ui.theme} texts={['Logging you out...']} />
46 </ThemeProvider> 37 </ThemeProvider>
47 ); 38 );
48 } 39 }
@@ -69,18 +60,4 @@ class AuthLayoutContainer extends Component {
69 } 60 }
70} 61}
71 62
72AuthLayoutContainer.propTypes = {
73 stores: PropTypes.shape({
74 app: PropTypes.instanceOf(AppStore).isRequired,
75 features: PropTypes.instanceOf(FeaturesStore).isRequired,
76 globalError: PropTypes.instanceOf(GlobalErrorStore).isRequired,
77 user: PropTypes.instanceOf(UserStore).isRequired,
78 ui: PropTypes.instanceOf(UIStore).isRequired,
79 }).isRequired,
80 actions: PropTypes.shape({
81 app: PropTypes.instanceOf(AppStore).isRequired,
82 settings: PropTypes.instanceOf(SettingsStore).isRequired,
83 }).isRequired,
84};
85
86export default inject('stores', 'actions')(observer(AuthLayoutContainer)); 63export default inject('stores', 'actions')(observer(AuthLayoutContainer));
diff --git a/src/containers/auth/ChangeServerScreen.js b/src/containers/auth/ChangeServerScreen.tsx
index 60bfde088..6af87e4a1 100644
--- a/src/containers/auth/ChangeServerScreen.js
+++ b/src/containers/auth/ChangeServerScreen.tsx
@@ -1,18 +1,16 @@
1import { Component } from 'react'; 1import { Component, ReactElement } from 'react';
2import PropTypes from 'prop-types';
3import { inject, observer } from 'mobx-react'; 2import { inject, observer } from 'mobx-react';
4import { RouterStore } from 'mobx-react-router'; 3import { DefaultProps } from 'src/@types/ferdium-components.types';
5import ChangeServer from '../../components/auth/ChangeServer'; 4import ChangeServer from '../../components/auth/ChangeServer';
6import SettingsStore from '../../stores/SettingsStore';
7 5
8class ChangeServerScreen extends Component { 6class ChangeServerScreen extends Component<DefaultProps> {
9 constructor(props) { 7 constructor(props: DefaultProps) {
10 super(props); 8 super(props);
11 9
12 this.onSubmit = this.onSubmit.bind(this); 10 this.onSubmit = this.onSubmit.bind(this);
13 } 11 }
14 12
15 onSubmit(values) { 13 onSubmit(values: any): void {
16 const { server } = values; 14 const { server } = values;
17 15
18 this.props.actions.settings.update({ 16 this.props.actions.settings.update({
@@ -24,7 +22,7 @@ class ChangeServerScreen extends Component {
24 this.props.stores.router.push('/auth'); 22 this.props.stores.router.push('/auth');
25 } 23 }
26 24
27 render() { 25 render(): ReactElement {
28 const { stores } = this.props; 26 const { stores } = this.props;
29 const { server } = stores.settings.all.app; 27 const { server } = stores.settings.all.app;
30 28
@@ -32,14 +30,4 @@ class ChangeServerScreen extends Component {
32 } 30 }
33} 31}
34 32
35ChangeServerScreen.propTypes = {
36 actions: PropTypes.shape({
37 settings: PropTypes.instanceOf(SettingsStore).isRequired,
38 }).isRequired,
39 stores: PropTypes.shape({
40 settings: PropTypes.instanceOf(SettingsStore).isRequired,
41 router: PropTypes.instanceOf(RouterStore).isRequired,
42 }).isRequired,
43};
44
45export default inject('stores', 'actions')(observer(ChangeServerScreen)); 33export default inject('stores', 'actions')(observer(ChangeServerScreen));
diff --git a/src/containers/auth/ImportScreen.tsx b/src/containers/auth/ImportScreen.tsx
index 8d318cb2d..c128dec14 100644
--- a/src/containers/auth/ImportScreen.tsx
+++ b/src/containers/auth/ImportScreen.tsx
@@ -1,21 +1,10 @@
1import { Component } from 'react'; 1import { Component, ReactElement } from 'react';
2import { inject, observer } from 'mobx-react'; 2import { inject, observer } from 'mobx-react';
3import { RouterStore } from 'mobx-react-router'; 3import { DefaultProps } from 'src/@types/ferdium-components.types';
4import { UserStore } from 'src/stores.types';
5import Import from '../../components/auth/Import'; 4import Import from '../../components/auth/Import';
6 5
7interface IProps { 6class ImportScreen extends Component<DefaultProps> {
8 actions: { 7 render(): ReactElement {
9 user: UserStore;
10 };
11 stores: {
12 user: UserStore;
13 router: RouterStore;
14 };
15}
16
17class ImportScreen extends Component<IProps> {
18 render() {
19 const { actions, stores } = this.props; 8 const { actions, stores } = this.props;
20 9
21 if (stores.user.isImportLegacyServicesCompleted) { 10 if (stores.user.isImportLegacyServicesCompleted) {
diff --git a/src/containers/auth/InviteScreen.js b/src/containers/auth/InviteScreen.js
deleted file mode 100644
index fc66227cc..000000000
--- a/src/containers/auth/InviteScreen.js
+++ /dev/null
@@ -1,22 +0,0 @@
1import { Component } from 'react';
2import PropTypes from 'prop-types';
3import { inject, observer } from 'mobx-react';
4import Invite from '../../components/auth/Invite';
5
6class InviteScreen extends Component {
7 render() {
8 const { actions } = this.props;
9
10 return <Invite onSubmit={actions.user.invite} embed={false} />;
11 }
12}
13
14InviteScreen.propTypes = {
15 actions: PropTypes.shape({
16 user: PropTypes.shape({
17 invite: PropTypes.func.isRequired,
18 }).isRequired,
19 }).isRequired,
20};
21
22export default inject('stores', 'actions')(observer(InviteScreen));
diff --git a/src/containers/auth/InviteScreen.tsx b/src/containers/auth/InviteScreen.tsx
new file mode 100644
index 000000000..a2c684f41
--- /dev/null
+++ b/src/containers/auth/InviteScreen.tsx
@@ -0,0 +1,14 @@
1import { Component, ReactElement } from 'react';
2import { inject, observer } from 'mobx-react';
3import { DefaultProps } from 'src/@types/ferdium-components.types';
4import Invite from '../../components/auth/Invite';
5
6class InviteScreen extends Component<DefaultProps> {
7 render(): ReactElement {
8 const { actions } = this.props;
9
10 return <Invite onSubmit={actions.user.invite} embed={false} />;
11 }
12}
13
14export default inject('stores', 'actions')(observer(InviteScreen));
diff --git a/src/containers/auth/LockedScreen.tsx b/src/containers/auth/LockedScreen.tsx
index 500bff0d6..8e3c1ec49 100644
--- a/src/containers/auth/LockedScreen.tsx
+++ b/src/containers/auth/LockedScreen.tsx
@@ -1,34 +1,23 @@
1import { Component, ReactElement } from 'react'; 1import { Component, ReactElement } from 'react';
2import { inject, observer } from 'mobx-react'; 2import { inject, observer } from 'mobx-react';
3import { SettingsStore } from 'src/stores.types'; 3import { DefaultProps } from 'src/@types/ferdium-components.types';
4import Locked from '../../components/auth/Locked'; 4import Locked from '../../components/auth/Locked';
5 5
6import { hash } from '../../helpers/password-helpers'; 6import { hash } from '../../helpers/password-helpers';
7import UserStore from '../../stores/UserStore';
8 7
9interface IProps { 8class LockedScreen extends Component<DefaultProps> {
10 actions: {
11 settings: SettingsStore;
12 };
13 stores: {
14 settings: SettingsStore;
15 user: UserStore;
16 };
17}
18
19class LockedScreen extends Component<IProps> {
20 state = { 9 state = {
21 error: false, 10 error: false,
22 }; 11 };
23 12
24 constructor(props) { 13 constructor(props: DefaultProps) {
25 super(props); 14 super(props);
26 15
27 this.onSubmit = this.onSubmit.bind(this); 16 this.onSubmit = this.onSubmit.bind(this);
28 this.unlock = this.unlock.bind(this); 17 this.unlock = this.unlock.bind(this);
29 } 18 }
30 19
31 onSubmit(values): void { 20 onSubmit(values: any): void {
32 const { password } = values; 21 const { password } = values;
33 22
34 let correctPassword = this.props.stores.settings.all.app.lockedPassword; 23 let correctPassword = this.props.stores.settings.all.app.lockedPassword;
diff --git a/src/containers/auth/LoginScreen.js b/src/containers/auth/LoginScreen.tsx
index f8351f458..4c5271fe1 100644
--- a/src/containers/auth/LoginScreen.js
+++ b/src/containers/auth/LoginScreen.tsx
@@ -1,17 +1,14 @@
1import { Component } from 'react'; 1import { Component, ReactElement } from 'react';
2import PropTypes from 'prop-types';
3import { inject, observer } from 'mobx-react'; 2import { inject, observer } from 'mobx-react';
3import { DefaultProps, GlobalError } from 'src/@types/ferdium-components.types';
4import Login from '../../components/auth/Login'; 4import Login from '../../components/auth/Login';
5import UserStore from '../../stores/UserStore';
6 5
7import { globalError as globalErrorPropType } from '../../prop-types'; 6interface LoginScreenProps extends DefaultProps {
8 7 error: GlobalError;
9class LoginScreen extends Component { 8}
10 static propTypes = {
11 error: globalErrorPropType.isRequired,
12 };
13 9
14 render() { 10class LoginScreen extends Component<LoginScreenProps> {
11 render(): ReactElement {
15 const { actions, stores, error } = this.props; 12 const { actions, stores, error } = this.props;
16 return ( 13 return (
17 <Login 14 <Login
@@ -29,13 +26,4 @@ class LoginScreen extends Component {
29 } 26 }
30} 27}
31 28
32LoginScreen.propTypes = {
33 actions: PropTypes.shape({
34 user: PropTypes.instanceOf(UserStore).isRequired,
35 }).isRequired,
36 stores: PropTypes.shape({
37 user: PropTypes.instanceOf(UserStore).isRequired,
38 }).isRequired,
39};
40
41export default inject('stores', 'actions')(observer(LoginScreen)); 29export default inject('stores', 'actions')(observer(LoginScreen));
diff --git a/src/containers/auth/PasswordScreen.tsx b/src/containers/auth/PasswordScreen.tsx
index d88549712..3176e5a8b 100644
--- a/src/containers/auth/PasswordScreen.tsx
+++ b/src/containers/auth/PasswordScreen.tsx
@@ -1,19 +1,10 @@
1import { Component } from 'react'; 1import { Component, ReactElement } from 'react';
2import { inject, observer } from 'mobx-react'; 2import { inject, observer } from 'mobx-react';
3import { UserStore } from 'src/stores.types'; 3import { DefaultProps } from 'src/@types/ferdium-components.types';
4import Password from '../../components/auth/Password'; 4import Password from '../../components/auth/Password';
5 5
6interface IProps { 6class PasswordScreen extends Component<DefaultProps> {
7 actions: { 7 render(): ReactElement {
8 user: UserStore;
9 };
10 stores: {
11 user: UserStore;
12 };
13};
14
15class PasswordScreen extends Component<IProps> {
16 render() {
17 const { actions, stores } = this.props; 8 const { actions, stores } = this.props;
18 9
19 return ( 10 return (
diff --git a/src/containers/auth/SetupAssistantScreen.tsx b/src/containers/auth/SetupAssistantScreen.tsx
index 8f1871776..92f12c0bc 100644
--- a/src/containers/auth/SetupAssistantScreen.tsx
+++ b/src/containers/auth/SetupAssistantScreen.tsx
@@ -1,29 +1,12 @@
1/* eslint-disable no-await-in-loop */ 1/* eslint-disable no-await-in-loop */
2import { Component } from 'react'; 2import { Component, ReactElement } from 'react';
3import { inject, observer } from 'mobx-react'; 3import { inject, observer } from 'mobx-react';
4 4
5import { RouterStore } from 'mobx-react-router'; 5import { DefaultProps } from 'src/@types/ferdium-components.types';
6import { sleep } from '../../helpers/async-helpers'; 6import { sleep } from '../../helpers/async-helpers';
7import SetupAssistant from '../../components/auth/SetupAssistant'; 7import SetupAssistant from '../../components/auth/SetupAssistant';
8import ServicesStore from '../../stores/ServicesStore';
9import RecipesStore from '../../stores/RecipesStore';
10import UserStore from '../../stores/UserStore';
11 8
12interface IProps { 9class SetupAssistantScreen extends Component<DefaultProps> {
13 stores: {
14 services: ServicesStore;
15 router: RouterStore;
16 recipes?: RecipesStore;
17 user?: UserStore;
18 };
19 actions: {
20 user: UserStore;
21 service: ServicesStore;
22 recipe: RecipesStore;
23 };
24};
25
26class SetupAssistantScreen extends Component<IProps> {
27 state = { 10 state = {
28 isSettingUpServices: false, 11 isSettingUpServices: false,
29 }; 12 };
@@ -68,7 +51,7 @@ class SetupAssistantScreen extends Component<IProps> {
68 }, 51 },
69 }; 52 };
70 53
71 async setupServices(serviceConfig) { 54 async setupServices(serviceConfig: any): Promise<void> {
72 const { 55 const {
73 stores: { services, router }, 56 stores: { services, router },
74 } = this.props; 57 } = this.props;
@@ -103,7 +86,7 @@ class SetupAssistantScreen extends Component<IProps> {
103 router.push('/'); 86 router.push('/');
104 } 87 }
105 88
106 render() { 89 render(): ReactElement {
107 return ( 90 return (
108 <SetupAssistant 91 <SetupAssistant
109 onSubmit={config => this.setupServices(config)} 92 onSubmit={config => this.setupServices(config)}
diff --git a/src/containers/auth/SignupScreen.js b/src/containers/auth/SignupScreen.js
deleted file mode 100644
index 3824e47d5..000000000
--- a/src/containers/auth/SignupScreen.js
+++ /dev/null
@@ -1,46 +0,0 @@
1import { Component } from 'react';
2import PropTypes from 'prop-types';
3import { inject, observer } from 'mobx-react';
4
5import Signup from '../../components/auth/Signup';
6import UserStore from '../../stores/UserStore';
7import FeaturesStore from '../../stores/FeaturesStore';
8
9import { globalError as globalErrorPropType } from '../../prop-types';
10
11class SignupScreen extends Component {
12 static propTypes = {
13 error: globalErrorPropType.isRequired,
14 };
15
16 onSignup(values) {
17 const { actions } = this.props;
18
19 actions.user.signup(values);
20 }
21
22 render() {
23 const { stores, error } = this.props;
24
25 return (
26 <Signup
27 onSubmit={values => this.onSignup(values)}
28 isSubmitting={stores.user.signupRequest.isExecuting}
29 loginRoute={stores.user.loginRoute}
30 error={error}
31 />
32 );
33 }
34}
35
36SignupScreen.propTypes = {
37 actions: PropTypes.shape({
38 user: PropTypes.instanceOf(UserStore).isRequired,
39 }).isRequired,
40 stores: PropTypes.shape({
41 user: PropTypes.instanceOf(UserStore).isRequired,
42 features: PropTypes.instanceOf(FeaturesStore).isRequired,
43 }).isRequired,
44};
45
46export default inject('stores', 'actions')(observer(SignupScreen));
diff --git a/src/containers/auth/SignupScreen.tsx b/src/containers/auth/SignupScreen.tsx
new file mode 100644
index 000000000..1dac392ef
--- /dev/null
+++ b/src/containers/auth/SignupScreen.tsx
@@ -0,0 +1,32 @@
1import { Component, ReactElement } from 'react';
2import { inject, observer } from 'mobx-react';
3
4import { DefaultProps, GlobalError } from 'src/@types/ferdium-components.types';
5import Signup from '../../components/auth/Signup';
6
7interface SignUpScreenComponents extends DefaultProps {
8 error: GlobalError;
9}
10
11class SignupScreen extends Component<SignUpScreenComponents> {
12 onSignup(values: any): void {
13 const { actions } = this.props;
14
15 actions.user.signup(values);
16 }
17
18 render(): ReactElement {
19 const { stores, error } = this.props;
20
21 return (
22 <Signup
23 onSubmit={values => this.onSignup(values)}
24 isSubmitting={stores.user.signupRequest.isExecuting}
25 loginRoute={stores.user.loginRoute}
26 error={error}
27 />
28 );
29 }
30}
31
32export default inject('stores', 'actions')(observer(SignupScreen));
diff --git a/src/containers/auth/WelcomeScreen.tsx b/src/containers/auth/WelcomeScreen.tsx
index 944d288ad..bbd73f4a2 100644
--- a/src/containers/auth/WelcomeScreen.tsx
+++ b/src/containers/auth/WelcomeScreen.tsx
@@ -1,19 +1,11 @@
1import { Component } from 'react'; 1import { Component, ReactElement } from 'react';
2import { inject, observer } from 'mobx-react'; 2import { inject, observer } from 'mobx-react';
3 3
4import { DefaultProps } from 'src/@types/ferdium-components.types';
4import Welcome from '../../components/auth/Welcome'; 5import Welcome from '../../components/auth/Welcome';
5import UserStore from '../../stores/UserStore';
6import RecipePreviewsStore from '../../stores/RecipePreviewsStore';
7 6
8interface IProps { 7class WelcomeScreen extends Component<DefaultProps> {
9 stores: { 8 render(): ReactElement {
10 user: UserStore,
11 recipePreviews: RecipePreviewsStore,
12 },
13};
14
15class WelcomeScreen extends Component<IProps> {
16 render() {
17 const { user, recipePreviews } = this.props.stores; 9 const { user, recipePreviews } = this.props.stores;
18 10
19 return ( 11 return (
diff --git a/src/features/workspaces/containers/EditWorkspaceScreen.tsx b/src/features/workspaces/containers/EditWorkspaceScreen.tsx
index 0351ddafb..f0c7e4574 100644
--- a/src/features/workspaces/containers/EditWorkspaceScreen.tsx
+++ b/src/features/workspaces/containers/EditWorkspaceScreen.tsx
@@ -6,7 +6,7 @@ import EditWorkspaceForm from '../components/EditWorkspaceForm';
6import Workspace from '../models/Workspace'; 6import Workspace from '../models/Workspace';
7import { workspaceStore } from '../index'; 7import { workspaceStore } from '../index';
8import { deleteWorkspaceRequest, updateWorkspaceRequest } from '../api'; 8import { deleteWorkspaceRequest, updateWorkspaceRequest } from '../api';
9import { ServicesStore, WorkspacesStore } from '../../../stores.types'; 9import { ServicesStore, WorkspacesStore } from '../../../@types/stores.types';
10 10
11type Props = { 11type Props = {
12 actions: { 12 actions: {
diff --git a/src/features/workspaces/containers/WorkspacesScreen.tsx b/src/features/workspaces/containers/WorkspacesScreen.tsx
index 33808b69d..5b153fb50 100644
--- a/src/features/workspaces/containers/WorkspacesScreen.tsx
+++ b/src/features/workspaces/containers/WorkspacesScreen.tsx
@@ -9,7 +9,7 @@ import {
9 getUserWorkspacesRequest, 9 getUserWorkspacesRequest,
10 updateWorkspaceRequest, 10 updateWorkspaceRequest,
11} from '../api'; 11} from '../api';
12import { WorkspacesStore } from '../../../stores.types'; 12import { WorkspacesStore } from '../../../@types/stores.types';
13 13
14type Props = { 14type Props = {
15 actions: { 15 actions: {
diff --git a/src/helpers/async-helpers.ts b/src/helpers/async-helpers.ts
index 56051b065..6556a0141 100644
--- a/src/helpers/async-helpers.ts
+++ b/src/helpers/async-helpers.ts
@@ -1,4 +1,4 @@
1export function sleep(ms: number = 0) { 1export function sleep(ms: number = 0): Promise<void> {
2 // eslint-disable-next-line no-promise-executor-return 2 // eslint-disable-next-line no-promise-executor-return
3 return new Promise(r => setTimeout(r, ms)); 3 return new Promise(r => setTimeout(r, ms));
4} 4}
diff --git a/src/stores/AppStore.ts b/src/stores/AppStore.ts
index 5659460c6..f333a0060 100644
--- a/src/stores/AppStore.ts
+++ b/src/stores/AppStore.ts
@@ -14,7 +14,7 @@ import ms from 'ms';
14import { URL } from 'url'; 14import { URL } from 'url';
15import { readJsonSync } from 'fs-extra'; 15import { readJsonSync } from 'fs-extra';
16 16
17import { Stores } from 'src/stores.types'; 17import { Stores } from 'src/@types/stores.types';
18import { ApiInterface } from 'src/api'; 18import { ApiInterface } from 'src/api';
19import { Actions } from 'src/actions/lib/actions'; 19import { Actions } from 'src/actions/lib/actions';
20import TypedStore from './lib/TypedStore'; 20import TypedStore from './lib/TypedStore';
diff --git a/src/stores/GlobalErrorStore.ts b/src/stores/GlobalErrorStore.ts
index cb364574b..fcc1276c8 100644
--- a/src/stores/GlobalErrorStore.ts
+++ b/src/stores/GlobalErrorStore.ts
@@ -1,7 +1,7 @@
1import { observable, action } from 'mobx'; 1import { observable, action } from 'mobx';
2import { Actions } from 'src/actions/lib/actions'; 2import { Actions } from 'src/actions/lib/actions';
3import { ApiInterface } from 'src/api'; 3import { ApiInterface } from 'src/api';
4import { Stores } from 'src/stores.types'; 4import { Stores } from 'src/@types/stores.types';
5import Request from './lib/Request'; 5import Request from './lib/Request';
6import TypedStore from './lib/TypedStore'; 6import TypedStore from './lib/TypedStore';
7 7
diff --git a/src/stores/RecipePreviewsStore.ts b/src/stores/RecipePreviewsStore.ts
index 500f69b40..099867785 100644
--- a/src/stores/RecipePreviewsStore.ts
+++ b/src/stores/RecipePreviewsStore.ts
@@ -2,7 +2,7 @@ import { action, computed, observable } from 'mobx';
2import { Actions } from 'src/actions/lib/actions'; 2import { Actions } from 'src/actions/lib/actions';
3import { ApiInterface } from 'src/api'; 3import { ApiInterface } from 'src/api';
4import Recipe from 'src/models/Recipe'; 4import Recipe from 'src/models/Recipe';
5import { Stores } from 'src/stores.types'; 5import { Stores } from 'src/@types/stores.types';
6 6
7import CachedRequest from './lib/CachedRequest'; 7import CachedRequest from './lib/CachedRequest';
8import Request from './lib/Request'; 8import Request from './lib/Request';
diff --git a/src/stores/RecipesStore.ts b/src/stores/RecipesStore.ts
index af2aa7fb0..d63e46bef 100644
--- a/src/stores/RecipesStore.ts
+++ b/src/stores/RecipesStore.ts
@@ -2,7 +2,7 @@ import { action, computed, observable } from 'mobx';
2import { readJSONSync } from 'fs-extra'; 2import { readJSONSync } from 'fs-extra';
3import semver from 'semver'; 3import semver from 'semver';
4 4
5import { Stores } from 'src/stores.types'; 5import { Stores } from 'src/@types/stores.types';
6import { ApiInterface } from 'src/api'; 6import { ApiInterface } from 'src/api';
7import { Actions } from 'src/actions/lib/actions'; 7import { Actions } from 'src/actions/lib/actions';
8import Recipe from 'src/models/Recipe'; 8import Recipe from 'src/models/Recipe';
diff --git a/src/stores/RequestStore.ts b/src/stores/RequestStore.ts
index 03ad2c7db..af686388a 100644
--- a/src/stores/RequestStore.ts
+++ b/src/stores/RequestStore.ts
@@ -4,7 +4,7 @@ import ms from 'ms';
4 4
5import { Actions } from 'src/actions/lib/actions'; 5import { Actions } from 'src/actions/lib/actions';
6import { ApiInterface } from 'src/api'; 6import { ApiInterface } from 'src/api';
7import { Stores } from 'src/stores.types'; 7import { Stores } from 'src/@types/stores.types';
8import CachedRequest from './lib/CachedRequest'; 8import CachedRequest from './lib/CachedRequest';
9import { LOCAL_PORT } from '../config'; 9import { LOCAL_PORT } from '../config';
10 10
diff --git a/src/stores/ServicesStore.ts b/src/stores/ServicesStore.ts
index caa44146f..0164d092a 100644
--- a/src/stores/ServicesStore.ts
+++ b/src/stores/ServicesStore.ts
@@ -5,7 +5,7 @@ import ms from 'ms';
5import { ensureFileSync, pathExistsSync, writeFileSync } from 'fs-extra'; 5import { ensureFileSync, pathExistsSync, writeFileSync } from 'fs-extra';
6import { join } from 'path'; 6import { join } from 'path';
7 7
8import { Stores } from 'src/stores.types'; 8import { Stores } from 'src/@types/stores.types';
9import { ApiInterface } from 'src/api'; 9import { ApiInterface } from 'src/api';
10import { Actions } from 'src/actions/lib/actions'; 10import { Actions } from 'src/actions/lib/actions';
11import Request from './lib/Request'; 11import Request from './lib/Request';
diff --git a/src/stores/SettingsStore.ts b/src/stores/SettingsStore.ts
index 524f2e50c..dabd7b099 100644
--- a/src/stores/SettingsStore.ts
+++ b/src/stores/SettingsStore.ts
@@ -2,7 +2,7 @@ import { ipcRenderer } from 'electron';
2import { getCurrentWindow } from '@electron/remote'; 2import { getCurrentWindow } from '@electron/remote';
3import { action, computed, observable, reaction } from 'mobx'; 3import { action, computed, observable, reaction } from 'mobx';
4import localStorage from 'mobx-localstorage'; 4import localStorage from 'mobx-localstorage';
5import { Stores } from 'src/stores.types'; 5import { Stores } from 'src/@types/stores.types';
6import { ApiInterface } from 'src/api'; 6import { ApiInterface } from 'src/api';
7import { Actions } from 'src/actions/lib/actions'; 7import { Actions } from 'src/actions/lib/actions';
8import { 8import {
diff --git a/src/stores/UIStore.ts b/src/stores/UIStore.ts
index 306b14cb1..e9e099ebc 100644
--- a/src/stores/UIStore.ts
+++ b/src/stores/UIStore.ts
@@ -1,7 +1,7 @@
1import { action, observable, computed, reaction } from 'mobx'; 1import { action, observable, computed, reaction } from 'mobx';
2import { nativeTheme } from '@electron/remote'; 2import { nativeTheme } from '@electron/remote';
3 3
4import { Stores } from 'src/stores.types'; 4import { Stores } from 'src/@types/stores.types';
5import { ApiInterface } from 'src/api'; 5import { ApiInterface } from 'src/api';
6import { Actions } from 'src/actions/lib/actions'; 6import { Actions } from 'src/actions/lib/actions';
7import { Theme, theme, ThemeType } from '../themes'; 7import { Theme, theme, ThemeType } from '../themes';
diff --git a/src/stores/UserStore.ts b/src/stores/UserStore.ts
index 616ff29a6..0827f8196 100644
--- a/src/stores/UserStore.ts
+++ b/src/stores/UserStore.ts
@@ -6,7 +6,7 @@ import { ipcRenderer } from 'electron';
6 6
7import { ApiInterface } from 'src/api'; 7import { ApiInterface } from 'src/api';
8import { Actions } from 'src/actions/lib/actions'; 8import { Actions } from 'src/actions/lib/actions';
9import { Stores } from 'src/stores.types'; 9import { Stores } from 'src/@types/stores.types';
10import { TODOS_PARTITION_ID } from '../config'; 10import { TODOS_PARTITION_ID } from '../config';
11import { isDevMode } from '../environment-remote'; 11import { isDevMode } from '../environment-remote';
12import Request from './lib/Request'; 12import Request from './lib/Request';
diff --git a/src/stores/index.ts b/src/stores/index.ts
index a5b1a7452..aac501cda 100644
--- a/src/stores/index.ts
+++ b/src/stores/index.ts
@@ -1,4 +1,3 @@
1import { Stores } from 'src/stores.types';
2import { RouterStore } from 'mobx-react-router'; 1import { RouterStore } from 'mobx-react-router';
3import { ApiInterface } from 'src/api'; 2import { ApiInterface } from 'src/api';
4import { Actions } from 'src/actions/lib/actions'; 3import { Actions } from 'src/actions/lib/actions';
@@ -16,12 +15,29 @@ import { workspaceStore } from '../features/workspaces';
16import { communityRecipesStore } from '../features/communityRecipes'; 15import { communityRecipesStore } from '../features/communityRecipes';
17import { todosStore } from '../features/todos'; 16import { todosStore } from '../features/todos';
18 17
18export interface RealStores {
19 router: RouterStore;
20 app: AppStore;
21 user: UserStore;
22 features: FeaturesStore;
23 settings: SettingsStore;
24 services: ServicesStore;
25 recipes: RecipesStore;
26 recipePreviews: RecipePreviewsStore;
27 ui: UIStore;
28 requests: RequestStore;
29 globalError: GlobalErrorStore;
30 workspaces: typeof workspaceStore;
31 communityRecipes: typeof communityRecipesStore;
32 todos: typeof todosStore;
33}
34
19export default ( 35export default (
20 api: ApiInterface, 36 api: ApiInterface,
21 actions: Actions, 37 actions: Actions,
22 router: RouterStore, 38 router: RouterStore,
23): Stores => { 39): RealStores => {
24 const stores: Stores | any = {}; 40 const stores: RealStores | any = {};
25 Object.assign(stores, { 41 Object.assign(stores, {
26 router, 42 router,
27 app: new AppStore(stores, api, actions), 43 app: new AppStore(stores, api, actions),
diff --git a/src/stores/lib/TypedStore.ts b/src/stores/lib/TypedStore.ts
index 7f9d2d60f..c78f83850 100644
--- a/src/stores/lib/TypedStore.ts
+++ b/src/stores/lib/TypedStore.ts
@@ -1,7 +1,7 @@
1import { computed, IReactionPublic, observable } from 'mobx'; 1import { computed, IReactionPublic, observable } from 'mobx';
2import { Actions } from 'src/actions/lib/actions'; 2import { Actions } from 'src/actions/lib/actions';
3import { ApiInterface } from 'src/api'; 3import { ApiInterface } from 'src/api';
4import { Stores } from 'src/stores.types'; 4import { Stores } from 'src/@types/stores.types';
5import Reaction from './Reaction'; 5import Reaction from './Reaction';
6 6
7export default abstract class TypedStore { 7export default abstract class TypedStore {