All files / comparison_chart/components/ChartWrapper index.jsx

60% Statements 3/5
100% Branches 0/0
0% Functions 0/1
60% Lines 3/5
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 72 73 74 75                        1x                                                                                 1x         1x                                
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import {
  ChartCard as Card,
  ChartHeader as Header,
} from '@bufferapp/analyze-shared-components';
import AddReport from '@bufferapp/add-report';
 
import ChartAndFooter from '../ChartAndFooter';
import Title from '../Title';
 
const ContentContainer = styled.div`
  position: relative;
  padding: 1rem 1.5rem
`;
 
class ChartWrapper extends PureComponent {
  render() {
    const {
      metrics,
      profiles,
      profileIds,
      loading,
      metricKey,
    } = this.props;
 
    return (
      <Card>
        <Header>
          <Title metricKey={metricKey} />
          <AddReport
            chart="comparison"
            state={{
              metricKey,
              profileIds,
              profiles,
            }}
          />
        </Header>
        <ContentContainer>
          <ChartAndFooter
            loading={loading}
            metrics={metrics}
            metricKey={metricKey}
            profiles={profiles}
          />
        </ContentContainer>
      </Card>
    );
  }
}
 
ChartWrapper.defaultProps = {
  loading: false,
  selectedProfiles: [],
};
 
ChartWrapper.propTypes = {
  loading: PropTypes.bool,
  metricKey: PropTypes.string.isRequired,
  // props used for generating chart
  metrics: PropTypes.shape({}).isRequired,
  profileIds: PropTypes.arrayOf(PropTypes.string).isRequired,
  profiles: PropTypes.arrayOf(PropTypes.shape({
    id: PropTypes.string.isRequired,
    username: PropTypes.string.isRequired,
    avatarUrl: PropTypes.string.isRequired,
    service: PropTypes.string.isRequired,
  })).isRequired,
};
 
export default ChartWrapper;