Added icons next to channels in channel switcher (#3663)

Этот коммит содержится в:
David Lu
2016-07-25 10:15:48 -04:00
коммит произвёл Christopher Speller
родитель 9b3e9243a5
Коммит 6e44d6b859

Просмотреть файл

@@ -4,9 +4,11 @@
import React from 'react'; import React from 'react';
import ChannelStore from 'stores/channel_store.jsx'; import ChannelStore from 'stores/channel_store.jsx';
import UserStore from 'stores/user_store.jsx';
import SuggestionStore from 'stores/suggestion_store.jsx'; import SuggestionStore from 'stores/suggestion_store.jsx';
import Suggestion from './suggestion.jsx'; import Suggestion from './suggestion.jsx';
import Constants from 'utils/constants.jsx'; import Constants from 'utils/constants.jsx';
import StatusIcon from 'components/status_icon.jsx';
import * as Utils from 'utils/utils.jsx'; import * as Utils from 'utils/utils.jsx';
class SwitchChannelSuggestion extends Suggestion { class SwitchChannelSuggestion extends Suggestion {
@@ -25,11 +27,21 @@ class SwitchChannelSuggestion extends Suggestion {
displayName = item.display_name + ' (' + item.name + ')'; 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 ( return (
<div <div
onClick={this.handleClick} onClick={this.handleClick}
className={className} className={className}
> >
{icon}
{displayName} {displayName}
</div> </div>
); );
@@ -48,10 +60,12 @@ export default class SwitchChannelProvider {
channels.push(channel); channels.push(channel);
} else if (channel.type === Constants.DM_CHANNEL && Utils.getDirectTeammate(channel.id).username.startsWith(channelPrefix.toLowerCase())) { } else if (channel.type === Constants.DM_CHANNEL && Utils.getDirectTeammate(channel.id).username.startsWith(channelPrefix.toLowerCase())) {
// New channel to not modify existing channel // New channel to not modify existing channel
const otherUser = Utils.getDirectTeammate(channel.id);
const newChannel = { const newChannel = {
display_name: Utils.getDirectTeammate(channel.id).username, display_name: otherUser.username,
name: Utils.getDirectTeammate(channel.id).username + ' ' + Utils.localizeMessage('channel_switch_modal.dm', '(Direct Message)'), name: otherUser.username + ' ' + Utils.localizeMessage('channel_switch_modal.dm', '(Direct Message)'),
type: Constants.DM_CHANNEL type: Constants.DM_CHANNEL,
status: UserStore.getStatus(otherUser.id) || 'offline'
}; };
channels.push(newChannel); channels.push(newChannel);
} }
@@ -59,6 +73,11 @@ export default class SwitchChannelProvider {
channels.sort((a, b) => { channels.sort((a, b) => {
if (a.display_name === b.display_name) { 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.name.localeCompare(b.name);
} }
return a.display_name.localeCompare(b.display_name); return a.display_name.localeCompare(b.display_name);