Spaces:
Running
Running
File size: 1,221 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 |
import React from 'react';
import PropTypes from 'prop-types';
import {connect} from 'react-redux';
import {
filterInlineAlerts
} from '../reducers/alerts';
import InlineMessageComponent from '../components/alerts/inline-message.jsx';
const InlineMessages = ({
alertsList,
className
}) => {
if (!alertsList) {
return null;
}
// only display inline alerts here
const inlineAlerts = filterInlineAlerts(alertsList);
if (!inlineAlerts || !inlineAlerts.length) {
return null;
}
// get first alert
const firstInlineAlert = inlineAlerts[0];
const {
content,
iconSpinner,
level
} = firstInlineAlert;
return (
<InlineMessageComponent
className={className}
content={content}
iconSpinner={iconSpinner}
level={level}
/>
);
};
InlineMessages.propTypes = {
alertsList: PropTypes.arrayOf(PropTypes.object),
className: PropTypes.string
};
const mapStateToProps = state => ({
alertsList: state.scratchGui.alerts.alertsList
});
const mapDispatchToProps = () => ({});
export default connect(
mapStateToProps,
mapDispatchToProps
)(InlineMessages);
|