Skip to content
Snippets Groups Projects
Commit 3a77388f authored by Evelyn Eastmond's avatar Evelyn Eastmond
Browse files

Cleanup for react container/component pattern for alerts/alert containers and components.

parent 40394eb5
Branches
Tags
No related merge requests found
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import Box from '../box/box.jsx';
import Alert from '../../containers/alert.jsx';
const AlertsComponent = ({
alertsList,
className,
onCloseAlert
}) => (
<Box
bounds="parent"
className={classNames(className)}
>
{alertsList.map((a, index) => (
<Alert
iconURL={a.iconURL}
index={index}
key={index}
message={a.message}
onCloseAlert={onCloseAlert}
/>
))}
</Box>
);
AlertsComponent.propTypes = {
alertsList: PropTypes.arrayOf(PropTypes.object),
className: PropTypes.string,
onCloseAlert: PropTypes.func
};
export default AlertsComponent;
......@@ -15,11 +15,17 @@ class Alert extends React.Component {
this.props.onCloseAlert(this.props.index);
}
render () {
const {
index, // eslint-disable-line no-unused-vars
onCloseAlert,
iconURL,
message
} = this.props;
return (
<AlertComponent
iconURL={this.props.iconURL}
message={this.props.message}
onCloseAlert={this.handleOnCloseAlert}
iconURL={iconURL}
message={message}
onCloseAlert={onCloseAlert}
/>
);
}
......
import classNames from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';
import {connect} from 'react-redux';
......@@ -7,28 +6,18 @@ import {
closeAlert
} from '../reducers/alerts';
import Box from '../components/box/box.jsx';
import Alert from '../containers/alert.jsx';
import AlertsComponent from '../components/alerts/alerts.jsx';
const Alerts = ({
alertsList,
className,
onCloseAlert
}) => (
<Box
bounds="parent"
className={classNames(className)}
>
{alertsList.map((a, index) => (
<Alert
iconURL={a.iconURL}
index={index}
key={index}
message={a.message}
onCloseAlert={onCloseAlert}
/>
))}
</Box>
<AlertsComponent
alertsList={alertsList}
className={className}
onCloseAlert={onCloseAlert}
/>
);
Alerts.propTypes = {
......
......@@ -59,7 +59,9 @@ const closeAlert = function (index) {
/**
* Function to show an alert with the given input data.
*
* @param {object} data - data with the following props: {message, extensionId=null}
* @param {object} data - data for the alert
* @param {string} data.message - message for the alert
* @param {string} data.extensionId - extension ID for the alert
* @return {object} - an object to be passed to the reducer.
*/
const showAlert = function (data) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment