2017-02-17 00:46:39 +00:00
|
|
|
import React, { PureComponent } from 'react';
|
2015-12-28 23:34:32 +00:00
|
|
|
import { List } from 'immutable';
|
2017-06-21 06:40:28 +00:00
|
|
|
import Navicon from 'containers/Navicon';
|
|
|
|
import Editable from 'components/ui/Editable';
|
|
|
|
import { isValidServerName } from 'state/servers';
|
2018-04-05 19:13:32 +00:00
|
|
|
import { linkify } from 'utils';
|
2015-12-28 23:34:32 +00:00
|
|
|
|
2017-02-17 00:46:39 +00:00
|
|
|
export default class ChatTitle extends PureComponent {
|
2015-12-28 23:34:32 +00:00
|
|
|
render() {
|
2017-07-02 01:31:00 +00:00
|
|
|
const { status, title, tab, channel, onTitleChange,
|
2017-06-12 04:18:32 +00:00
|
|
|
onToggleSearch, onToggleUserList, onCloseClick } = this.props;
|
2015-12-28 23:34:32 +00:00
|
|
|
|
2017-05-27 05:30:22 +00:00
|
|
|
let closeTitle;
|
2017-04-19 23:51:55 +00:00
|
|
|
if (tab.isChannel()) {
|
2017-05-27 05:30:22 +00:00
|
|
|
closeTitle = 'Leave';
|
2017-04-19 23:51:55 +00:00
|
|
|
} else if (tab.name) {
|
2017-05-27 05:30:22 +00:00
|
|
|
closeTitle = 'Close';
|
2015-12-28 23:34:32 +00:00
|
|
|
} else {
|
2017-05-27 05:30:22 +00:00
|
|
|
closeTitle = 'Disconnect';
|
2015-12-28 23:34:32 +00:00
|
|
|
}
|
|
|
|
|
2017-07-02 01:31:00 +00:00
|
|
|
let serverError = null;
|
|
|
|
if (!tab.name && status.error) {
|
2017-07-02 22:04:10 +00:00
|
|
|
serverError = <span className="chat-topic error">Error: {status.error}</span>;
|
2017-07-02 01:31:00 +00:00
|
|
|
}
|
|
|
|
|
2015-12-28 23:34:32 +00:00
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<div className="chat-title-bar">
|
|
|
|
<Navicon />
|
2017-06-12 04:18:32 +00:00
|
|
|
<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">
|
2017-05-27 05:30:22 +00:00
|
|
|
<span className="chat-topic">{linkify(channel.get('topic')) || null}</span>
|
2017-07-02 01:31:00 +00:00
|
|
|
{serverError}
|
2015-12-28 23:34:32 +00:00
|
|
|
</div>
|
2017-05-27 05:30:22 +00:00
|
|
|
<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"
|
2017-05-27 05:30:22 +00:00
|
|
|
title={closeTitle}
|
|
|
|
onClick={onCloseClick}
|
2015-12-28 23:34:32 +00:00
|
|
|
/>
|
2017-05-27 05:30:22 +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" />
|
2017-05-27 05:30:22 +00:00
|
|
|
<span className="chat-usercount">{channel.get('users', List()).size}</span>
|
2015-12-28 23:34:32 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|