All files / javascripts/explorev2/components ControlPanelSection.jsx

0% Statements 0/15
0% Branches 0/4
100% Functions 0/0
0% Lines 0/15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48                                                                                               
import React from 'react';
import PropTypes from 'prop-types';
import { Panel } from 'react-bootstrap';
import InfoTooltipWithTrigger from '../../components/InfoTooltipWithTrigger';
 
const propTypes = {
  label: PropTypes.string,
  description: PropTypes.string,
  tooltip: PropTypes.string,
  children: PropTypes.node.isRequired,
};
 
const defaultProps = {
  label: null,
  description: null,
  tooltip: null,
};
 
export default class ControlPanelSection extends React.Component {
  renderHeader() {
    const { label, tooltip } = this.props;
    let header;
    if (label) {
      header = (
        <div>
          {label} &nbsp;
          {tooltip && <InfoTooltipWithTrigger label={label} tooltip={tooltip} />}
        </div>
      );
    }
    return header;
  }
 
  render() {
    return (
      <Panel
        className="control-panel-section"
        header={this.renderHeader()}
      >
        {this.props.children}
      </Panel>
    );
  }
}
 
ControlPanelSection.propTypes = propTypes;
ControlPanelSection.defaultProps = defaultProps;