'use strict'; import React from 'react'; import ReactAddons from 'react/addons'; import Modal from 'react-bootstrap/lib/Modal'; import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger'; import ModalTrigger from 'react-bootstrap/lib/ModalTrigger'; import Tooltip from 'react-bootstrap/lib/Tooltip'; import ModalMixin from '../../mixins/modal_mixin'; let ModalWrapper = React.createClass({ propTypes: { title: React.PropTypes.string.isRequired, onRequestHide: React.PropTypes.func, handleSuccess: React.PropTypes.func.isRequired, button: React.PropTypes.object.isRequired, children: React.PropTypes.object, tooltip: React.PropTypes.string }, getModalTrigger() { return ( {this.props.children} }> {this.props.button} ); }, render() { if(this.props.tooltip) { return ( {this.props.tooltip}}> {this.getModalTrigger()} ); } else { return ( {/* This needs to be some kind of inline-block */} {this.getModalTrigger()} ); } } }); let ModalBody = React.createClass({ propTypes: { onRequestHide: React.PropTypes.func, handleSuccess: React.PropTypes.func, children: React.PropTypes.object, title: React.PropTypes.string.isRequired }, mixins: [ModalMixin], handleSuccess(response){ this.props.handleSuccess(response); this.props.onRequestHide(); }, renderChildren() { return ReactAddons.Children.map(this.props.children, (child) => { return ReactAddons.addons.cloneWithProps(child, { onRequestHide: this.props.onRequestHide, handleSuccess: this.handleSuccess }); }); }, render() { return (
{this.renderChildren()}
); } }); export default ModalWrapper;