import React from 'react'; import { Modal, Button } from 'react-bootstrap'; export default class MessageDlg extends React.Component { constructor(props) { super(props); this.yesClick = this.yesClick.bind(this); this.noClick = this.noClick.bind(this); this.okClick = this.okClick.bind(this); this.cancelClick = this.cancelClick.bind(this); } createButtons() { switch (this.props.type) { case 'YesNo': return (

); default: return (

); } } yesClick() { this.close('yes'); } cancelClick() { this.close('cancel'); } noClick() { this.close('no'); } okClick() { this.close('ok'); } close(evt) { if (this.props.onClose) { this.props.onClose(evt); } } render() { const buttons = this.createButtons(); let icon = 'fa fa-4x fa-'; let icondiv = 'circle-5x'; switch (this.props.style) { case 'danger': icon += 'exclamation'; icondiv += ' bg-danger text-danger'; break; case 'warning': icon += 'exclamation-triangle'; icondiv += ' bg-warning text-warning'; break; default: icon += 'info'; icondiv += ' bg-info text-info'; } return ( {this.props.title}

{this.props.message}

{buttons}
); } } MessageDlg.propTypes = { show: React.PropTypes.bool, title: React.PropTypes.string, message: React.PropTypes.string, style: React.PropTypes.oneOf(['info', 'danger', 'warning']), type: React.PropTypes.oneOf(['YesNo', 'Ok']), onClose: React.PropTypes.func, size: React.PropTypes.string }; MessageDlg.defaultProps = { show: false, style: 'info', type: 'Ok' };