diff options
Diffstat (limited to 'web/react/components/modal.jsx')
-rw-r--r-- | web/react/components/modal.jsx | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/web/react/components/modal.jsx b/web/react/components/modal.jsx new file mode 100644 index 000000000..758a68847 --- /dev/null +++ b/web/react/components/modal.jsx @@ -0,0 +1,48 @@ +// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +export default class Modal extends ReactBootstrap.Modal { + constructor(props) { + super(props); + } + + componentWillMount() { + if (this.props.show && this.props.onPreshow) { + this.props.onPreshow(); + } + } + + componentDidMount() { + super.componentDidMount(); + + if (this.props.show && this.props.onShow) { + this.props.onShow(); + } + } + + componentDidUpdate(prevProps) { + super.componentDidUpdate(prevProps); + + if (this.props.show && !prevProps.show && this.props.onShow) { + this.props.onShow(); + } + } + + componentWillReceiveProps(nextProps) { + super.componentWillReceiveProps(nextProps); + + if (nextProps.show && !this.props.show && this.props.onPreshow) { + this.props.onPreshow(); + } + } +} + +Modal.propTypes = { + ...ReactBootstrap.Modal.propTypes, + + // called before showing the dialog to allow for a state change before rendering + onPreshow: React.PropTypes.func, + + // called after the dialog has been shown and rendered + onShow: React.PropTypes.func +}; |