-
Notifications
You must be signed in to change notification settings - Fork 6
Feature 2244 avatar click #2248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
dd7b089
f8bf3c0
22b12e5
26bd09d
24cecf8
8983a7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,6 @@ import { UPDATE_TOAST } from '../../context/actions'; | |
| import { useLocation, Link } from 'react-router-dom'; | ||
| import { AppContext } from '../../context/AppContext'; | ||
| import { getAvatarURL } from '../../api/api'; | ||
| import AvatarMenu from '@mui/material/Menu'; | ||
|
|
||
| import MenuIcon from '@mui/icons-material/Menu'; | ||
| import { styled, useTheme } from '@mui/material/styles'; | ||
|
|
@@ -32,7 +31,6 @@ import { | |
| List, | ||
| ListItem, | ||
| ListItemText, | ||
| MenuItem, | ||
| Modal, | ||
| Toolbar | ||
| } from '@mui/material'; | ||
|
|
@@ -149,7 +147,6 @@ function Menu() { | |
|
|
||
| const [mobileOpen, setMobileOpen] = useState(false); | ||
| const [open, setOpen] = useState(false); | ||
| const [anchorEl, setAnchorEl] = useState(null); | ||
| const [showHoursUpload, setShowHoursUpload] = useState(false); | ||
| const [selectedFile, setSelectedFile] = useState(null); | ||
| const feedbackLinks = getFeedbackLinks(isAdmin, isPDL, isSupervisor); | ||
|
|
@@ -180,10 +177,6 @@ function Menu() { | |
| return links; | ||
| }; | ||
|
|
||
| const handleClick = event => { | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is now handled by a |
||
| setAnchorEl(event.currentTarget); | ||
| }; | ||
|
|
||
| const uploadFile = async file => { | ||
| if (!file) { | ||
| return; | ||
|
|
@@ -278,10 +271,6 @@ function Menu() { | |
| setFeedbackOpen(false); | ||
| }; | ||
|
|
||
| const closeAvatarMenu = () => { | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no longer an avatar menu to close. |
||
| setAnchorEl(null); | ||
| }; | ||
|
|
||
| const closeHoursUpload = () => { | ||
| setShowHoursUpload(false); | ||
| setSelectedFile(null); | ||
|
|
@@ -305,7 +294,6 @@ function Menu() { | |
| component={Link} | ||
| to={path} | ||
| className={isSubLink ? classes.nested : null} | ||
| button | ||
| onClick={ | ||
| isSubLink | ||
| ? undefined | ||
|
|
@@ -413,14 +401,8 @@ function Menu() { | |
| <MenuIcon /> | ||
| </IconButton> | ||
| </Toolbar> | ||
| <div | ||
| ref={anchorRef} | ||
| aria-controls={open ? 'menu-list-grow' : undefined} | ||
| aria-haspopup="true" | ||
| onClick={handleToggle} | ||
| > | ||
| <Link to={`/profile/${id}`}> | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The avatar is now wrapped in a |
||
| <Avatar | ||
| onClick={handleClick} | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The click is now handled by the |
||
| src={getAvatarURL(workEmail)} | ||
| style={{ | ||
| position: 'absolute', | ||
|
|
@@ -430,32 +412,7 @@ function Menu() { | |
| textDecoration: 'none' | ||
| }} | ||
| /> | ||
| <AvatarMenu | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No more avatar menu. |
||
| id="simple-menu" | ||
| anchorEl={anchorEl} | ||
| keepMounted | ||
| open={Boolean(anchorEl)} | ||
| onClose={closeAvatarMenu} | ||
| > | ||
| <MenuItem | ||
| component={Link} | ||
| onClick={closeAvatarMenu} | ||
| to={`/profile/${id}`} | ||
| > | ||
| Profile | ||
| </MenuItem> | ||
| {isAdmin && ( | ||
| <MenuItem | ||
| onClick={() => { | ||
| closeAvatarMenu(); | ||
| openHoursUpload(); | ||
| }} | ||
| > | ||
| Upload Hours | ||
| </MenuItem> | ||
| )} | ||
| </AvatarMenu> | ||
| </div> | ||
| </Link> | ||
| </AppBar> | ||
| <nav className={classes.drawer}> | ||
| <Drawer | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,17 @@ | ||
| import React from 'react'; | ||
| import { render } from '@testing-library/react'; | ||
| import Menu from './Menu'; | ||
| import { BrowserRouter } from 'react-router-dom'; | ||
| import { MemoryRouter } from 'react-router-dom'; | ||
| import { AppContextProvider } from '../../context/AppContext'; | ||
|
|
||
| const testId = 'some-id'; | ||
| const initialState = { | ||
| state: { | ||
| userProfile: { | ||
| name: 'holmes', | ||
| memberProfile: { | ||
| id: testId, | ||
| pdlId: '', | ||
| title: 'Tester', | ||
| workEmail: 'test@tester.com' | ||
|
|
@@ -84,4 +88,19 @@ describe('<Menu />', () => { | |
| </AppContextProvider> | ||
| ); | ||
| }); | ||
|
|
||
| it('adds link to avatar', () => { | ||
| const { container } = render( | ||
| <AppContextProvider value={initialState}> | ||
| <BrowserRouter> | ||
| <Menu /> | ||
| </BrowserRouter> | ||
| </AppContextProvider> | ||
| ); | ||
| const link = container.querySelector('header > a'); | ||
| const href = link.getAttribute('href'); | ||
| const lastIndex = href.lastIndexOf('/'); | ||
| const id = href.substring(lastIndex + 1); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another way to grab the const id = href.split('/').pop() |
||
| expect(id).toBe(testId); | ||
| }); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clicking the avatar no longer displays a menu.