Passed
Pull Request — master (#114)
by Huu-Phat
04:15
created

cms/src/core/components/Drawer.js   A

Complexity

Total Complexity 1
Complexity/F 0

Size

Lines of Code 60
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
eloc 50
mnd 1
bc 1
fnc 0
dl 0
loc 60
ccs 8
cts 8
cp 1
rs 10
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
1
import React from 'react'
2
import PropTypes from 'prop-types'
3
import { withStyles } from '@material-ui/core/styles'
4
import Drawer from '@material-ui/core/Drawer'
5
import List from '@material-ui/core/List'
6
import ListItem from '@material-ui/core/ListItem'
7
import ListItemIcon from '@material-ui/core/ListItemIcon'
8
import ListItemText from '@material-ui/core/ListItemText'
9
import { pages } from 'core/const/pages'
10
11 2
const LeftDrawer = ({ classes, open, history }) => (
12 3
  <Drawer
13
    className={classes.drawer}
14
    variant="persistent"
15
    anchor="left"
16
    open={open}
17
    classes={{
18
      paper: classes.drawerPaper
19
    }}
20
  >
21
    <div className={classes.drawerHeader}>Blogs</div>
22
    <NoPaddingList>
23
      {Object.keys(pages).map(key => {
24 15
        const page = pages[key]
25 15
        const isHighLight = history.location.pathname === page.url
26 15
        return (
27
          <ListItem
28
            button
29
            key={key}
30
            data-test-id={`drawer-item-${key}`}
31
            className={
32
              isHighLight ? classes.highLightListItem : classes.listItem
33
            }
34 1
            onClick={() => history.push(page.url)}
35
          >
36
            <ListItemIcon>{page.icon}</ListItemIcon>
37
            <ListItemText primary={page.name} />
38
          </ListItem>
39
        )
40
      })}
41
    </NoPaddingList>
42
  </Drawer>
43
)
44
45
export default LeftDrawer
46
47 2
LeftDrawer.propTypes = {
48
  classes: PropTypes.object,
49
  open: PropTypes.bool,
50
  history: PropTypes.object,
51
  openDrawer: PropTypes.func,
52
  closeDrawer: PropTypes.func
53
}
54
55 2
const NoPaddingList = withStyles({
56
  padding: {
57
    padding: 0
58
  }
59
})(List)
60