From b61ec9f8837ef67193e61a9c56423a1f9f51eb6f Mon Sep 17 00:00:00 2001
From: hmhealey <harrisonmhealey@gmail.com>
Date: Fri, 26 Feb 2016 12:01:01 -0500
Subject: Changed ChannelInviteModal to use a FilteredUserList

---
 web/react/components/channel_invite_modal.jsx | 43 +++++++++++++++++----------
 1 file changed, 27 insertions(+), 16 deletions(-)

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

diff --git a/web/react/components/channel_invite_modal.jsx b/web/react/components/channel_invite_modal.jsx
index c9fe871d0..f27f5a900 100644
--- a/web/react/components/channel_invite_modal.jsx
+++ b/web/react/components/channel_invite_modal.jsx
@@ -1,7 +1,7 @@
 // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
 // See License.txt for license information.
 
-import MemberList from './member_list.jsx';
+import FilteredUserList from './filtered_user_list.jsx';
 import LoadingScreen from './loading_screen.jsx';
 
 import UserStore from '../stores/user_store.jsx';
@@ -22,6 +22,8 @@ export default class ChannelInviteModal extends React.Component {
         this.onListenerChange = this.onListenerChange.bind(this);
         this.handleInvite = this.handleInvite.bind(this);
 
+        this.createInviteButton = this.createInviteButton.bind(this);
+
         // the state gets populated when the modal is shown
         this.state = {};
     }
