summaryrefslogtreecommitdiffstats
path: root/webapp/components
diff options
context:
space:
mode:
authorDavid Lu <david.lu@hotmail.com>2016-07-25 10:15:48 -0400
committerChristopher Speller <crspeller@gmail.com>2016-07-25 10:15:48 -0400
commit6e44d6b8593196d665d5043eb52c3cb359c6dce2 (patch)
treed8f467fe841e637eb3b7e54927106ee4537ce9b7 /webapp/components
parent9b3e9243a5d596be718bb2da21c59265f050e2eb (diff)
downloadchat-6e44d6b8593196d665d5043eb52c3cb359c6dce2.tar.gz
chat-6e44d6b8593196d665d5043eb52c3cb359c6dce2.tar.bz2
chat-6e44d6b8593196d665d5043eb52c3cb359c6dce2.zip
Added icons next to channels in channel switcher (#3663)
Diffstat (limited to 'webapp/components')
-rw-r--r--webapp/components/suggestion/switch_channel_provider.jsx25
1 files changed, 22 insertions, 3 deletions
diff --git a/webapp/components/suggestion/switch_channel_provider.jsx b/webapp/components/suggestion/switch_channel_provider.jsx
index e092d9b5c..e0c862e7e 100644
--- a/webapp/components/suggestion/switch_channel_provider.jsx
+++ b/webapp/components/suggestion/switch_channel_provider.jsx
@@ -4,9 +4,11 @@
import React from 'react';
import ChannelStore from 'stores/channel_store.jsx';
+import UserStore from 'stores/user_store.jsx';
import SuggestionStore from 'stores/suggestion_store.jsx';
import Suggestion from './suggestion.jsx';
import Constants from 'utils/constants.jsx';
+import StatusIcon from 'components/status_icon.jsx';
import * as Utils from 'utils/utils.jsx';
class SwitchChannelSuggestion extends Suggestion {
@@ -25,11 +27,21 @@ class SwitchChannelSuggestion extends Suggestion {
displayName = item.display_name + ' (' + item.name + ')';
}
+ let icon = null;
+ if (item.type === Constants.OPEN_CHANNEL) {
+ icon = <div className='status'><i className='fa fa-globe'></i></div>;
+ } else if (item.type === Constants.PRIVATE_CHANNEL) {
+ icon = <div className='status'><i className='fa fa-lock'></i></div>;
+ } else {
+ icon = <StatusIcon status={item.status}/>;
+ }
+
return (
<div
onClick={this.handleClick}
className={className}
>
+ {icon}
{displayName}
</div>
);
@@ -48,10 +60,12 @@ export default class SwitchChannelProvider {
channels.push(channel);
} else if (channel.type === Constants.DM_CHANNEL && Utils.getDirectTeammate(channel.id).username.startsWith(channelPrefix.toLowerCase())) {
// New channel to not modify existing channel
+ const otherUser = Utils.getDirectTeammate(channel.id);
const newChannel = {
- display_name: Utils.getDirectTeammate(channel.id).username,
- name: Utils.getDirectTeammate(channel.id).username + ' ' + Utils.localizeMessage('channel_switch_modal.dm', '(Direct Message)'),
- type: Constants.DM_CHANNEL
+ display_name: otherUser.username,
+ name: otherUser.username + ' ' + Utils.localizeMessage('channel_switch_modal.dm', '(Direct Message)'),
+ type: Constants.DM_CHANNEL,
+ status: UserStore.getStatus(otherUser.id) || 'offline'
};
channels.push(newChannel);
}
@@ -59,6 +73,11 @@ export default class SwitchChannelProvider {
channels.sort((a, b) => {
if (a.display_name === b.display_name) {
+ if (a.type !== Constants.DM_CHANNEL && b.type === Constants.DM_CHANNEL) {
+ return -1;
+ } else if (a.type === Constants.DM_CHANNEL && b.type !== Constants.DM_CHANNEL) {
+ return 1;
+ }
return a.name.localeCompare(b.name);
}
return a.display_name.localeCompare(b.display_name);