2015-01-17 01:37:21 +00:00
|
|
|
var React = require('react');
|
|
|
|
var Reflux = require('reflux');
|
|
|
|
var _ = require('lodash');
|
|
|
|
|
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-01-17 01:37:21 +00:00
|
|
|
|
|
|
|
var TabList = React.createClass({
|
|
|
|
mixins: [
|
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
|
|
|
],
|
|
|
|
|
|
|
|
getInitialState: function() {
|
|
|
|
return {
|
2015-02-06 01:32:25 +00:00
|
|
|
servers: serverStore.getState(),
|
2015-01-17 01:37:21 +00:00
|
|
|
channels: channelStore.getState(),
|
2015-02-06 01:32:25 +00:00
|
|
|
privateChats: privateChatStore.getState()
|
2015-01-17 01:37:21 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2015-02-03 21:54:46 +00:00
|
|
|
handleConnectClick: function() {
|
|
|
|
routeActions.navigate('connect');
|
|
|
|
},
|
|
|
|
|
|
|
|
handleSettingsClick: function() {
|
|
|
|
routeActions.navigate('settings');
|
|
|
|
},
|
|
|
|
|
2015-01-17 01:37:21 +00:00
|
|
|
render: function() {
|
|
|
|
var self = this;
|
2015-01-29 23:38:51 +00:00
|
|
|
|
2015-01-17 01:37:21 +00:00
|
|
|
var tabs = _.map(this.state.channels, function(server, address) {
|
2015-02-06 01:32:25 +00:00
|
|
|
var serverTabs = _.map(server, function(channel, name) {
|
2015-02-02 00:54:26 +00:00
|
|
|
return (
|
2015-02-06 01:32:25 +00:00
|
|
|
<TabListItem
|
|
|
|
server={address}
|
|
|
|
channel={name}
|
|
|
|
name={name}>
|
|
|
|
</TabListItem>
|
2015-02-02 00:54:26 +00:00
|
|
|
);
|
2015-01-17 01:37:21 +00:00
|
|
|
});
|
2015-01-29 23:38:51 +00:00
|
|
|
|
2015-01-30 01:34:28 +00:00
|
|
|
_.each(self.state.privateChats[address], function(chat, nick) {
|
2015-02-06 01:32:25 +00:00
|
|
|
serverTabs.push(
|
|
|
|
<TabListItem
|
|
|
|
server={address}
|
|
|
|
channel={nick}
|
|
|
|
name={nick}>
|
|
|
|
</TabListItem>
|
2015-02-02 00:54:26 +00:00
|
|
|
);
|
2015-01-30 01:34:28 +00:00
|
|
|
});
|
|
|
|
|
2015-02-06 01:32:25 +00:00
|
|
|
serverTabs.unshift(
|
|
|
|
<TabListItem
|
|
|
|
server={address}
|
|
|
|
channel={null}
|
|
|
|
name={serverStore.getName(address)}>
|
|
|
|
</TabListItem>
|
2015-02-02 00:54:26 +00:00
|
|
|
);
|
2015-01-29 23:38:51 +00:00
|
|
|
|
2015-02-06 01:32:25 +00:00
|
|
|
return serverTabs;
|
2015-01-17 01:37:21 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
2015-01-29 23:38:51 +00:00
|
|
|
<div className="tablist">
|
2015-02-03 21:54:46 +00:00
|
|
|
<button className="button-connect" onClick={this.handleConnectClick}>Connect</button>
|
2015-01-29 23:38:51 +00:00
|
|
|
{tabs}
|
|
|
|
<div className="side-buttons">
|
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;
|