@@ -78,12 +80,13 @@ export default class ChannelInviteModal extends React.Component {
         };
     }
     onShow() {
-        if ($(window).width() > 768) {
+        // TODO ugh
+        /*if ($(window).width() > 768) {
             $(ReactDOM.findDOMNode(this.refs.modalBody)).perfectScrollbar();
             $(ReactDOM.findDOMNode(this.refs.modalBody)).css('max-height', $(window).height() - 200);
         } else {
             $(ReactDOM.findDOMNode(this.refs.modalBody)).css('max-height', $(window).height() - 150);
-        }
+        }*/
     }
     componentDidUpdate(prevProps) {
         if (this.props.show && !prevProps.show) {
@@ -108,9 +111,10 @@ export default class ChannelInviteModal extends React.Component {
             this.setState(newState);
         }
     }
-    handleInvite(userId) {
-        var data = {};
-        data.user_id = userId;
+    handleInvite(user) {
+        const data = {
+            user_id: user.id
+        };
 
         Client.addChannelMember(
             this.props.channel.id,
@@ -124,27 +128,34 @@ export default class ChannelInviteModal extends React.Component {
             }
         );
     }
+    createInviteButton({user}) {
+        return (
+            <a
+                onClick={this.handleInvite.bind(this, user)}
+                className='btn btn-sm btn-primary'
+            >
+                <i className='glyphicon glyphicon-envelope'/>
+                <FormattedMessage
+                    id='member_item.add'
+                    defaultMessage=' Add'
+                />
+            </a>
+        );
+    }
     render() {
         var inviteError = null;
         if (this.state.inviteError) {
             inviteError = (<label className='has-error control-label'>{this.state.inviteError}</label>);
         }
 
-        var currentMember = ChannelStore.getCurrentMember();
-        var isAdmin = false;
-        if (currentMember) {
-            isAdmin = Utils.isAdmin(currentMember.roles) || Utils.isAdmin(UserStore.getCurrentUser().roles);
-        }
-
         var content;
         if (this.state.loading) {
             content = (<LoadingScreen/>);
         } else {
             content = (
-                <MemberList
-                    memberList={this.state.nonmembers}
-                    isAdmin={isAdmin}
-                    handleInvite={this.handleInvite}
+                <FilteredUserList
+                    users={this.state.nonmembers}
+                    actions={[this.createInviteButton]}
                 />
             );
         }
-- 
cgit v1.2.3-1-g7c22


From a92b51935e172f4e4fc7af83f410a071d0590f90 Mon Sep 17 00:00:00 2001
From: hmhealey <harrisonmhealey@gmail.com>
Date: Wed, 2 Mar 2016 11:00:01 -0500
Subject: Moved localized strings for PLT-1090

---
 web/react/components/channel_invite_modal.jsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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

diff --git a/web/react/components/channel_invite_modal.jsx b/web/react/components/channel_invite_modal.jsx
index f27f5a900..f0c8a9030 100644
--- a/web/react/components/channel_invite_modal.jsx
+++ b/web/react/components/channel_invite_modal.jsx
@@ -136,7 +136,7 @@ export default class ChannelInviteModal extends React.Component {
             >
                 <i className='glyphicon glyphicon-envelope'/>
                 <FormattedMessage
-                    id='member_item.add'
+                    id='channel_invite.add'
                     defaultMessage=' Add'
                 />
             </a>
-- 
cgit v1.2.3-1-g7c22


From 62c09209430e74fb0863cd998497f6ef1c475342 Mon Sep 17 00:00:00 2001
From: hmhealey <harrisonmhealey@gmail.com>
Date: Wed, 2 Mar 2016 16:10:14 -0500
Subject: Fixed max height for all modals using FilteredUserLists

---
 web/react/components/channel_invite_modal.jsx | 28 ++++++++++-----------------
 1 file changed, 10 insertions(+), 18 deletions(-)

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

diff --git a/web/react/components/channel_invite_modal.jsx b/web/react/components/channel_invite_modal.jsx
index f0c8a9030..6c8d51abb 100644
--- a/web/react/components/channel_invite_modal.jsx
+++ b/web/react/components/channel_invite_modal.jsx
@@ -25,7 +25,9 @@ export default class ChannelInviteModal extends React.Component {
         this.createInviteButton = this.createInviteButton.bind(this);
 
         // the state gets populated when the modal is shown
-        this.state = {};
+        this.state = {
+            loading: true
+        };
     }
     shouldComponentUpdate(nextProps, nextState) {
         if (!this.props.show && !nextProps.show) {
@@ -79,20 +81,6 @@ export default class ChannelInviteModal extends React.Component {
             loading: false
         };
     }
-    onShow() {
-        // TODO ugh
-        /*if ($(window).width() > 768) {
-            $(ReactDOM.findDOMNode(this.refs.modalBody)).perfectScrollbar();
-            $(ReactDOM.findDOMNode(this.refs.modalBody)).css('max-height', $(window).height() - 200);
-        } else {
-            $(ReactDOM.findDOMNode(this.refs.modalBody)).css('max-height', $(window).height() - 150);
-        }*/
-    }
-    componentDidUpdate(prevProps) {
-        if (this.props.show && !prevProps.show) {
-            this.onShow();
-        }
-    }
     componentWillReceiveProps(nextProps) {
         if (!this.props.show && nextProps.show) {
             ChannelStore.addExtraInfoChangeListener(this.onListenerChange);
@@ -152,8 +140,14 @@ export default class ChannelInviteModal extends React.Component {
         if (this.state.loading) {
             content = (<LoadingScreen/>);
         } else {
+            let maxHeight = 1000;
+            if (Utils.windowHeight() <= 1200) {
+                maxHeight = Utils.windowHeight() - 300;
+            }
+
             content = (
                 <FilteredUserList
+                    style={{maxHeight}}
                     users={this.state.nonmembers}
                     actions={[this.createInviteButton]}
                 />
@@ -175,9 +169,7 @@ export default class ChannelInviteModal extends React.Component {
                         <span className='name'>{this.props.channel.display_name}</span>
                     </Modal.Title>
                 </Modal.Header>
-                <Modal.Body
-                    ref='modalBody'
-                >
+                <Modal.Body>
                     {inviteError}
                     {content}
                 </Modal.Body>
-- 
cgit v1.2.3-1-g7c22

