2017-02-17 00:46:39 +00:00
|
|
|
import React, { PureComponent } from 'react';
|
2015-12-28 23:34:32 +00:00
|
|
|
import TabListItem from './TabListItem';
|
|
|
|
|
2017-02-17 00:46:39 +00:00
|
|
|
export default class TabList extends PureComponent {
|
2017-05-07 20:19:15 +00:00
|
|
|
handleTabClick = (server, target) => this.props.select(server, target);
|
|
|
|
handleConnectClick = () => this.props.pushPath('/connect');
|
|
|
|
handleSettingsClick = () => this.props.pushPath('/settings');
|
2015-12-28 23:34:32 +00:00
|
|
|
|
|
|
|
render() {
|
2017-04-19 23:51:55 +00:00
|
|
|
const { tab, channels, servers, privateChats, showTabList } = this.props;
|
2016-01-11 22:31:06 +00:00
|
|
|
const className = showTabList ? 'tablist off-canvas' : 'tablist';
|
2015-12-28 23:34:32 +00:00
|
|
|
const tabs = [];
|
|
|
|
|
|
|
|
channels.forEach((server, address) => {
|
|
|
|
tabs.push(
|
|
|
|
<TabListItem
|
|
|
|
key={address}
|
2016-01-05 18:29:22 +00:00
|
|
|
server={address}
|
2015-12-28 23:34:32 +00:00
|
|
|
content={servers.getIn([address, 'name'])}
|
2017-04-19 23:51:55 +00:00
|
|
|
selected={tab.server === address && tab.name === null}
|
2016-01-13 17:53:54 +00:00
|
|
|
connected={servers.getIn([address, 'connected'])}
|
2016-01-05 18:29:22 +00:00
|
|
|
onClick={this.handleTabClick}
|
2015-12-28 23:34:32 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
2016-01-05 18:29:22 +00:00
|
|
|
server.forEach((channel, name) => tabs.push(
|
|
|
|
<TabListItem
|
|
|
|
key={address + name}
|
|
|
|
server={address}
|
|
|
|
target={name}
|
|
|
|
content={name}
|
2017-04-19 23:51:55 +00:00
|
|
|
selected={tab.server === address && tab.name === name}
|
2016-01-05 18:29:22 +00:00
|
|
|
onClick={this.handleTabClick}
|
|
|
|
/>
|
|
|
|
));
|
2015-12-28 23:34:32 +00:00
|
|
|
|
2017-05-22 01:49:37 +00:00
|
|
|
if (privateChats.has(address) && privateChats.get(address).size > 0) {
|
2017-05-26 06:20:00 +00:00
|
|
|
tabs.push(<div key={`${address}-pm}`} className="tab-label">Private messages</div>);
|
2017-05-22 01:49:37 +00:00
|
|
|
|
2016-01-05 18:29:22 +00:00
|
|
|
privateChats.get(address).forEach(nick => tabs.push(
|
|
|
|
<TabListItem
|
|
|
|
key={address + nick}
|
|
|
|
server={address}
|
|
|
|
target={nick}
|
|
|
|
content={nick}
|
2017-04-19 23:51:55 +00:00
|
|
|
selected={tab.server === address && tab.name === nick}
|
2016-01-05 18:29:22 +00:00
|
|
|
onClick={this.handleTabClick}
|
|
|
|
/>
|
|
|
|
));
|
2015-12-28 23:34:32 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={className}>
|
|
|
|
<button className="button-connect" onClick={this.handleConnectClick}>Connect</button>
|
|
|
|
<div className="tab-container">{tabs}</div>
|
|
|
|
<div className="side-buttons">
|
2017-02-16 02:55:50 +00:00
|
|
|
<i className="icon-user" />
|
|
|
|
<i className="icon-cog" onClick={this.handleSettingsClick} />
|
2015-12-28 23:34:32 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|