Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame^] | 1 | import React from 'react'; |
| 2 | import Button from 'react-bootstrap/lib/Button.js'; |
| 3 | |
| 4 | import i18n from 'nfvo-utils/i18n/i18n.js'; |
| 5 | import Modal from 'nfvo-components/modal/Modal.jsx'; |
| 6 | |
| 7 | let typeClass = { |
| 8 | 'default': 'primary', |
| 9 | error: 'danger', |
| 10 | warning: 'warning', |
| 11 | success: 'success' |
| 12 | }; |
| 13 | |
| 14 | |
| 15 | class ConfirmationModalView extends React.Component { |
| 16 | |
| 17 | static propTypes = { |
| 18 | show: React.PropTypes.bool, |
| 19 | type: React.PropTypes.oneOf(['default', 'error', 'warning', 'success']), |
| 20 | msg: React.PropTypes.node, |
| 21 | title: React.PropTypes.string, |
| 22 | confirmationDetails: React.PropTypes.object, |
| 23 | confirmationButtonText: React.PropTypes.string, |
| 24 | |
| 25 | }; |
| 26 | |
| 27 | static defaultProps = { |
| 28 | show: false, |
| 29 | type: 'warning', |
| 30 | title: 'Warning', |
| 31 | msg: '', |
| 32 | confirmationButtonText: i18n('Delete') |
| 33 | }; |
| 34 | |
| 35 | render() { |
| 36 | let {title, type, msg, show, confirmationButtonText} = this.props; |
| 37 | |
| 38 | return( |
| 39 | <Modal show={show} className={`notification-modal ${typeClass[type]}`}> |
| 40 | <Modal.Header> |
| 41 | <Modal.Title>{title}</Modal.Title> |
| 42 | </Modal.Header> |
| 43 | <Modal.Body>{msg}</Modal.Body> |
| 44 | <Modal.Footer> |
| 45 | <Button bsStyle={typeClass[type]} onClick={() => this.props.onDeclined(this.props.confirmationDetails)}>{i18n('Cancel')}</Button> |
| 46 | <Button bsStyle={typeClass[type]} onClick={() => this.props.onConfirmed(this.props.confirmationDetails)}>{confirmationButtonText}</Button> |
| 47 | </Modal.Footer> |
| 48 | </Modal> |
| 49 | ); |
| 50 | }; |
| 51 | } |
| 52 | |
| 53 | export default ConfirmationModalView; |