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

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

Complexity

Total Complexity 1
Complexity/F 0

Size

Lines of Code 82
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
eloc 71
mnd 1
bc 1
fnc 0
dl 0
loc 82
ccs 7
cts 7
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 { styled } from '@material-ui/core/styles'
4
import AppBar from '@material-ui/core/AppBar'
5
import Toolbar from '@material-ui/core/Toolbar'
6
import Typography from '@material-ui/core/Typography'
7
import IconButton from '@material-ui/core/IconButton'
8
import MenuIcon from '@material-ui/icons/Menu'
9
import Badge from '@material-ui/core/Badge'
10
import AccountCircle from '@material-ui/icons/AccountCircle'
11
import NotificationsIcon from '@material-ui/icons/Notifications'
12
import { pages } from 'core/const/pages'
13
14 2
const NavBar = ({ classes, history, open, openDrawer, closeDrawer }) => {
15 6
  return (
16
    <Container>
17
      <AppBar position="static" className={classes.navbar}>
18
        <Toolbar>
19
          <IconButton
20
            edge="start"
21
            className={classes.menuButton}
22
            color="inherit"
23
            aria-label="menu"
24
            data-test-id="navbar-menu"
25 2
            onClick={() => (open ? closeDrawer() : openDrawer())}
26
          >
27
            <MenuIcon />
28
          </IconButton>
29
          <Typography
30
            variant="h1"
31
            data-test-id="navbar-title"
32
            className={classes.title}
33
            onClick={() => {
34 1
              history.push(pages.dashboard.url)
35
            }}
36
          >
37
            Dashboard
38
          </Typography>
39
          <div>
40
            <IconButton
41
              aria-label="show 17 new notifications"
42
              color="inherit"
43
              className={classes.icon}
44
            >
45
              <Badge badgeContent={17} color="secondary">
46
                <NotificationsIcon />
47
              </Badge>
48
            </IconButton>
49
            <IconButton
50
              edge="end"
51
              aria-label="account of current user"
52
              aria-haspopup="true"
53
              color="inherit"
54
              data-test-id="navbar-user-info"
55
              className={classes.icon}
56
              onClick={() => {
57 1
                history.push(pages.profile.url)
58
              }}
59
            >
60
              <AccountCircle />
61
            </IconButton>
62
          </div>
63
        </Toolbar>
64
      </AppBar>
65
    </Container>
66
  )
67
}
68
69
export default NavBar
70
71 2
NavBar.propTypes = {
72
  classes: PropTypes.object.isRequired,
73
  history: PropTypes.object.isRequired,
74
  open: PropTypes.bool,
75
  openDrawer: PropTypes.func,
76
  closeDrawer: PropTypes.func
77
}
78
79 2
const Container = styled('div')({
80
  flexGrow: 1
81
})
82