Skip to content

Commit df729ea

Browse files
committed
feat(admin-ui): add notification
1 parent f1fd0ab commit df729ea

File tree

3 files changed

+113
-0
lines changed

3 files changed

+113
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import React from 'react'
2+
import Button from '@material-ui/core/Button'
3+
import ClickAwayListener from '@material-ui/core/ClickAwayListener'
4+
import Grow from '@material-ui/core/Grow'
5+
import Paper from '@material-ui/core/Paper'
6+
import Popper from '@material-ui/core/Popper'
7+
import List from '@material-ui/core/List'
8+
import ListItem from '@material-ui/core/ListItem'
9+
import ListItemText from '@material-ui/core/ListItemText'
10+
import { makeStyles } from '@material-ui/core/styles'
11+
import NotificationsIcon from '@material-ui/icons/Notifications'
12+
13+
const useStyles = makeStyles((theme) => ({
14+
root: {
15+
display: 'flex',
16+
},
17+
whiteColor: {
18+
color: '#FFFFFF',
19+
},
20+
paper: {
21+
marginRight: theme.spacing(2),
22+
},
23+
btnContainer: {
24+
position: 'relative',
25+
top: 8,
26+
textTransform: 'none',
27+
color: '#FFFFFF',
28+
},
29+
topElm: {
30+
zIndex: 9999
31+
}
32+
}))
33+
34+
export default function Lang() {
35+
const classes = useStyles()
36+
const [open, setOpen] = React.useState(false)
37+
const anchorRef = React.useRef(null)
38+
39+
const handleToggle = () => {
40+
setOpen((prevOpen) => !prevOpen)
41+
}
42+
43+
const handleClose = (event) => {
44+
if (anchorRef.current && anchorRef.current.contains(event.target)) {
45+
return
46+
}
47+
48+
setOpen(false)
49+
}
50+
51+
// return focus to the button when we transitioned from !open -> open
52+
const prevOpen = React.useRef(open)
53+
React.useEffect(() => {
54+
if (prevOpen.current === true && open === false) {
55+
anchorRef.current.focus()
56+
}
57+
58+
prevOpen.current = open
59+
}, [open])
60+
61+
return (
62+
<div className={classes.root}>
63+
<div>
64+
<Button
65+
ref={anchorRef}
66+
aria-controls={open ? 'menu-list-grow' : undefined}
67+
aria-haspopup="true"
68+
className={classes.btnContainer}
69+
onClick={handleToggle}
70+
>
71+
<NotificationsIcon />
72+
</Button>
73+
<Popper open={open} anchorEl={anchorRef.current} role={undefined} transition disablePortal className={classes.topElm}>
74+
{({ TransitionProps, placement }) => (
75+
<Grow
76+
{...TransitionProps}
77+
style={{ transformOrigin: placement === 'bottom' ? 'center top' : 'center bottom' }}
78+
>
79+
<Paper>
80+
<ClickAwayListener onClickAway={handleClose}>
81+
<List component="nav" aria-label="notification">
82+
<ListItem button>
83+
<ListItemText
84+
primary="User data has been updated"
85+
secondary="User data has been updated text detail description"
86+
/>
87+
</ListItem>
88+
<ListItem button>
89+
<ListItemText
90+
primary="License successfully added"
91+
secondary="License successfully added text detail description"
92+
/>
93+
</ListItem>
94+
<ListItem button>
95+
<ListItemText
96+
primary="Service Cache successfully removed"
97+
secondary="Service Cache successfully removed text detail description"
98+
/>
99+
</ListItem>
100+
</List>
101+
</ClickAwayListener>
102+
</Paper>
103+
</Grow>
104+
)}
105+
</Popper>
106+
</div>
107+
</div>
108+
)
109+
}

admin-ui/app/components/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import Navbar from './Navbar'
1919
import NavSearch from './NavSearch'
2020
import NavbarThemeProvider from './NavbarThemeProvider'
2121
import NestedDropdown from './NestedDropdown'
22+
import Notifications from './Notifications'
2223
import OuterClick from './OuterClick'
2324
import Progress from './Progress'
2425
import Sidebar from './Sidebar'
@@ -127,6 +128,7 @@ export {
127128
NavSearch,
128129
NavbarThemeProvider,
129130
NestedDropdown,
131+
Notifications,
130132
withPageConfig,
131133
setupPage,
132134
OuterClick,

admin-ui/app/routes/Apps/Gluu/GluuNavBar.js

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
Nav,
1111
NavItem,
1212
NavSearch,
13+
Notifications,
1314
SidebarTrigger,
1415
ThemeSetting,
1516
UncontrolledDropdown,
@@ -52,6 +53,7 @@ function GluuNavBar({ themeColor, themeStyle, userinfo }) {
5253
{/*<NavbarMessages />*/}
5354
{/*<NavbarActivityFeed />*/}
5455
<NavSearch />
56+
<Notifications />
5557
<LanguageMenu />
5658
<ThemeSetting />
5759
<UncontrolledDropdown nav inNavbar>

0 commit comments

Comments
 (0)