diff --git a/src/components/alerts/alerts.jsx b/src/components/alerts/alerts.jsx index 88e690cb31a67e61958af4192320fcf61e675777..1835a50a820e7de90443449ecec60c54f33779f5 100644 --- a/src/components/alerts/alerts.jsx +++ b/src/components/alerts/alerts.jsx @@ -3,13 +3,11 @@ import PropTypes from 'prop-types'; import Box from '../box/box.jsx'; import Alert from '../../containers/alert.jsx'; -import VM from 'scratch-vm'; const AlertsComponent = ({ alertsList, className, - onCloseAlert, - vm + onCloseAlert }) => ( <Box bounds="parent" @@ -21,7 +19,6 @@ const AlertsComponent = ({ index={index} key={index} message={a.message} - vm={vm} onCloseAlert={onCloseAlert} /> ))} @@ -31,8 +28,7 @@ const AlertsComponent = ({ AlertsComponent.propTypes = { alertsList: PropTypes.arrayOf(PropTypes.object), className: PropTypes.string, - onCloseAlert: PropTypes.func, - vm: PropTypes.instanceOf(VM).isRequired + onCloseAlert: PropTypes.func }; export default AlertsComponent; diff --git a/src/containers/alert.jsx b/src/containers/alert.jsx index 8413998aaa765d4d03e0579655c4fcfc191b8f43..fe2fed13ae05e6bcd61244a505880114ffdeb72d 100644 --- a/src/containers/alert.jsx +++ b/src/containers/alert.jsx @@ -2,7 +2,6 @@ import React from 'react'; import bindAll from 'lodash.bindall'; import PropTypes from 'prop-types'; import {connect} from 'react-redux'; -import VM from 'scratch-vm'; import AlertComponent from '../components/alerts/alert.jsx'; import {openConnectionModal} from '../reducers/modals'; @@ -12,15 +11,16 @@ class Alert extends React.Component { constructor (props) { super(props); bindAll(this, [ - 'handleOnCloseAlert' + 'handleOnCloseAlert', + 'handleOnReconnect' ]); } handleOnCloseAlert () { this.props.onCloseAlert(this.props.index); } handleOnReconnect () { - // this.props.vm.emit('') - console.log('hello'); + this.props.onOpenConnectionModal('ev3') + console.log('handleOnReconnect'); } render () { const { @@ -39,6 +39,10 @@ class Alert extends React.Component { } } +const mapStateToProps = state => ({ + state: state +}); + const mapDispatchToProps = dispatch => ({ onOpenConnectionModal: id => { dispatch(setConnectionModalExtensionId(id)); @@ -51,10 +55,10 @@ Alert.propTypes = { index: PropTypes.number, message: PropTypes.string, onCloseAlert: PropTypes.func.isRequired, - onOpenConnectionModal: PropTypes.func, - vm: PropTypes.instanceOf(VM).isRequired + onOpenConnectionModal: PropTypes.func }; export default connect( + mapStateToProps, mapDispatchToProps -)(Alerts); +)(Alert); diff --git a/src/containers/alerts.jsx b/src/containers/alerts.jsx index f75046d1388d671da67a6a3a2bf56a38d1b4e010..21a17700a8a8a7fd76f83f55d227fb803f372388 100644 --- a/src/containers/alerts.jsx +++ b/src/containers/alerts.jsx @@ -1,7 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; import {connect} from 'react-redux'; -import VM from 'scratch-vm'; import { closeAlert @@ -12,13 +11,11 @@ import AlertsComponent from '../components/alerts/alerts.jsx'; const Alerts = ({ alertsList, className, - onCloseAlert, - vm + onCloseAlert }) => ( <AlertsComponent alertsList={alertsList} className={className} - vm={vm} onCloseAlert={onCloseAlert} /> ); @@ -26,8 +23,7 @@ const Alerts = ({ Alerts.propTypes = { alertsList: PropTypes.arrayOf(PropTypes.object), className: PropTypes.string, - onCloseAlert: PropTypes.func, - vm: PropTypes.instanceOf(VM).isRequired + onCloseAlert: PropTypes.func }; const mapStateToProps = state => ({