From 0b52e85ba73e5b3badeb1703462c5d05d3a7d224 Mon Sep 17 00:00:00 2001
From: hmhealey <harrisonmhealey@gmail.com>
Date: Tue, 10 Nov 2015 10:20:16 -0500
Subject: Added Modal base class that extends ReactBootstrap.Modal

---
 web/react/components/modal.jsx | 48 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 web/react/components/modal.jsx

(limited to 'web/react/components/modal.jsx')

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
+};
-- 
cgit v1.2.3-1-g7c22

