From a24ad3b77422ff096ea52a0270771e637757d2d1 Mon Sep 17 00:00:00 2001 From: Brett Sun Date: Fri, 15 Jan 2016 17:55:34 +0100 Subject: [PATCH] Add handleCancel callback to ModalWrapper --- js/components/ascribe_modal/modal_wrapper.js | 21 ++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/js/components/ascribe_modal/modal_wrapper.js b/js/components/ascribe_modal/modal_wrapper.js index 94000942..511e7f8c 100644 --- a/js/components/ascribe_modal/modal_wrapper.js +++ b/js/components/ascribe_modal/modal_wrapper.js @@ -6,13 +6,15 @@ import Modal from 'react-bootstrap/lib/Modal'; let ModalWrapper = React.createClass({ propTypes: { - trigger: React.PropTypes.element, title: React.PropTypes.oneOfType([ React.PropTypes.arrayOf(React.PropTypes.element), React.PropTypes.element, React.PropTypes.string ]).isRequired, - handleSuccess: React.PropTypes.func.isRequired, + + handleCancel: React.PropTypes.func, + handleSuccess: React.PropTypes.func, + trigger: React.PropTypes.element, children: React.PropTypes.oneOfType([ React.PropTypes.arrayOf(React.PropTypes.element), React.PropTypes.element @@ -37,8 +39,19 @@ let ModalWrapper = React.createClass({ }); }, + handleCancel() { + if (typeof this.props.handleCancel === 'function') { + this.props.handleCancel(); + } + + this.hide(); + }, + handleSuccess(response) { - this.props.handleSuccess(response); + if (typeof this.props.handleSuccess === 'function') { + this.props.handleSuccess(response); + } + this.hide(); }, @@ -75,7 +88,7 @@ let ModalWrapper = React.createClass({ return ( {clonedTrigger} - + {title}