mirror of
https://github.com/strapi/strapi.git
synced 2026-01-08 05:04:10 +00:00
Fixes #2213
This commit is contained in:
parent
20ee8f9e1e
commit
b06997014a
File diff suppressed because one or more lines are too long
@ -14,14 +14,12 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Switch, Route } from 'react-router-dom';
|
||||
|
||||
import AdminPage from 'containers/AdminPage';
|
||||
import NotFoundPage from 'containers/NotFoundPage';
|
||||
|
||||
import NotificationProvider from 'containers/NotificationProvider';
|
||||
|
||||
import AppLoader from 'containers/AppLoader';
|
||||
import LoadingIndicatorPage from 'components/LoadingIndicatorPage';
|
||||
import '../../styles/main.scss';
|
||||
|
||||
import styles from './styles.scss';
|
||||
|
||||
export class App extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
||||
@ -29,12 +27,22 @@ export class App extends React.Component { // eslint-disable-line react/prefer-s
|
||||
return (
|
||||
<div>
|
||||
<NotificationProvider />
|
||||
<div className={styles.container}>
|
||||
<Switch>
|
||||
<Route path="/" component={AdminPage} />
|
||||
<Route path="" component={NotFoundPage} />
|
||||
</Switch>
|
||||
</div>
|
||||
<AppLoader>
|
||||
{({ shouldLoad }) => {
|
||||
if (shouldLoad) {
|
||||
return <LoadingIndicatorPage />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
<Switch>
|
||||
<Route path="/" component={AdminPage} />
|
||||
<Route path="" component={NotFoundPage} />
|
||||
</Switch>
|
||||
</div>
|
||||
);
|
||||
}}
|
||||
</AppLoader>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@ -14,6 +14,11 @@ const selectPlugins = () => createSelector(
|
||||
(appState) => appState.get('plugins')
|
||||
);
|
||||
|
||||
const makeSelectApp = () => createSelector(
|
||||
selectApp(),
|
||||
appState => appState.toJS(),
|
||||
);
|
||||
|
||||
const selectHasUserPlugin = () => createSelector(
|
||||
selectApp(),
|
||||
(appState) => appState.get('hasUserPlugin'),
|
||||
@ -38,7 +43,7 @@ const makeSelectAppPlugins = () => createSelector(
|
||||
selectApp(),
|
||||
appState => appState.get('appPlugins').toJS(),
|
||||
);
|
||||
|
||||
export default makeSelectApp;
|
||||
export {
|
||||
selectApp,
|
||||
selectHasUserPlugin,
|
||||
|
||||
@ -0,0 +1,31 @@
|
||||
/**
|
||||
*
|
||||
* AppLoader
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import PropTypes from 'prop-types';
|
||||
import makeSelectApp from 'containers/App/selectors';
|
||||
|
||||
class AppLoader extends React.Component {
|
||||
shouldLoad = () => {
|
||||
const { appPlugins, plugins: mountedPlugins } = this.props;
|
||||
|
||||
return appPlugins.length !== Object.keys(mountedPlugins).length;
|
||||
}
|
||||
render() {
|
||||
return this.props.children({ shouldLoad: this.shouldLoad() });
|
||||
}
|
||||
}
|
||||
|
||||
AppLoader.propTypes = {
|
||||
appPlugins: PropTypes.array.isRequired,
|
||||
children: PropTypes.func.isRequired,
|
||||
plugins: PropTypes.object.isRequired,
|
||||
};
|
||||
|
||||
const mapStateToProps = makeSelectApp();
|
||||
|
||||
export default connect(mapStateToProps, null)(AppLoader);
|
||||
@ -51,4 +51,4 @@
|
||||
"npm": ">= 5.0.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user