Files
weave-scope/client/app/scripts/components/groupings.js
David Kaltschmidt 66d66a4d01 Fix grouping bar for topologies that don't support grouping
- fixes #61
- dont clear nodes cache if topo is the same
- combined stores that were interdependent
- dont show topology grouping menu if unsupported
- also harmonized some variable names
- removed old grouping switcher
- moved topo actions to app actions, removed search
- get correct topology url
- first JS test using Jest
- make tests run on circle using the build container.
- replaced jest test runner with karma/jasmine
- Use debian for UI build and test container.
- updated karma-browserify
2015-05-22 16:41:48 +00:00

69 lines
1.8 KiB
JavaScript

/** @jsx React.DOM */
var React = require('react');
var _ = require('lodash');
var AppActions = require('../actions/app-actions');
var AppStore = require('../stores/app-store');
var GROUPINGS = [{
id: 'none',
iconClass: 'fa fa-th',
needsTopology: false
}, {
id: 'grouped',
iconClass: 'fa fa-th-large',
needsTopology: 'grouped_url'
}];
var Groupings = React.createClass({
onGroupingClick: function(ev) {
ev.preventDefault();
AppActions.clickGrouping(ev.currentTarget.getAttribute('rel'));
},
isGroupingSupportedByTopology: function(topology, grouping) {
return !grouping.needsTopology || topology && topology[grouping.needsTopology];
},
getGroupingsSupportedByTopology: function(topology) {
return _.filter(GROUPINGS, _.partial(this.isGroupingSupportedByTopology, topology));
},
renderGrouping: function(grouping, activeGroupingId) {
var className = "groupings-item",
isSupportedByTopology = this.isGroupingSupportedByTopology(this.props.currentTopology, grouping);
if (grouping.id === activeGroupingId) {
className += " groupings-item-active";
} else if (!isSupportedByTopology) {
className += " groupings-item-disabled";
} else {
className += " groupings-item-default";
}
return (
<div className={className} key={grouping.id} rel={grouping.id} onClick={isSupportedByTopology && this.onGroupingClick}>
<span className={grouping.iconClass} />
</div>
);
},
render: function() {
var activeGrouping = this.props.active,
isGroupingSupported = _.size(this.getGroupingsSupportedByTopology(this.props.currentTopology)) > 1;
return (
<div className="groupings">
{isGroupingSupported && GROUPINGS.map(function(grouping) {
return this.renderGrouping(grouping, activeGrouping);
}, this)}
</div>
);
}
});
module.exports = Groupings;