From afdef124c8b76292ac3b8431a0c6137457d998e0 Mon Sep 17 00:00:00 2001
From: hmhealey <harrisonmhealey@gmail.com>
Date: Sat, 21 Nov 2015 08:53:45 -0500
Subject: Converted TeamMembers (now called TeamMembersModal) to
 React-Bootstrap

---
 web/react/components/member_list_team.jsx | 47 +++++++++++++++++++++++++++----
 1 file changed, 41 insertions(+), 6 deletions(-)

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

diff --git a/web/react/components/member_list_team.jsx b/web/react/components/member_list_team.jsx
index 72fdb7be9..f1c31131f 100644
--- a/web/react/components/member_list_team.jsx
+++ b/web/react/components/member_list_team.jsx
@@ -2,17 +2,56 @@
 // See License.txt for license information.
 
 import MemberListTeamItem from './member_list_team_item.jsx';
+import UserStore from '../stores/user_store.jsx';
 
 export default class MemberListTeam extends React.Component {
+    constructor(props) {
+        super(props);
+
+        this.getUsers = this.getUsers.bind(this);
+        this.onChange = this.onChange.bind(this);
+
+        this.state = {
+            users: this.getUsers()
+        };
+    }
+
+    componentDidMount() {
+        UserStore.addChangeListener(this.onChange);
+    }
+
+    componentWillUnmount() {
+        UserStore.removeChangeListener(this.onChange);
+    }
+
+    getUsers() {
+        const profiles = UserStore.getProfiles();
+        const users = [];
+
+        for (const id of Object.keys(profiles)) {
+            users.push(profiles[id]);
+        }
+
+        users.sort((a, b) => a.username.localeCompare(b.username));
+
+        return users;
+    }
+
+    onChange() {
+        this.setState({
+            users: this.getUsers()
+        });
+    }
+
     render() {
-        const memberList = this.props.users.map(function makeListItem(user) {
+        const memberList = this.state.users.map((user) => {
             return (
                 <MemberListTeamItem
                     key={user.id}
                     user={user}
                 />
             );
-        }, this);
+        });
 
         return (
             <table className='table more-table member-list-holder'>
@@ -23,7 +62,3 @@ export default class MemberListTeam extends React.Component {
         );
     }
 }
-
-MemberListTeam.propTypes = {
-    users: React.PropTypes.arrayOf(React.PropTypes.object).isRequired
-};
-- 
cgit v1.2.3-1-g7c22

