All files / javascripts/SqlLab/components Alerts.jsx

87.5% Statements 7/8
100% Branches 0/0
100% Functions 1/1
85.71% Lines 6/7
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 351x 1x           1x 1x                           1x           1x            
import React from 'react';
import { Alert } from 'react-bootstrap';
 
class Alerts extends React.PureComponent {
  removeAlert(alert) {
    this.props.actions.removeAlert(alert);
  }
  render() {
    const alerts = this.props.alerts.map((alert) =>
      <Alert
        key={alert.id}
        bsStyle={alert.bsStyle}
        style={{ width: '500px', textAlign: 'midddle', margin: '10px auto' }}
      >
        {alert.msg}
        <i
          className="fa fa-close pull-right"
          onClick={this.removeAlert.bind(this, alert)}
          style={{ cursor: 'pointer' }}
        />
      </Alert>
    );
    return (
      <div>{alerts}</div>
    );
  }
}
 
Alerts.propTypes = {
  alerts: React.PropTypes.array,
  actions: React.PropTypes.object,
};
 
export default Alerts;