Files
weave-scope/client/app/scripts/components/topologies.js
David Kaltschmidt 7d1ee40a2b Fixed lint errors in all js files
- Also added linter configuration, and make linter fail on error
- fixing ES6 errors and added ES6 transformer
- gulp target to try local build
- linted gulpfile
- cant hook into gulp lint yet, because gulp does currently not support
  ES6 which some rules demand, since gulp cant transpile itself, we have a
  chicken and egg problem.
- ES6 transpiler for test runner
- removed old linter config
- adapted editorconfig to reflect linter config
2015-05-28 15:07:13 +00:00

50 lines
1.4 KiB
JavaScript

const React = require('react');
const _ = require('lodash');
const AppActions = require('../actions/app-actions');
const AppStore = require('../stores/app-store');
const Topologies = React.createClass({
onTopologyClick: function(ev) {
ev.preventDefault();
AppActions.clickTopology(ev.currentTarget.getAttribute('rel'));
},
renderTopology: function(topology) {
const isActive = topology.name === this.props.currentTopology.name;
const className = isActive ? 'topologies-item topologies-item-active' : 'topologies-item';
const topologyId = AppStore.getTopologyIdForUrl(topology.url);
const title = ['Topology: ' + topology.name,
'Nodes: ' + topology.stats.node_count,
'Connections: ' + topology.stats.node_count].join('\n');
return (
<div className={className} key={topologyId} rel={topologyId} onClick={this.onTopologyClick}>
<div title={title}>
<div className="topologies-item-label">
{topology.name}
</div>
</div>
</div>
);
},
render: function() {
const topologies = _.sortBy(this.props.topologies, function(topology) {
return topology.name;
});
return (
<div className="topologies">
{this.props.currentTopology && topologies.map(function(topology) {
return this.renderTopology(topology);
}, this)}
</div>
);
}
});
module.exports = Topologies;