From aa684f0b8b81aa576997dd26fb077882651830fc Mon Sep 17 00:00:00 2001
From: Harrison Healey <harrisonmhealey@gmail.com>
Date: Mon, 28 Mar 2016 15:19:59 -0400
Subject: Added ChannelSelect component

---
 webapp/components/channel_select.jsx | 79 ++++++++++++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)
 create mode 100644 webapp/components/channel_select.jsx

(limited to 'webapp/components/channel_select.jsx')

diff --git a/webapp/components/channel_select.jsx b/webapp/components/channel_select.jsx
new file mode 100644
index 000000000..b110b32da
--- /dev/null
+++ b/webapp/components/channel_select.jsx
@@ -0,0 +1,79 @@
+// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+import React from 'react';
+
+import Constants from 'utils/constants.jsx';
+import ChannelStore from 'stores/channel_store.jsx';
+import * as Utils from 'utils/utils.jsx';
+
+export default class ChannelSelect extends React.Component {
+    static get propTypes() {
+        return {
+            onChange: React.PropTypes.func,
+            value: React.PropTypes.string
+        };
+    }
+
+    constructor(props) {
+        super(props);
+
+        this.handleChannelChange = this.handleChannelChange.bind(this);
+
+        this.state = {
+            channels: []
+        };
+    }
+
+    componentWillMount() {
+        this.setState({
+            channels: ChannelStore.getAll()
+        });
+
+        ChannelStore.addChangeListener(this.handleChannelChange);
+    }
+
+    componentWillUnmount() {
+        ChannelStore.removeChangeListener(this.handleChannelChange);
+    }
+
+    handleChannelChange() {
+        this.setState({
+            channels: ChannelStore.getAll()
+        });
+    }
+
+    render() {
+        const options = [
+            <option
+                key=''
+                value=''
+            >
+                {Utils.localizeMessage('channel-select.select', '--- Select a channel ---')}
+            </option>
+        ];
+
+        this.state.channels.forEach((channel) => {
+            if (channel.type !== Constants.DM_CHANNEL) {
+                options.push(
+                    <option
+                        key={channel.id}
+                        value={channel.id}
+                    >
+                        {channel.display_name}
+                    </option>
+                );
+            }
+        });
+
+        return (
+            <select
+                className='form-control'
+                value={this.props.value}
+                onChange={this.props.onChange}
+            >
+                {options}
+            </select>
+        );
+    }
+}
-- 
cgit v1.2.3-1-g7c22


From 17f10b1abad76d797e7c0b3b686f065a253f5c0b Mon Sep 17 00:00:00 2001
From: Harrison Healey <harrisonmhealey@gmail.com>
Date: Tue, 29 Mar 2016 10:46:54 -0400
Subject: Added english localization for Backstage and additional cleanup

---
 webapp/components/channel_select.jsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'webapp/components/channel_select.jsx')

diff --git a/webapp/components/channel_select.jsx b/webapp/components/channel_select.jsx
index b110b32da..8622d1f57 100644
--- a/webapp/components/channel_select.jsx
+++ b/webapp/components/channel_select.jsx
@@ -49,7 +49,7 @@ export default class ChannelSelect extends React.Component {
                 key=''
                 value=''
             >
-                {Utils.localizeMessage('channel-select.select', '--- Select a channel ---')}
+                {Utils.localizeMessage('channel_select.placeholder', '--- Select a channel ---')}
             </option>
         ];
 
-- 
cgit v1.2.3-1-g7c22

