summaryrefslogtreecommitdiffstats
path: root/web/react/components/modal.jsx
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2015-11-10 10:20:16 -0500
committerhmhealey <harrisonmhealey@gmail.com>2015-11-17 11:04:31 -0500
commit0b52e85ba73e5b3badeb1703462c5d05d3a7d224 (patch)
tree0f224748c20bae18af12c3abd76a29ca6a1c1bc4 /web/react/components/modal.jsx
parent1d7c44919237f424cfd65157cc08bff42753fd0f (diff)
downloadchat-0b52e85ba73e5b3badeb1703462c5d05d3a7d224.tar.gz
chat-0b52e85ba73e5b3badeb1703462c5d05d3a7d224.tar.bz2
chat-0b52e85ba73e5b3badeb1703462c5d05d3a7d224.zip
Added Modal base class that extends ReactBootstrap.Modal
Diffstat (limited to 'web/react/components/modal.jsx')
-rw-r--r--web/react/components/modal.jsx48
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
+};