dispatch/client/src/js/components/pages/Chat/ChatTitle.js

54 lines
1.6 KiB
JavaScript
Raw Normal View History

import React, { PureComponent } from 'react';
2015-12-28 23:34:32 +00:00
import { List } from 'immutable';
import Navicon from 'containers/Navicon';
import Editable from 'components/ui/Editable';
import { isValidServerName } from 'state/servers';
import { linkify } from 'util';
2015-12-28 23:34:32 +00:00
export default class ChatTitle extends PureComponent {
2015-12-28 23:34:32 +00:00
render() {
const { title, tab, channel, onTitleChange,
onToggleSearch, onToggleUserList, onCloseClick } = this.props;
2015-12-28 23:34:32 +00:00
let closeTitle;
if (tab.isChannel()) {
closeTitle = 'Leave';
} else if (tab.name) {
closeTitle = 'Close';
2015-12-28 23:34:32 +00:00
} else {
closeTitle = 'Disconnect';
2015-12-28 23:34:32 +00:00
}
return (
<div>
<div className="chat-title-bar">
<Navicon />
<Editable
className="chat-title"
editable={!tab.name}
value={title}
validate={isValidServerName}
onChange={onTitleChange}
>
<span className="chat-title">{title}</span>
</Editable>
2015-12-28 23:34:32 +00:00
<div className="chat-topic-wrap">
<span className="chat-topic">{linkify(channel.get('topic')) || null}</span>
2015-12-28 23:34:32 +00:00
</div>
<i className="icon-search" title="Search" onClick={onToggleSearch} />
2015-12-28 23:34:32 +00:00
<i
2017-05-16 06:38:43 +00:00
className="icon-cancel button-leave"
title={closeTitle}
onClick={onCloseClick}
2015-12-28 23:34:32 +00:00
/>
<i className="icon-user button-userlist" onClick={onToggleUserList} />
2015-12-28 23:34:32 +00:00
</div>
<div className="userlist-bar">
<i className="icon-user" />
<span className="chat-usercount">{channel.get('users', List()).size}</span>
2015-12-28 23:34:32 +00:00
</div>
</div>
);
}
}