Files
scratch-gui/src/containers/monitor-list.jsx
T
chrisgarrity 44c76e5774 Combine GUI reducers
* Export initial states for each reducer
* combine all gui reducers (excludes scratchPaint and intl)
* combine all initial states to create default guiState for preloading in www
* expect all of the gui state to be accessible at `state.scratchGui`
2018-05-21 16:54:19 -04:00

48 lines
1.2 KiB
React

import bindAll from 'lodash.bindall';
import React from 'react';
import PropTypes from 'prop-types';
import {connect} from 'react-redux';
import {moveMonitorRect} from '../reducers/monitor-layout';
import errorBoundaryHOC from '../lib/error-boundary-hoc.jsx';
import MonitorListComponent from '../components/monitor-list/monitor-list.jsx';
class MonitorList extends React.Component {
constructor (props) {
super(props);
bindAll(this, [
'handleMonitorChange'
]);
}
handleMonitorChange (id, x, y) { // eslint-disable-line no-unused-vars
this.props.moveMonitorRect(id, x, y);
}
render () {
return (
<MonitorListComponent
onMonitorChange={this.handleMonitorChange}
{...this.props}
/>
);
}
}
MonitorList.propTypes = {
moveMonitorRect: PropTypes.func.isRequired
};
const mapStateToProps = state => ({
monitors: state.scratchGui.monitors
});
const mapDispatchToProps = dispatch => ({
moveMonitorRect: (id, x, y) => dispatch(moveMonitorRect(id, x, y))
});
export default errorBoundaryHOC('Monitors')(
connect(
mapStateToProps,
mapDispatchToProps
)(MonitorList)
);