mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 17:28:54 +00:00
dc4b97d15f
- Refactor imports of PropTypes to use the prop-types package - Upgrade dependencies that were setting off deprecation warnings
59 lines
1.3 KiB
JavaScript
59 lines
1.3 KiB
JavaScript
import React, { Component } from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { isEqual, noop } from 'lodash';
|
|
|
|
import labelInterface from 'interfaces/label';
|
|
import PanelGroupItem from 'components/side_panels/HostSidePanel/PanelGroupItem';
|
|
import statusLabelsInterface from 'interfaces/status_labels';
|
|
|
|
class PanelGroup extends Component {
|
|
static propTypes = {
|
|
groupItems: PropTypes.arrayOf(labelInterface),
|
|
onLabelClick: PropTypes.func,
|
|
selectedLabel: labelInterface,
|
|
statusLabels: statusLabelsInterface,
|
|
type: PropTypes.string,
|
|
};
|
|
|
|
static defaultProps = {
|
|
onLabelClick: noop,
|
|
};
|
|
|
|
renderGroupItem = (item) => {
|
|
const {
|
|
onLabelClick,
|
|
selectedLabel,
|
|
statusLabels,
|
|
type,
|
|
} = this.props;
|
|
const selected = isEqual(selectedLabel, item);
|
|
|
|
return (
|
|
<PanelGroupItem
|
|
isSelected={selected}
|
|
item={item}
|
|
key={item.display_text}
|
|
onLabelClick={onLabelClick(item)}
|
|
statusLabels={statusLabels}
|
|
type={type}
|
|
/>
|
|
);
|
|
}
|
|
|
|
render () {
|
|
const { groupItems } = this.props;
|
|
const { renderGroupItem } = this;
|
|
const baseClass = 'panel-group';
|
|
|
|
return (
|
|
<div className={baseClass}>
|
|
{groupItems.map((item) => {
|
|
return renderGroupItem(item);
|
|
})}
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default PanelGroup;
|