-
Notifications
You must be signed in to change notification settings - Fork 712
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #420 from weaveworks/without-system-containers
Add filtering options to views; add options for filtering out system containers & unconnected containers.
- Loading branch information
Showing
16 changed files
with
459 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
const React = require('react'); | ||
const _ = require('lodash'); | ||
const mui = require('material-ui'); | ||
const DropDownMenu = mui.DropDownMenu; | ||
|
||
const AppActions = require('../actions/app-actions'); | ||
|
||
const TopologyOptions = React.createClass({ | ||
|
||
componentDidMount: function() { | ||
this.fixWidth(); | ||
}, | ||
|
||
onChange: function(ev, index, item) { | ||
ev.preventDefault(); | ||
AppActions.changeTopologyOption(item.option, item.payload); | ||
}, | ||
|
||
renderOption: function(items) { | ||
let selected = 0; | ||
let key; | ||
const activeOptions = this.props.activeOptions; | ||
const menuItems = items.map(function(item, index) { | ||
if (activeOptions[item.option] && activeOptions[item.option] === item.value) { | ||
selected = index; | ||
} | ||
key = item.option; | ||
return { | ||
option: item.option, | ||
payload: item.value, | ||
text: item.display | ||
}; | ||
}); | ||
|
||
return ( | ||
<DropDownMenu menuItems={menuItems} onChange={this.onChange} key={key} | ||
selectedIndex={selected} /> | ||
); | ||
}, | ||
|
||
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" ref="container"> | ||
{options.map(function(items) { | ||
return this.renderOption(items); | ||
}, this)} | ||
</div> | ||
); | ||
}, | ||
|
||
componentDidUpdate: function() { | ||
this.fixWidth(); | ||
}, | ||
|
||
fixWidth: function() { | ||
const containerNode = this.refs.container.getDOMNode(); | ||
_.each(containerNode.childNodes, function(child) { | ||
// set drop down width to length of current label | ||
const label = child.getElementsByClassName('mui-menu-label')[0]; | ||
const width = label.getBoundingClientRect().width + 40; | ||
child.style.width = width + 'px'; | ||
}); | ||
} | ||
}); | ||
|
||
module.exports = TopologyOptions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.