70 lines
1.9 KiB
JavaScript
Raw Normal View History

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';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
2017-03-18 17:34:00 +01:00
import { createStructuredSelector } from 'reselect';
import { Switch, Route } from 'react-router-dom';
2017-10-23 16:12:37 +02:00
import { bindActionCreators, compose } from 'redux';
2017-10-25 18:49:29 +02:00
// Utils
import { pluginId } from 'app';
// Containers
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-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}>
<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} />
</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,
router: PropTypes.object.isRequired,
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
const withConnect = connect(mapStateToProps, mapDispatchToProps);
export default compose(
withConnect,
)(App);