1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
import { Component } from 'react';
import PropTypes from 'prop-types';
import { inject, observer } from 'mobx-react';
import { ThemeProvider } from 'react-jss';
import AuthLayout from '../../components/auth/AuthLayout';
import AppStore from '../../stores/AppStore';
import UserStore from '../../stores/UserStore';
import GlobalErrorStore from '../../stores/GlobalErrorStore';
import UIStore from '../../stores/UIStore';
import SettingsStore from '../../stores/SettingsStore';
import AppLoader from '../../components/ui/AppLoader';
import { oneOrManyChildElements } from '../../prop-types';
import FeaturesStore from '../../stores/FeaturesStore';
class AuthLayoutContainer extends Component {
static propTypes = {
children: oneOrManyChildElements.isRequired,
location: PropTypes.shape({
pathname: PropTypes.string.isRequired,
}).isRequired,
};
render() {
const { stores, actions, children, location } = this.props;
const { app, features, globalError, user } = stores;
const isLoadingBaseFeatures =
features.defaultFeaturesRequest.isExecuting &&
!features.defaultFeaturesRequest.wasExecuted;
if (isLoadingBaseFeatures) {
return (
<ThemeProvider theme={stores.ui.theme}>
<AppLoader />
</ThemeProvider>
);
}
const { isLoggingOut } = user;
if (isLoggingOut) {
return (
<ThemeProvider theme={stores.ui.theme}>
<AppLoader texts={['Logging you out...']} />
</ThemeProvider>
);
}
return (
<ThemeProvider theme={stores.ui.theme}>
<AuthLayout
error={globalError.response}
pathname={location.pathname}
isOnline={app.isOnline}
isAPIHealthy={!app.healthCheckRequest.isError}
retryHealthCheck={actions.app.healthCheck}
isHealthCheckLoading={app.healthCheckRequest.isExecuting}
isFullScreen={app.isFullScreen}
installAppUpdate={actions.app.installUpdate}
appUpdateIsDownloaded={
app.updateStatus === app.updateStatusTypes.DOWNLOADED
}
>
{children}
</AuthLayout>
</ThemeProvider>
);
}
}
AuthLayoutContainer.propTypes = {
stores: PropTypes.shape({
app: PropTypes.instanceOf(AppStore).isRequired,
features: PropTypes.instanceOf(FeaturesStore).isRequired,
globalError: PropTypes.instanceOf(GlobalErrorStore).isRequired,
user: PropTypes.instanceOf(UserStore).isRequired,
ui: PropTypes.instanceOf(UIStore).isRequired,
}).isRequired,
actions: PropTypes.shape({
app: PropTypes.instanceOf(AppStore).isRequired,
settings: PropTypes.instanceOf(SettingsStore).isRequired,
}).isRequired,
};
export default inject('stores', 'actions')(observer(AuthLayoutContainer));
|