2016-11-17 17:12:41 +00:00
|
|
|
import React, { Component, PropTypes } from 'react';
|
|
|
|
|
import { isEqual, noop } from 'lodash';
|
|
|
|
|
|
|
|
|
|
import labelInterface from 'interfaces/label';
|
2017-01-16 20:59:01 +00:00
|
|
|
import PanelGroupItem from 'components/side_panels/HostSidePanel/PanelGroupItem';
|
|
|
|
|
import statusLabelsInterface from 'interfaces/status_labels';
|
2016-11-17 17:12:41 +00:00
|
|
|
|
|
|
|
|
class PanelGroup extends Component {
|
|
|
|
|
static propTypes = {
|
|
|
|
|
groupItems: PropTypes.arrayOf(labelInterface),
|
|
|
|
|
onLabelClick: PropTypes.func,
|
|
|
|
|
selectedLabel: labelInterface,
|
2017-01-16 20:59:01 +00:00
|
|
|
statusLabels: statusLabelsInterface,
|
2016-12-22 19:26:18 +00:00
|
|
|
type: PropTypes.string,
|
2016-11-17 17:12:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static defaultProps = {
|
|
|
|
|
onLabelClick: noop,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
renderGroupItem = (item) => {
|
|
|
|
|
const {
|
|
|
|
|
onLabelClick,
|
|
|
|
|
selectedLabel,
|
2017-01-16 20:59:01 +00:00
|
|
|
statusLabels,
|
2016-12-22 19:26:18 +00:00
|
|
|
type,
|
2016-11-17 17:12:41 +00:00
|
|
|
} = this.props;
|
|
|
|
|
const selected = isEqual(selectedLabel, item);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<PanelGroupItem
|
|
|
|
|
isSelected={selected}
|
|
|
|
|
item={item}
|
|
|
|
|
key={item.display_text}
|
|
|
|
|
onLabelClick={onLabelClick(item)}
|
2017-01-16 20:59:01 +00:00
|
|
|
statusLabels={statusLabels}
|
2016-12-22 19:26:18 +00:00
|
|
|
type={type}
|
2016-11-17 17:12:41 +00:00
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render () {
|
|
|
|
|
const { groupItems } = this.props;
|
|
|
|
|
const { renderGroupItem } = this;
|
2016-11-29 22:29:14 +00:00
|
|
|
const baseClass = 'panel-group';
|
2016-11-17 17:12:41 +00:00
|
|
|
|
|
|
|
|
return (
|
2016-11-29 22:29:14 +00:00
|
|
|
<div className={baseClass}>
|
2016-11-17 17:12:41 +00:00
|
|
|
{groupItems.map((item) => {
|
|
|
|
|
return renderGroupItem(item);
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default PanelGroup;
|