From ed70db18611331de99b2a86b580947e56d0cb7e5 Mon Sep 17 00:00:00 2001
From: nickago <ngonella@calpoly.edu>
Date: Wed, 22 Jul 2015 15:12:50 -0700
Subject: When user is removed, a modal appears, which on closing redirects the
 user to town square.

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

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

diff --git a/web/react/components/removed_from_channel_modal.jsx b/web/react/components/removed_from_channel_modal.jsx
new file mode 100644
index 000000000..3a5a58d5e
--- /dev/null
+++ b/web/react/components/removed_from_channel_modal.jsx
@@ -0,0 +1,45 @@
+// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+var ChannelStore = require('../stores/channel_store.jsx');
+var UserStore = require('../stores/user_store.jsx');
+var utils = require('../utils/utils.jsx');
+
+module.exports = React.createClass({
+    handleClose: function() {
+      var townSquare = ChannelStore.getByName("town-square");
+      utils.switchChannel(townSquare);
+    },
+    componentDidMount: function() {
+      $(this.getDOMNode()).on('hidden.bs.modal',this.handleClose);
+    },
+    componentWillUnmount: function() {
+      $(this.getDOMNode()).off('hidden.bs.modal',this.handleClose);
+    },
+    render: function() {
+        currentUser = UserStore.getCurrentUser();
+
+        if (currentUser != null) {
+            return (
+                <div className="modal fade" ref="modal" id="removed_from_channel" tabIndex="-1" role="dialog" aria-hidden="true">
+                   <div className="modal-dialog">
+                      <div className="modal-content">
+                        <div className="modal-header">
+                          <button type="button" className="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
+                          <h4 className="modal-title" />
+                        </div>
+                        <div className="modal-body">
+                            <p />
+                        </div>
+                        <div className="modal-footer">
+                          <button type="button" className="btn btn-primary" data-dismiss="modal">Okay</button>
+                        </div>
+                      </div>
+                   </div>
+                </div>
+            );
+        } else {
+            return <div/>;
+        }
+    }
+});
\ No newline at end of file
-- 
cgit v1.2.3-1-g7c22


From 2d8b81170ba80a68865dc6305186a66099d418a2 Mon Sep 17 00:00:00 2001
From: nickago <ngonella@calpoly.edu>
Date: Fri, 24 Jul 2015 09:03:43 -0700
Subject: Added precautions to avoid incorrect data display to the user by
 clearing modal after every close

---
 web/react/components/removed_from_channel_modal.jsx | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

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

diff --git a/web/react/components/removed_from_channel_modal.jsx b/web/react/components/removed_from_channel_modal.jsx
index 3a5a58d5e..b815e5d1d 100644
--- a/web/react/components/removed_from_channel_modal.jsx
+++ b/web/react/components/removed_from_channel_modal.jsx
@@ -9,6 +9,9 @@ module.exports = React.createClass({
     handleClose: function() {
       var townSquare = ChannelStore.getByName("town-square");
       utils.switchChannel(townSquare);
+
+      $(this.refs.title.getDOMNode()).text("")
+      $(this.refs.body.getDOMNode()).text("");
     },
     componentDidMount: function() {
       $(this.getDOMNode()).on('hidden.bs.modal',this.handleClose);
@@ -26,10 +29,10 @@ module.exports = React.createClass({
                       <div className="modal-content">
                         <div className="modal-header">
                           <button type="button" className="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
-                          <h4 className="modal-title" />
+                          <h4 ref="title" className="modal-title" />
                         </div>
                         <div className="modal-body">
-                            <p />
+                            <p ref="body" />
                         </div>
                         <div className="modal-footer">
                           <button type="button" className="btn btn-primary" data-dismiss="modal">Okay</button>
-- 
cgit v1.2.3-1-g7c22


From da6d3556e83b54472f1caa7777ce223988c0655c Mon Sep 17 00:00:00 2001
From: nickago <ngonella@calpoly.edu>
Date: Mon, 27 Jul 2015 13:44:54 -0700
Subject: Changed from Jquery style modal modification to using browserStore

---
 .../components/removed_from_channel_modal.jsx      | 26 +++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

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

diff --git a/web/react/components/removed_from_channel_modal.jsx b/web/react/components/removed_from_channel_modal.jsx
index b815e5d1d..a8889a92a 100644
--- a/web/react/components/removed_from_channel_modal.jsx
+++ b/web/react/components/removed_from_channel_modal.jsx
@@ -3,24 +3,40 @@
 
 var ChannelStore = require('../stores/channel_store.jsx');
 var UserStore = require('../stores/user_store.jsx');
+var BrowserStore = require('../stores/browser_store.jsx')
 var utils = require('../utils/utils.jsx');
 
 module.exports = React.createClass({
+    handleShow: function() {
+      var newState = {};
+      if(BrowserStore.getItem("channel-removed-state")) {
+        newState = BrowserStore.getItem("channel-removed-state");
+        BrowserStore.removeItem("channel-removed-state");
+      }
+
+      this.setState(newState);
+    },
     handleClose: function() {
       var townSquare = ChannelStore.getByName("town-square");
       utils.switchChannel(townSquare);
 
-      $(this.refs.title.getDOMNode()).text("")
-      $(this.refs.body.getDOMNode()).text("");
+      this.setState({channelName: "", remover: ""})
     },
     componentDidMount: function() {
+      $(this.getDOMNode()).on('show.bs.modal',this.handleShow);
       $(this.getDOMNode()).on('hidden.bs.modal',this.handleClose);
     },
     componentWillUnmount: function() {
+      $(this.getDOMNode()).off('show.bs.modal',this.handleShow);
       $(this.getDOMNode()).off('hidden.bs.modal',this.handleClose);
     },
+    getInitialState: function() {
+      return {channelName: "", remover: ""}
+    },
     render: function() {
-        currentUser = UserStore.getCurrentUser();
+        var currentUser = UserStore.getCurrentUser();
+        var channelName = this.state.channelName ? this.state.channelName : "the channel"
+        var remover = this.state.remover ? this.state.remover : "Someone"
 
         if (currentUser != null) {
             return (
@@ -29,10 +45,10 @@ module.exports = React.createClass({
                       <div className="modal-content">
                         <div className="modal-header">
                           <button type="button" className="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
-                          <h4 ref="title" className="modal-title" />
+                          <h4 className="modal-title">Removed from {channelName}</h4>
                         </div>
                         <div className="modal-body">
-                            <p ref="body" />
+                            <p>{remover} removed you from {channelName}</p>
                         </div>
                         <div className="modal-footer">
                           <button type="button" className="btn btn-primary" data-dismiss="modal">Okay</button>
-- 
cgit v1.2.3-1-g7c22

