mirror of
https://github.com/weaveworks/scope.git
synced 2026-04-19 00:49:45 +00:00
* status bar (fixes #207) * moved topology options to sidebar * render topology option like snackbar * upgrade material-ui to 0.11
60 lines
1.3 KiB
JavaScript
60 lines
1.3 KiB
JavaScript
const React = require('react');
|
|
const _ = require('lodash');
|
|
|
|
const TopologyOptionAction = require('./topology-option-action');
|
|
|
|
const TopologyOptions = React.createClass({
|
|
|
|
renderAction: function(action, option) {
|
|
return (
|
|
<TopologyOptionAction option={option} value={action} />
|
|
);
|
|
},
|
|
|
|
renderOption: function(items) {
|
|
let activeText;
|
|
const actions = [];
|
|
const activeOptions = this.props.activeOptions;
|
|
items.forEach(function(item) {
|
|
if (activeOptions[item.option] && activeOptions[item.option] === item.value) {
|
|
activeText = item.display;
|
|
} else {
|
|
actions.push(this.renderAction(item.value, item.option));
|
|
}
|
|
}, this);
|
|
|
|
return (
|
|
<div className="sidebar-item">
|
|
{activeText}
|
|
<span className="sidebar-item-actions">
|
|
{actions}
|
|
</span>
|
|
</div>
|
|
);
|
|
},
|
|
|
|
render: function() {
|
|
const options = _.sortBy(
|
|
_.map(this.props.options, function(items, optionId) {
|
|
_.each(items, function(item) {
|
|
item.option = optionId;
|
|
});
|
|
items.option = optionId;
|
|
return items;
|
|
}),
|
|
'option'
|
|
);
|
|
|
|
return (
|
|
<div className="topology-options">
|
|
{options.map(function(items) {
|
|
return this.renderOption(items);
|
|
}, this)}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
});
|
|
|
|
module.exports = TopologyOptions;
|