fleet/frontend/components/side_panels/HostSidePanel/PanelGroup/PanelGroup.jsx
Mike Stone bb62993ea5 Hosts side panel (#472)
* Host side panel

* Query form handles labels

* QueryComposer handles labels

* ManageHostsPage add label transitions

* Stop preventing default on click outside of ellipsis menu

* get labels from API

* use real label data in hosts side panel

* create label on label form submit

* adds platform dropdown

* Validate query text

* Label header

* validate presence of query text
2016-11-17 12:12:41 -05:00

50 lines
1.0 KiB
JavaScript

import React, { Component, PropTypes } from 'react';
import { isEqual, noop } from 'lodash';
import labelInterface from 'interfaces/label';
import PanelGroupItem from '../PanelGroupItem';
class PanelGroup extends Component {
static propTypes = {
groupItems: PropTypes.arrayOf(labelInterface),
onLabelClick: PropTypes.func,
selectedLabel: labelInterface,
};
static defaultProps = {
onLabelClick: noop,
};
renderGroupItem = (item) => {
const {
onLabelClick,
selectedLabel,
} = this.props;
const selected = isEqual(selectedLabel, item);
return (
<PanelGroupItem
isSelected={selected}
item={item}
key={item.display_text}
onLabelClick={onLabelClick(item)}
/>
);
}
render () {
const { groupItems } = this.props;
const { renderGroupItem } = this;
return (
<div>
{groupItems.map((item) => {
return renderGroupItem(item);
})}
</div>
);
}
}
export default PanelGroup;