2015-01-17 01:37:21 +00:00
|
|
|
var React = require('react');
|
|
|
|
var Reflux = require('reflux');
|
|
|
|
var _ = require('lodash');
|
|
|
|
|
2015-01-21 23:32:32 +00:00
|
|
|
var channelStore = require('../stores/channel');
|
|
|
|
var selectedTabStore = require('../stores/selectedTab');
|
|
|
|
var tabActions = require('../actions/tab');
|
2015-01-17 01:37:21 +00:00
|
|
|
|
|
|
|
var TabList = React.createClass({
|
|
|
|
mixins: [
|
|
|
|
Reflux.connect(channelStore, 'channels'),
|
|
|
|
Reflux.connect(selectedTabStore, 'selectedTab')
|
|
|
|
],
|
|
|
|
|
|
|
|
getInitialState: function() {
|
|
|
|
return {
|
|
|
|
channels: channelStore.getState(),
|
|
|
|
selectedTab: selectedTabStore.getState()
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
|
|
|
var self = this;
|
2015-01-29 23:38:51 +00:00
|
|
|
var tabClass;
|
|
|
|
var selected = this.state.selectedTab;
|
|
|
|
|
2015-01-17 01:37:21 +00:00
|
|
|
var tabs = _.map(this.state.channels, function(server, address) {
|
2015-01-29 23:38:51 +00:00
|
|
|
var channels = _.map(server, function(channel, name) {
|
|
|
|
if (address === selected.server &&
|
|
|
|
name === selected.channel) {
|
|
|
|
tabClass = 'selected';
|
|
|
|
} else {
|
|
|
|
tabClass = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
return <p className={tabClass} onClick={tabActions.select.bind(null, address, name)}>{name}</p>;
|
2015-01-17 01:37:21 +00:00
|
|
|
});
|
2015-01-29 23:38:51 +00:00
|
|
|
|
|
|
|
if (address === selected.server &&
|
|
|
|
selected.channel === null) {
|
|
|
|
tabClass = 'tab-server selected';
|
|
|
|
} else {
|
|
|
|
tabClass = 'tab-server';
|
|
|
|
}
|
|
|
|
|
|
|
|
channels.unshift(<p className={tabClass} onClick={tabActions.select.bind(null, address, null)}>{address}</p>);
|
|
|
|
|
2015-01-17 01:37:21 +00:00
|
|
|
return channels;
|
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
2015-01-29 23:38:51 +00:00
|
|
|
<div className="tablist">
|
|
|
|
<button className="button-connect">Add Network</button>
|
|
|
|
{tabs}
|
|
|
|
<div className="side-buttons">
|
|
|
|
<button>Settings</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
2015-01-17 01:37:21 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = TabList;
|