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

100% Statements 6/6
90% Branches 9/10
66.67% Functions 2/3
100% Lines 6/6
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 49          2x                       1x 1x 1x                             1x               1x            
import React from 'react';
import PropTypes from 'prop-types';
 
class NavSidebarUserPanel extends React.Component {
  render() {
    return (
      <div className="user-panel">
        {this.props.img ? (
          <div className="pull-left image">
            <img src={this.props.img} className="img-circle" alt={`${this.props.name ? `${this.props.name}'s '` : ''}Profile Avatar`} />
          </div>
        ) : ''}
        <div className="pull-left info">
          <p>{this.props.name}</p>
          <a
            href={this.props.link}
            onClick={this.props.onLinkClick ? e => {
               e.preventDefault();
               e.stopPropagation();
               this.props.onLinkClick();
             } : () => {}}
          >
            <span>
              <i className={`fa fa-circle ${this.props.isOnline ? 'text-success' : 'text-danger'}`} />
              &nbsp;
              {this.props.isOnline ? 'Online' : 'Offline'}
            </span>
          </a>
        </div>
      </div>
    );
  }
}
 
NavSidebarUserPanel.propTypes = {
  name: PropTypes.string,
  img: PropTypes.string,
  link: PropTypes.string,
  onLinkClick: PropTypes.func,
  isOnline: PropTypes.bool
};
 
NavSidebarUserPanel.defaultProps = {
  name: '',
  isOnline: false
};
 
export default NavSidebarUserPanel;