All files / components/controls-menu controls-menu-tab.jsx

66.67% Statements 8/12
33.33% Branches 2/6
80% Functions 4/5
66.67% Lines 8/12
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            1x 1x 1x                   1x 1x 2x     2x         1x                  
import React from 'react';
import ReactDOM from 'react-dom';
import ControlsMenuTabSection from './controls-menu-tab-section.jsx';
 
class ControlsMenuTab extends React.Component {
  constructor(props) {
    super(props);
    this.getBetterChildren = this.getBetterChildren.bind(this);
    this.alertParentOfError = this.alertParentOfError.bind(this);
  }
  alertParentOfError(xhr, status, err) {
    if(this.props.passErr) {
      this.props.passErr(xhr, status, err);
    } else {
      console.error(xhr, status, err.toString());
    }
  }
  getBetterChildren() {
    Eif (this.props.children) {
      return React.Children.map(this.props.children, (child, i) => {
        Iif (child.type === ControlsMenuTabSection) {
          return React.cloneElement(child, { passErr: this.alertParentOfError });
        }
        return child;
      });
    }
  }
  render () {
    return (
      <div className="tab-pane" id={this.props.id}>
        {this.getBetterChildren()}
      </div>
    );
  }
}
 
export default ControlsMenuTab;