2017-02-17 00:46:39 +00:00
|
|
|
import React, { PureComponent } from 'react';
|
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-25 03:36:27 +00:00
|
|
|
import { isChannel, 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() {
|
2018-04-05 23:46:22 +00:00
|
|
|
const {
|
|
|
|
status,
|
|
|
|
title,
|
|
|
|
tab,
|
|
|
|
channel,
|
|
|
|
onTitleChange,
|
|
|
|
onToggleSearch,
|
|
|
|
onToggleUserList,
|
|
|
|
onCloseClick
|
|
|
|
} = this.props;
|
2015-12-28 23:34:32 +00:00
|
|
|
|
2017-05-27 05:30:22 +00:00
|
|
|
let closeTitle;
|
2018-04-25 03:36:27 +00:00
|
|
|
if (isChannel(tab)) {
|
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) {
|
2018-04-05 23:46:22 +00:00
|
|
|
serverError = (
|
2018-08-12 21:19:17 +00:00
|
|
|
<span className="chat-topic error">
|
|
|
|
Error:
|
|
|
|
{status.error}
|
|
|
|
</span>
|
2018-04-05 23:46:22 +00:00
|
|
|
);
|
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">
|
2018-04-05 23:46:22 +00:00
|
|
|
<span className="chat-topic">
|
2018-04-25 03:36:27 +00:00
|
|
|
{channel && linkify(channel.topic)}
|
2018-04-05 23:46:22 +00:00
|
|
|
</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" />
|
2018-04-05 23:46:22 +00:00
|
|
|
<span className="chat-usercount">
|
2018-04-25 03:36:27 +00:00
|
|
|
{channel && channel.users.length}
|
2018-04-05 23:46:22 +00:00
|
|
|
</span>
|
2015-12-28 23:34:32 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|