diff options
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 @@ | |||
1 | import { Actions } from 'src/actions/lib/actions'; | ||
2 | import { RealStores } from 'src/stores'; | ||
3 | |||
4 | export interface DefaultProps { | ||
5 | actions: Actions; | ||
6 | stores: RealStores; | ||
7 | } | ||
8 | |||
9 | export 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 | */ |
22 | export {}; | 22 | export { }; |
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 @@ | |||
1 | import Workspace from './features/workspaces/models/Workspace'; | 1 | import Workspace from '../features/workspaces/models/Workspace'; |
2 | import Recipe from './models/Recipe'; | 2 | import Recipe from '../models/Recipe'; |
3 | import Service from './models/Service'; | 3 | import Service from '../models/Service'; |
4 | import User from './models/User'; | 4 | import User from '../models/User'; |
5 | import { Request } from './stores/lib/Request'; | 5 | import { Request } from '../stores/lib/Request'; |
6 | import { CachedRequest } from './stores/lib/CachedRequest'; | 6 | import { CachedRequest } from '../stores/lib/CachedRequest'; |
7 | import Reaction from './stores/lib/Reaction'; | 7 | import 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 | ||
9 | export interface FerdiumStores { | 12 | export 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 | ||
9 | const translations = generatedTranslations(); | 9 | const translations = generatedTranslations(); |
10 | 10 | ||
11 | type Props = { | 11 | interface 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 | ||
19 | class I18N extends Component<Props> { | 19 | class 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'; | |||
2 | import { observer, inject } from 'mobx-react'; | 2 | import { observer, inject } from 'mobx-react'; |
3 | import Loader from 'react-loader'; | 3 | import Loader from 'react-loader'; |
4 | 4 | ||
5 | import { FerdiumStores } from '../../stores.types'; | 5 | import { FerdiumStores } from '../../@types/stores.types'; |
6 | 6 | ||
7 | type Props = { | 7 | type 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 @@ | |||
1 | import { Component } from 'react'; | 1 | import { Component, ReactElement, ReactNode } from 'react'; |
2 | import PropTypes from 'prop-types'; | ||
3 | import { inject, observer } from 'mobx-react'; | 2 | import { inject, observer } from 'mobx-react'; |
4 | import { ThemeProvider } from 'react-jss'; | 3 | import { ThemeProvider } from 'react-jss'; |
5 | 4 | ||
5 | import { DefaultProps } from 'src/@types/ferdium-components.types'; | ||
6 | import { Location } from 'mobx-react-router'; | ||
6 | import AuthLayout from '../../components/auth/AuthLayout'; | 7 | import AuthLayout from '../../components/auth/AuthLayout'; |
7 | import AppStore from '../../stores/AppStore'; | ||
8 | import UserStore from '../../stores/UserStore'; | ||
9 | import GlobalErrorStore from '../../stores/GlobalErrorStore'; | ||
10 | import UIStore from '../../stores/UIStore'; | ||
11 | import SettingsStore from '../../stores/SettingsStore'; | ||
12 | import AppLoader from '../../components/ui/AppLoader'; | 8 | import AppLoader from '../../components/ui/AppLoader'; |
13 | 9 | ||
14 | import { oneOrManyChildElements } from '../../prop-types'; | 10 | interface AuthLayoutContainerProps extends DefaultProps { |
15 | import FeaturesStore from '../../stores/FeaturesStore'; | 11 | location: Location; |
16 | 12 | children: ReactNode[] | ReactNode; | |
17 | class 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() { | 15 | class 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 | ||
72 | AuthLayoutContainer.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 | |||
86 | export default inject('stores', 'actions')(observer(AuthLayoutContainer)); | 63 | export 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 @@ | |||
1 | import { Component } from 'react'; | 1 | import { Component, ReactElement } from 'react'; |
2 | import PropTypes from 'prop-types'; | ||
3 | import { inject, observer } from 'mobx-react'; | 2 | import { inject, observer } from 'mobx-react'; |
4 | import { RouterStore } from 'mobx-react-router'; | 3 | import { DefaultProps } from 'src/@types/ferdium-components.types'; |
5 | import ChangeServer from '../../components/auth/ChangeServer'; | 4 | import ChangeServer from '../../components/auth/ChangeServer'; |
6 | import SettingsStore from '../../stores/SettingsStore'; | ||
7 | 5 | ||
8 | class ChangeServerScreen extends Component { | 6 | class 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 | ||
35 | ChangeServerScreen.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 | |||
45 | export default inject('stores', 'actions')(observer(ChangeServerScreen)); | 33 | export 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 @@ | |||
1 | import { Component } from 'react'; | 1 | import { Component, ReactElement } from 'react'; |
2 | import { inject, observer } from 'mobx-react'; | 2 | import { inject, observer } from 'mobx-react'; |
3 | import { RouterStore } from 'mobx-react-router'; | 3 | import { DefaultProps } from 'src/@types/ferdium-components.types'; |
4 | import { UserStore } from 'src/stores.types'; | ||
5 | import Import from '../../components/auth/Import'; | 4 | import Import from '../../components/auth/Import'; |
6 | 5 | ||
7 | interface IProps { | 6 | class ImportScreen extends Component<DefaultProps> { |
8 | actions: { | 7 | render(): ReactElement { |
9 | user: UserStore; | ||
10 | }; | ||
11 | stores: { | ||
12 | user: UserStore; | ||
13 | router: RouterStore; | ||
14 | }; | ||
15 | } | ||
16 | |||
17 | class 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 @@ | |||
1 | import { Component } from 'react'; | ||
2 | import PropTypes from 'prop-types'; | ||
3 | import { inject, observer } from 'mobx-react'; | ||
4 | import Invite from '../../components/auth/Invite'; | ||
5 | |||
6 | class InviteScreen extends Component { | ||
7 | render() { | ||
8 | const { actions } = this.props; | ||
9 | |||
10 | return <Invite onSubmit={actions.user.invite} embed={false} />; | ||
11 | } | ||
12 | } | ||
13 | |||
14 | InviteScreen.propTypes = { | ||
15 | actions: PropTypes.shape({ | ||
16 | user: PropTypes.shape({ | ||
17 | invite: PropTypes.func.isRequired, | ||
18 | }).isRequired, | ||
19 | }).isRequired, | ||
20 | }; | ||
21 | |||
22 | export 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 @@ | |||
1 | import { Component, ReactElement } from 'react'; | ||
2 | import { inject, observer } from 'mobx-react'; | ||
3 | import { DefaultProps } from 'src/@types/ferdium-components.types'; | ||
4 | import Invite from '../../components/auth/Invite'; | ||
5 | |||
6 | class 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 | |||
14 | export 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 @@ | |||
1 | import { Component, ReactElement } from 'react'; | 1 | import { Component, ReactElement } from 'react'; |
2 | import { inject, observer } from 'mobx-react'; | 2 | import { inject, observer } from 'mobx-react'; |
3 | import { SettingsStore } from 'src/stores.types'; | 3 | import { DefaultProps } from 'src/@types/ferdium-components.types'; |
4 | import Locked from '../../components/auth/Locked'; | 4 | import Locked from '../../components/auth/Locked'; |
5 | 5 | ||
6 | import { hash } from '../../helpers/password-helpers'; | 6 | import { hash } from '../../helpers/password-helpers'; |
7 | import UserStore from '../../stores/UserStore'; | ||
8 | 7 | ||
9 | interface IProps { | 8 | class LockedScreen extends Component<DefaultProps> { |
10 | actions: { | ||
11 | settings: SettingsStore; | ||
12 | }; | ||
13 | stores: { | ||
14 | settings: SettingsStore; | ||
15 | user: UserStore; | ||
16 | }; | ||
17 | } | ||
18 | |||
19 | class 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 @@ | |||
1 | import { Component } from 'react'; | 1 | import { Component, ReactElement } from 'react'; |
2 | import PropTypes from 'prop-types'; | ||
3 | import { inject, observer } from 'mobx-react'; | 2 | import { inject, observer } from 'mobx-react'; |
3 | import { DefaultProps, GlobalError } from 'src/@types/ferdium-components.types'; | ||
4 | import Login from '../../components/auth/Login'; | 4 | import Login from '../../components/auth/Login'; |
5 | import UserStore from '../../stores/UserStore'; | ||
6 | 5 | ||
7 | import { globalError as globalErrorPropType } from '../../prop-types'; | 6 | interface LoginScreenProps extends DefaultProps { |
8 | 7 | error: GlobalError; | |
9 | class LoginScreen extends Component { | 8 | } |
10 | static propTypes = { | ||
11 | error: globalErrorPropType.isRequired, | ||
12 | }; | ||
13 | 9 | ||
14 | render() { | 10 | class 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 | ||
32 | LoginScreen.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 | |||
41 | export default inject('stores', 'actions')(observer(LoginScreen)); | 29 | export 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 @@ | |||
1 | import { Component } from 'react'; | 1 | import { Component, ReactElement } from 'react'; |
2 | import { inject, observer } from 'mobx-react'; | 2 | import { inject, observer } from 'mobx-react'; |
3 | import { UserStore } from 'src/stores.types'; | 3 | import { DefaultProps } from 'src/@types/ferdium-components.types'; |
4 | import Password from '../../components/auth/Password'; | 4 | import Password from '../../components/auth/Password'; |
5 | 5 | ||
6 | interface IProps { | 6 | class PasswordScreen extends Component<DefaultProps> { |
7 | actions: { | 7 | render(): ReactElement { |
8 | user: UserStore; | ||
9 | }; | ||
10 | stores: { | ||
11 | user: UserStore; | ||
12 | }; | ||
13 | }; | ||
14 | |||
15 | class 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 */ |
2 | import { Component } from 'react'; | 2 | import { Component, ReactElement } from 'react'; |
3 | import { inject, observer } from 'mobx-react'; | 3 | import { inject, observer } from 'mobx-react'; |
4 | 4 | ||
5 | import { RouterStore } from 'mobx-react-router'; | 5 | import { DefaultProps } from 'src/@types/ferdium-components.types'; |
6 | import { sleep } from '../../helpers/async-helpers'; | 6 | import { sleep } from '../../helpers/async-helpers'; |
7 | import SetupAssistant from '../../components/auth/SetupAssistant'; | 7 | import SetupAssistant from '../../components/auth/SetupAssistant'; |
8 | import ServicesStore from '../../stores/ServicesStore'; | ||
9 | import RecipesStore from '../../stores/RecipesStore'; | ||
10 | import UserStore from '../../stores/UserStore'; | ||
11 | 8 | ||
12 | interface IProps { | 9 | class 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 | |||
26 | class 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 @@ | |||
1 | import { Component } from 'react'; | ||
2 | import PropTypes from 'prop-types'; | ||
3 | import { inject, observer } from 'mobx-react'; | ||
4 | |||
5 | import Signup from '../../components/auth/Signup'; | ||
6 | import UserStore from '../../stores/UserStore'; | ||
7 | import FeaturesStore from '../../stores/FeaturesStore'; | ||
8 | |||
9 | import { globalError as globalErrorPropType } from '../../prop-types'; | ||
10 | |||
11 | class 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 | |||
36 | SignupScreen.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 | |||
46 | export 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 @@ | |||
1 | import { Component, ReactElement } from 'react'; | ||
2 | import { inject, observer } from 'mobx-react'; | ||
3 | |||
4 | import { DefaultProps, GlobalError } from 'src/@types/ferdium-components.types'; | ||
5 | import Signup from '../../components/auth/Signup'; | ||
6 | |||
7 | interface SignUpScreenComponents extends DefaultProps { | ||
8 | error: GlobalError; | ||
9 | } | ||
10 | |||
11 | class 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 | |||
32 | export 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 @@ | |||
1 | import { Component } from 'react'; | 1 | import { Component, ReactElement } from 'react'; |
2 | import { inject, observer } from 'mobx-react'; | 2 | import { inject, observer } from 'mobx-react'; |
3 | 3 | ||
4 | import { DefaultProps } from 'src/@types/ferdium-components.types'; | ||
4 | import Welcome from '../../components/auth/Welcome'; | 5 | import Welcome from '../../components/auth/Welcome'; |
5 | import UserStore from '../../stores/UserStore'; | ||
6 | import RecipePreviewsStore from '../../stores/RecipePreviewsStore'; | ||
7 | 6 | ||
8 | interface IProps { | 7 | class WelcomeScreen extends Component<DefaultProps> { |
9 | stores: { | 8 | render(): ReactElement { |
10 | user: UserStore, | ||
11 | recipePreviews: RecipePreviewsStore, | ||
12 | }, | ||
13 | }; | ||
14 | |||
15 | class 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'; | |||
6 | import Workspace from '../models/Workspace'; | 6 | import Workspace from '../models/Workspace'; |
7 | import { workspaceStore } from '../index'; | 7 | import { workspaceStore } from '../index'; |
8 | import { deleteWorkspaceRequest, updateWorkspaceRequest } from '../api'; | 8 | import { deleteWorkspaceRequest, updateWorkspaceRequest } from '../api'; |
9 | import { ServicesStore, WorkspacesStore } from '../../../stores.types'; | 9 | import { ServicesStore, WorkspacesStore } from '../../../@types/stores.types'; |
10 | 10 | ||
11 | type Props = { | 11 | type 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'; |
12 | import { WorkspacesStore } from '../../../stores.types'; | 12 | import { WorkspacesStore } from '../../../@types/stores.types'; |
13 | 13 | ||
14 | type Props = { | 14 | type 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 @@ | |||
1 | export function sleep(ms: number = 0) { | 1 | export 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'; | |||
14 | import { URL } from 'url'; | 14 | import { URL } from 'url'; |
15 | import { readJsonSync } from 'fs-extra'; | 15 | import { readJsonSync } from 'fs-extra'; |
16 | 16 | ||
17 | import { Stores } from 'src/stores.types'; | 17 | import { Stores } from 'src/@types/stores.types'; |
18 | import { ApiInterface } from 'src/api'; | 18 | import { ApiInterface } from 'src/api'; |
19 | import { Actions } from 'src/actions/lib/actions'; | 19 | import { Actions } from 'src/actions/lib/actions'; |
20 | import TypedStore from './lib/TypedStore'; | 20 | import 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 @@ | |||
1 | import { observable, action } from 'mobx'; | 1 | import { observable, action } from 'mobx'; |
2 | import { Actions } from 'src/actions/lib/actions'; | 2 | import { Actions } from 'src/actions/lib/actions'; |
3 | import { ApiInterface } from 'src/api'; | 3 | import { ApiInterface } from 'src/api'; |
4 | import { Stores } from 'src/stores.types'; | 4 | import { Stores } from 'src/@types/stores.types'; |
5 | import Request from './lib/Request'; | 5 | import Request from './lib/Request'; |
6 | import TypedStore from './lib/TypedStore'; | 6 | import 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'; | |||
2 | import { Actions } from 'src/actions/lib/actions'; | 2 | import { Actions } from 'src/actions/lib/actions'; |
3 | import { ApiInterface } from 'src/api'; | 3 | import { ApiInterface } from 'src/api'; |
4 | import Recipe from 'src/models/Recipe'; | 4 | import Recipe from 'src/models/Recipe'; |
5 | import { Stores } from 'src/stores.types'; | 5 | import { Stores } from 'src/@types/stores.types'; |
6 | 6 | ||
7 | import CachedRequest from './lib/CachedRequest'; | 7 | import CachedRequest from './lib/CachedRequest'; |
8 | import Request from './lib/Request'; | 8 | import 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'; | |||
2 | import { readJSONSync } from 'fs-extra'; | 2 | import { readJSONSync } from 'fs-extra'; |
3 | import semver from 'semver'; | 3 | import semver from 'semver'; |
4 | 4 | ||
5 | import { Stores } from 'src/stores.types'; | 5 | import { Stores } from 'src/@types/stores.types'; |
6 | import { ApiInterface } from 'src/api'; | 6 | import { ApiInterface } from 'src/api'; |
7 | import { Actions } from 'src/actions/lib/actions'; | 7 | import { Actions } from 'src/actions/lib/actions'; |
8 | import Recipe from 'src/models/Recipe'; | 8 | import 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 | ||
5 | import { Actions } from 'src/actions/lib/actions'; | 5 | import { Actions } from 'src/actions/lib/actions'; |
6 | import { ApiInterface } from 'src/api'; | 6 | import { ApiInterface } from 'src/api'; |
7 | import { Stores } from 'src/stores.types'; | 7 | import { Stores } from 'src/@types/stores.types'; |
8 | import CachedRequest from './lib/CachedRequest'; | 8 | import CachedRequest from './lib/CachedRequest'; |
9 | import { LOCAL_PORT } from '../config'; | 9 | import { 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'; | |||
5 | import { ensureFileSync, pathExistsSync, writeFileSync } from 'fs-extra'; | 5 | import { ensureFileSync, pathExistsSync, writeFileSync } from 'fs-extra'; |
6 | import { join } from 'path'; | 6 | import { join } from 'path'; |
7 | 7 | ||
8 | import { Stores } from 'src/stores.types'; | 8 | import { Stores } from 'src/@types/stores.types'; |
9 | import { ApiInterface } from 'src/api'; | 9 | import { ApiInterface } from 'src/api'; |
10 | import { Actions } from 'src/actions/lib/actions'; | 10 | import { Actions } from 'src/actions/lib/actions'; |
11 | import Request from './lib/Request'; | 11 | import 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'; | |||
2 | import { getCurrentWindow } from '@electron/remote'; | 2 | import { getCurrentWindow } from '@electron/remote'; |
3 | import { action, computed, observable, reaction } from 'mobx'; | 3 | import { action, computed, observable, reaction } from 'mobx'; |
4 | import localStorage from 'mobx-localstorage'; | 4 | import localStorage from 'mobx-localstorage'; |
5 | import { Stores } from 'src/stores.types'; | 5 | import { Stores } from 'src/@types/stores.types'; |
6 | import { ApiInterface } from 'src/api'; | 6 | import { ApiInterface } from 'src/api'; |
7 | import { Actions } from 'src/actions/lib/actions'; | 7 | import { Actions } from 'src/actions/lib/actions'; |
8 | import { | 8 | import { |
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 @@ | |||
1 | import { action, observable, computed, reaction } from 'mobx'; | 1 | import { action, observable, computed, reaction } from 'mobx'; |
2 | import { nativeTheme } from '@electron/remote'; | 2 | import { nativeTheme } from '@electron/remote'; |
3 | 3 | ||
4 | import { Stores } from 'src/stores.types'; | 4 | import { Stores } from 'src/@types/stores.types'; |
5 | import { ApiInterface } from 'src/api'; | 5 | import { ApiInterface } from 'src/api'; |
6 | import { Actions } from 'src/actions/lib/actions'; | 6 | import { Actions } from 'src/actions/lib/actions'; |
7 | import { Theme, theme, ThemeType } from '../themes'; | 7 | import { 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 | ||
7 | import { ApiInterface } from 'src/api'; | 7 | import { ApiInterface } from 'src/api'; |
8 | import { Actions } from 'src/actions/lib/actions'; | 8 | import { Actions } from 'src/actions/lib/actions'; |
9 | import { Stores } from 'src/stores.types'; | 9 | import { Stores } from 'src/@types/stores.types'; |
10 | import { TODOS_PARTITION_ID } from '../config'; | 10 | import { TODOS_PARTITION_ID } from '../config'; |
11 | import { isDevMode } from '../environment-remote'; | 11 | import { isDevMode } from '../environment-remote'; |
12 | import Request from './lib/Request'; | 12 | import 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 @@ | |||
1 | import { Stores } from 'src/stores.types'; | ||
2 | import { RouterStore } from 'mobx-react-router'; | 1 | import { RouterStore } from 'mobx-react-router'; |
3 | import { ApiInterface } from 'src/api'; | 2 | import { ApiInterface } from 'src/api'; |
4 | import { Actions } from 'src/actions/lib/actions'; | 3 | import { Actions } from 'src/actions/lib/actions'; |
@@ -16,12 +15,29 @@ import { workspaceStore } from '../features/workspaces'; | |||
16 | import { communityRecipesStore } from '../features/communityRecipes'; | 15 | import { communityRecipesStore } from '../features/communityRecipes'; |
17 | import { todosStore } from '../features/todos'; | 16 | import { todosStore } from '../features/todos'; |
18 | 17 | ||
18 | export 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 | |||
19 | export default ( | 35 | export 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 @@ | |||
1 | import { computed, IReactionPublic, observable } from 'mobx'; | 1 | import { computed, IReactionPublic, observable } from 'mobx'; |
2 | import { Actions } from 'src/actions/lib/actions'; | 2 | import { Actions } from 'src/actions/lib/actions'; |
3 | import { ApiInterface } from 'src/api'; | 3 | import { ApiInterface } from 'src/api'; |
4 | import { Stores } from 'src/stores.types'; | 4 | import { Stores } from 'src/@types/stores.types'; |
5 | import Reaction from './Reaction'; | 5 | import Reaction from './Reaction'; |
6 | 6 | ||
7 | export default abstract class TypedStore { | 7 | export default abstract class TypedStore { |