59 lines
1.4 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';
2017-03-18 17:34:00 +01:00
import { createStructuredSelector } from 'reselect';
import { loadModels } from './actions';
import { makeSelectModels } from './selectors';
import { connect } from 'react-redux';
2017-01-17 13:40:59 +01:00
import '../../styles/main.scss';
2017-03-18 17:34:00 +01:00
class App extends React.Component { // eslint-disable-line react/prefer-stateless-function
componentWillMount() {
this.props.loadModels();
}
2017-01-17 13:40:59 +01:00
render() {
// Assign plugin component to children
const childrenWithProps = React.Children.map(this.props.children,
(child) => React.cloneElement(child, {
2017-03-15 11:48:56 +01:00
exposedComponents: this.props.exposedComponents
})
);
2017-01-17 13:40:59 +01:00
return (
2017-03-18 17:34:00 +01:00
<div className='content-manager'>
{React.Children.toArray(childrenWithProps)}
</div>
2017-01-17 13:40:59 +01:00
);
}
}
2017-03-18 17:34:00 +01:00
2017-04-11 15:38:15 +02:00
App.contextTypes = {
router: React.PropTypes.object.isRequired,
};
2017-03-18 17:34:00 +01:00
App.propTypes = {
children: React.PropTypes.node,
loadModels: React.PropTypes.func,
};
export function mapDispatchToProps(dispatch) {
return {
loadModels: () => dispatch(loadModels()),
dispatch,
};
}
const mapStateToProps = createStructuredSelector({
models: makeSelectModels(),
});
// Wrap the component to inject dispatch and state into it
export default connect(mapStateToProps, mapDispatchToProps)(App);