All files / nav-sidebar/components NavSidebar.jsx

100% Statements 8/8
75% Branches 3/4
100% Functions 2/2
100% Lines 7/7
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71                                1x                   1x       1x       1x 2x                                       1x           4x                  
import React from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import styled from 'styled-components';
 
import {
  grayLighter,
} from '@bufferapp/ui/style/colors';
 
import Label from './Label';
import Item from './Item';
import Channels from './Channels';
import NewsLink from './NewsLink';
import FeedbackLink from './FeedbackLink';
import AccountManagement from './AccountManagement';
 
const Sidebar = styled.div`
  display: flex;
  flex-direction: column;
  padding: 0.75rem 0;
  height: 100%;
  width: 200px;
  background: ${grayLighter};
  box-sizing: border-box;
`;
 
const bottomSectionStyle = {
  marginTop: 'auto',
};
 
const Group = styled.div`
  margin: 0 0 1.5rem;
`;
 
const NavSidebar = props => (
  <div>
    {props.channels.length > 0 && <Sidebar>
      <Group>
        <Item href="/" {...props}>Home</Item>
      </Group>
      <Channels {...props} />
      <div>
        <Label>Tools</Label>
        <Item href="/aggregates/" {...props}>Aggregates</Item>
        <Item href="/reports/" {...props}>Reports</Item>
      </div>
      <div style={bottomSectionStyle}>
        <AccountManagement {...props} />
        <NewsLink>What&apos;s New</NewsLink>
        <FeedbackLink email="hello+analyze@buffer.com">Send Feedback</FeedbackLink>
      </div>
    </Sidebar>}
  </div>
);
 
NavSidebar.propTypes = {
  channels: PropTypes.arrayOf(PropTypes.shape({
    service: PropTypes.string,
  })).isRequired,
};
 
const mapStateToProps = state => ({
  channels: state.navSidebar.channels,
  selectedProfileId: state.profiles.selectedProfile ? state.profiles.selectedProfile.id : '',
});
 
export default connect(
  mapStateToProps,
)(NavSidebar);