Spaces:
Running
Running
File size: 2,957 Bytes
6bcb42f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
import React from 'react';
import bindAll from 'lodash.bindall';
import PropTypes from 'prop-types';
import {connect} from 'react-redux';
import SB3Downloader from './sb3-downloader.jsx';
import AlertComponent from '../components/alerts/alert.jsx';
import {openConnectionModal} from '../reducers/modals';
import {setConnectionModalExtensionId} from '../reducers/connection-modal';
import {manualUpdateProject} from '../reducers/project-state';
class Alert extends React.Component {
constructor (props) {
super(props);
bindAll(this, [
'handleOnCloseAlert',
'handleOnReconnect'
]);
}
handleOnCloseAlert () {
this.props.onCloseAlert(this.props.index);
}
handleOnReconnect () {
this.props.onOpenConnectionModal(this.props.extensionId);
this.handleOnCloseAlert();
}
render () {
const {
closeButton,
content,
extensionName,
index, // eslint-disable-line no-unused-vars
level,
iconSpinner,
iconURL,
message,
onSaveNow,
showDownload,
showReconnect,
showSaveNow
} = this.props;
return (
<SB3Downloader>{(_, downloadProject) => (
<AlertComponent
closeButton={closeButton}
content={content}
extensionName={extensionName}
iconSpinner={iconSpinner}
iconURL={iconURL}
level={level}
message={message}
showDownload={showDownload}
showReconnect={showReconnect}
showSaveNow={showSaveNow}
onCloseAlert={this.handleOnCloseAlert}
onDownload={downloadProject}
onReconnect={this.handleOnReconnect}
onSaveNow={onSaveNow}
/>
)}</SB3Downloader>
);
}
}
const mapStateToProps = () => ({});
const mapDispatchToProps = dispatch => ({
onOpenConnectionModal: id => {
dispatch(setConnectionModalExtensionId(id));
dispatch(openConnectionModal());
},
onSaveNow: () => {
dispatch(manualUpdateProject());
}
});
Alert.propTypes = {
closeButton: PropTypes.bool,
content: PropTypes.element,
extensionId: PropTypes.string,
extensionName: PropTypes.string,
iconSpinner: PropTypes.bool,
iconURL: PropTypes.string,
index: PropTypes.number,
level: PropTypes.string.isRequired,
message: PropTypes.string,
onCloseAlert: PropTypes.func.isRequired,
onOpenConnectionModal: PropTypes.func,
onSaveNow: PropTypes.func,
showDownload: PropTypes.bool,
showReconnect: PropTypes.bool,
showSaveNow: PropTypes.bool
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(Alert);
|