2017-01-17 13:40:59 +01:00
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* This component is the skeleton around the actual pages, and should only
|
|
|
|
|
* contain code that should be seen on all pages. (e.g. navigation bar)
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import React from 'react';
|
2017-09-20 11:12:04 +02:00
|
|
|
import PropTypes from 'prop-types';
|
2017-05-11 14:17:21 +02:00
|
|
|
import { connect } from 'react-redux';
|
2017-03-18 17:34:00 +01:00
|
|
|
import { createStructuredSelector } from 'reselect';
|
2017-08-22 17:57:54 +02:00
|
|
|
import { Switch, Route } from 'react-router-dom';
|
2017-10-23 16:12:37 +02:00
|
|
|
import { bindActionCreators, compose } from 'redux';
|
2017-08-22 17:57:54 +02:00
|
|
|
|
2017-10-25 18:49:29 +02:00
|
|
|
// Utils
|
2019-02-11 18:35:46 +01:00
|
|
|
import pluginId from 'pluginId';
|
2017-10-25 18:49:29 +02:00
|
|
|
|
|
|
|
|
// Containers
|
2017-08-22 17:57:54 +02:00
|
|
|
import HomePage from 'containers/HomePage';
|
2017-10-25 18:49:29 +02:00
|
|
|
import NotFoundPage from 'containers/NotFoundPage';
|
|
|
|
|
// When you're done studying the ExamplePage container, remove the following line and delete the ExamplePage container
|
|
|
|
|
import ExamplePage from 'containers/ExamplePage';
|
2017-08-22 17:57:54 +02:00
|
|
|
|
2019-02-11 18:35:46 +01:00
|
|
|
import reducer from './reducer';
|
2017-01-17 13:40:59 +01:00
|
|
|
|
2017-05-11 10:54:44 +02:00
|
|
|
class App extends React.Component {
|
2017-10-25 18:49:29 +02:00
|
|
|
// When you're done studying the ExamplePage container, remove the following lines and delete the ExamplePage container
|
|
|
|
|
componentDidMount() {
|
|
|
|
|
this.props.history.push(`/plugins/${pluginId}/example`);
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-17 13:40:59 +01:00
|
|
|
render() {
|
|
|
|
|
return (
|
2017-06-08 17:16:20 +01:00
|
|
|
<div className={pluginId}>
|
2017-08-22 17:57:54 +02:00
|
|
|
<Switch>
|
2017-10-25 18:49:29 +02:00
|
|
|
<Route path={`/plugins/${pluginId}`} component={HomePage} exact />
|
|
|
|
|
{/* When you're done studying the ExamplePage container, remove the following line and delete the ExamplePage container */}
|
|
|
|
|
<Route path={`/plugins/${pluginId}/example`} component={ExamplePage} exact />
|
|
|
|
|
<Route component={NotFoundPage} />
|
2017-08-22 17:57:54 +02:00
|
|
|
</Switch>
|
2017-03-18 17:34:00 +01:00
|
|
|
</div>
|
2017-01-17 13:40:59 +01:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-03-18 17:34:00 +01:00
|
|
|
|
2017-10-23 16:12:37 +02:00
|
|
|
App.contextTypes = {
|
|
|
|
|
plugins: PropTypes.object,
|
|
|
|
|
updatePlugin: PropTypes.func,
|
2017-03-18 17:34:00 +01:00
|
|
|
};
|
|
|
|
|
|
2017-10-25 18:49:29 +02:00
|
|
|
App.propTypes = {
|
|
|
|
|
history: PropTypes.object.isRequired,
|
|
|
|
|
};
|
2017-10-23 16:12:37 +02:00
|
|
|
|
2017-03-18 17:34:00 +01:00
|
|
|
export function mapDispatchToProps(dispatch) {
|
2017-10-23 16:12:37 +02:00
|
|
|
return bindActionCreators(
|
|
|
|
|
{},
|
2017-03-18 17:34:00 +01:00
|
|
|
dispatch,
|
2017-10-23 16:12:37 +02:00
|
|
|
);
|
2017-03-18 17:34:00 +01:00
|
|
|
}
|
|
|
|
|
|
2017-06-08 17:16:20 +01:00
|
|
|
const mapStateToProps = createStructuredSelector({});
|
2017-03-18 17:34:00 +01:00
|
|
|
|
|
|
|
|
// Wrap the component to inject dispatch and state into it
|
2017-08-22 17:57:54 +02:00
|
|
|
const withConnect = connect(mapStateToProps, mapDispatchToProps);
|
2019-02-11 18:35:46 +01:00
|
|
|
const withReducer = strapi.injectReducer({ key: 'global', reducer, pluginId });
|
2017-08-22 17:57:54 +02:00
|
|
|
|
|
|
|
|
export default compose(
|
2019-02-11 18:35:46 +01:00
|
|
|
withReducer,
|
2017-08-22 17:57:54 +02:00
|
|
|
withConnect,
|
2017-09-20 11:12:04 +02:00
|
|
|
)(App);
|