All files / components/nav-sidebar nav-sidebar.jsx

63.64% Statements 7/11
33.33% Branches 2/6
75% Functions 3/4
63.64% Lines 7/11
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            1x 1x     1x                     1x 1x                   1x         1x            
import React from 'react';
import NavSidebarUserPanel from './nav-sidebar-user-panel.jsx';
import PropTypes from 'prop-types';
 
class NavSidebar extends React.Component {
  constructor(props) {
    super(props);
    this.getBetterChildren = this.getBetterChildren.bind(this);
  }
  getBetterChildren() {
    Iif (this.props.children) {
      return React.Children.map(this.props.children, (child, i) => {
        if (child.type === NavSidebarUserPanel) {
          return React.cloneElement(child, { passErr: this.props.passErr, key: i });
        } else {
          return React.cloneElement(child, { key: i });
        }
      });
    }
  }
  render() {
    const betterChildren = this.getBetterChildren();
    return (
      <aside className={`main-sidebar${this.props.lightTheme ? ' main-sidebar-light' : ''}`}>
        <section className="sidebar">
          {betterChildren}
        </section>
      </aside>
    );
  }
}
 
NavSidebar.propTypes = {
  passErr: PropTypes.string,
  lightTheme: PropTypes.bool
};
 
NavSidebar.defaultProps = {
  lightTheme: false
};
 
 
export default NavSidebar;