mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-04 10:41:14 +00:00
- 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
69 lines
1.8 KiB
JavaScript
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;
|