2015-01-17 01:37:21 +00:00
|
|
|
var React = require('react');
|
|
|
|
var Reflux = require('reflux');
|
|
|
|
|
2015-02-06 01:32:25 +00:00
|
|
|
var TabListItem = require('./TabListItem.jsx');
|
2015-01-21 23:32:32 +00:00
|
|
|
var channelStore = require('../stores/channel');
|
2015-01-30 01:34:28 +00:00
|
|
|
var privateChatStore = require('../stores/privateChat');
|
2015-02-02 00:54:26 +00:00
|
|
|
var serverStore = require('../stores/server');
|
2015-02-03 21:54:46 +00:00
|
|
|
var routeActions = require('../actions/route');
|
2015-06-09 22:59:41 +00:00
|
|
|
var tabActions = require('../actions/tab');
|
2015-05-20 06:14:44 +00:00
|
|
|
var PureMixin = require('../mixins/pure');
|
2015-01-17 01:37:21 +00:00
|
|
|
|
|
|
|
var TabList = React.createClass({
|
|
|
|
mixins: [
|
2015-05-20 06:14:44 +00:00
|
|
|
PureMixin,
|
2015-02-06 01:32:25 +00:00
|
|
|
Reflux.connect(serverStore, 'servers'),
|
2015-01-17 01:37:21 +00:00
|
|
|
Reflux.connect(channelStore, 'channels'),
|
2015-02-06 01:32:25 +00:00
|
|
|
Reflux.connect(privateChatStore, 'privateChats')
|
2015-01-17 01:37:21 +00:00
|
|
|
],
|
|
|
|
|
2015-05-18 23:17:23 +00:00
|
|
|
handleConnectClick() {
|
2015-02-03 21:54:46 +00:00
|
|
|
routeActions.navigate('connect');
|
2015-06-09 22:59:41 +00:00
|
|
|
tabActions.hideMenu();
|
2015-02-03 21:54:46 +00:00
|
|
|
},
|
|
|
|
|
2015-05-18 23:17:23 +00:00
|
|
|
handleSettingsClick() {
|
2015-02-03 21:54:46 +00:00
|
|
|
routeActions.navigate('settings');
|
2015-06-09 22:59:41 +00:00
|
|
|
tabActions.hideMenu();
|
2015-02-03 21:54:46 +00:00
|
|
|
},
|
|
|
|
|
2015-05-18 23:17:23 +00:00
|
|
|
render() {
|
2015-06-09 22:24:14 +00:00
|
|
|
var className = this.props.menuToggled ? 'tablist off-canvas' : 'tablist';
|
2015-05-20 06:14:44 +00:00
|
|
|
var tabs = [];
|
2015-01-30 01:34:28 +00:00
|
|
|
|
2015-05-20 06:14:44 +00:00
|
|
|
this.state.channels.forEach((server, address) => {
|
|
|
|
tabs.push(
|
2015-06-01 22:09:28 +00:00
|
|
|
<TabListItem
|
2015-05-20 06:14:44 +00:00
|
|
|
key={address}
|
2015-06-01 22:09:28 +00:00
|
|
|
server={address}
|
2015-02-06 01:32:25 +00:00
|
|
|
channel={null}
|
2015-05-20 06:14:44 +00:00
|
|
|
name={this.state.servers.getIn([address, 'name'])}>
|
2015-02-06 01:32:25 +00:00
|
|
|
</TabListItem>
|
2015-02-02 00:54:26 +00:00
|
|
|
);
|
2015-01-29 23:38:51 +00:00
|
|
|
|
2015-05-20 06:14:44 +00:00
|
|
|
server.forEach((channel, name) => {
|
|
|
|
tabs.push(
|
|
|
|
<TabListItem
|
2015-06-01 22:09:28 +00:00
|
|
|
key={address + name}
|
|
|
|
server={address}
|
2015-05-20 06:14:44 +00:00
|
|
|
channel={name}
|
|
|
|
name={name}>
|
|
|
|
</TabListItem>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
if (this.state.privateChats.has(address)) {
|
|
|
|
this.state.privateChats.get(address).forEach(nick => {
|
|
|
|
tabs.push(
|
2015-06-01 22:09:28 +00:00
|
|
|
<TabListItem
|
2015-05-20 06:14:44 +00:00
|
|
|
key={address + nick}
|
2015-06-01 22:09:28 +00:00
|
|
|
server={address}
|
2015-05-20 06:14:44 +00:00
|
|
|
channel={nick}
|
|
|
|
name={nick}>
|
|
|
|
</TabListItem>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
2015-01-17 01:37:21 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
2015-06-09 22:24:14 +00:00
|
|
|
<div className={className}>
|
2015-02-03 21:54:46 +00:00
|
|
|
<button className="button-connect" onClick={this.handleConnectClick}>Connect</button>
|
2015-05-23 02:38:43 +00:00
|
|
|
<div className="tab-container">{tabs}</div>
|
2015-01-29 23:38:51 +00:00
|
|
|
<div className="side-buttons">
|
2015-05-10 23:09:59 +00:00
|
|
|
<i className="icon-user"></i>
|
2015-02-16 20:53:01 +00:00
|
|
|
<i className="icon-cog" onClick={this.handleSettingsClick}></i>
|
2015-01-29 23:38:51 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2015-01-17 01:37:21 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = TabList;
|