diff options
author | =Corey Hulen <corey@hulen.com> | 2015-06-14 23:53:32 -0800 |
---|---|---|
committer | =Corey Hulen <corey@hulen.com> | 2015-06-14 23:53:32 -0800 |
commit | cf7a05f80f68b5b1c8bcc0089679dd497cec2506 (patch) | |
tree | 70007378570a6962d7c175ca96af732b71aeb6da /web/react/components/more_direct_channels.jsx | |
download | chat-cf7a05f80f68b5b1c8bcc0089679dd497cec2506.tar.gz chat-cf7a05f80f68b5b1c8bcc0089679dd497cec2506.tar.bz2 chat-cf7a05f80f68b5b1c8bcc0089679dd497cec2506.zip |
first commit
Diffstat (limited to 'web/react/components/more_direct_channels.jsx')
-rw-r--r-- | web/react/components/more_direct_channels.jsx | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/web/react/components/more_direct_channels.jsx b/web/react/components/more_direct_channels.jsx new file mode 100644 index 000000000..2785dc8e0 --- /dev/null +++ b/web/react/components/more_direct_channels.jsx @@ -0,0 +1,68 @@ +// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. +// See License.txt for license information. + +var ChannelStore = require('../stores/channel_store.jsx'); +var utils = require('../utils/utils.jsx'); + +module.exports = React.createClass({ + componentDidMount: function() { + var self = this; + $(this.refs.modal.getDOMNode()).on('show.bs.modal', function(e) { + var button = e.relatedTarget; + self.setState({ channels: $(button).data('channels') }); + }); + }, + getInitialState: function() { + return { channels: [] }; + }, + render: function() { + var self = this; + + var directMessageItems = this.state.channels.map(function(channel) { + var badge = ""; + var titleClass = "" + + if (!channel.fake) { + var active = channel.id === ChannelStore.getCurrentId() ? "active" : ""; + + if (channel.unread) { + badge = <span className="badge pull-right small">{channel.unread}</span>; + badgesActive = true; + titleClass = "unread-title" + } + return ( + <li key={channel.name} className={active}><a className={"sidebar-channel " + titleClass} href="#" onClick={function(e){e.preventDefault(); utils.switchChannel(channel, channel.teammate_username); $(self.refs.modal.getDOMNode()).modal('hide')}}>{badge}{channel.display_name}</a></li> + ); + } else { + return ( + <li key={channel.name} className={active}><a className={"sidebar-channel " + titleClass} href={"/channels/"+channel.name}>{badge}{channel.display_name}</a></li> + ); + } + }); + + return ( + <div className="modal fade" id="more_direct_channels" ref="modal" 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"> + <span aria-hidden="true">×</span> + <span className="sr-only">Close</span> + </button> + <h4 className="modal-title">More Direct Messages</h4> + </div> + <div className="modal-body"> + <ul className="nav nav-pills nav-stacked"> + {directMessageItems} + </ul> + </div> + <div className="modal-footer"> + <button type="button" className="btn btn-default" data-dismiss="modal">Close</button> + </div> + </div> + </div> + </div> + + ); + } +}); |