Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion web-ui/src/components/edit_skills/EditSkillsCard.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { AppContextProvider } from '../../context/AppContext';
import { http, HttpResponse } from 'msw';
import { setupServer } from 'msw/node';
import { BrowserRouter } from 'react-router-dom';
import { act } from '@testing-library/react';

const currentUserProfile = {
id: 9876,
Expand Down
47 changes: 2 additions & 45 deletions web-ui/src/components/menu/Menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Copy link
Collaborator Author

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.


import MenuIcon from '@mui/icons-material/Menu';
import { styled, useTheme } from '@mui/material/styles';
Expand All @@ -32,7 +31,6 @@ import {
List,
ListItem,
ListItemText,
MenuItem,
Modal,
Toolbar
} from '@mui/material';
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -180,10 +177,6 @@ function Menu() {
return links;
};

const handleClick = event => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now handled by a Link component.

setAnchorEl(event.currentTarget);
};

const uploadFile = async file => {
if (!file) {
return;
Expand Down Expand Up @@ -278,10 +271,6 @@ function Menu() {
setFeedbackOpen(false);
};

const closeAvatarMenu = () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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);
Expand All @@ -305,7 +294,6 @@ function Menu() {
component={Link}
to={path}
className={isSubLink ? classes.nested : null}
button
onClick={
isSubLink
? undefined
Expand Down Expand Up @@ -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}`}>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The avatar is now wrapped in a Link that goes to the Profile page.

<Avatar
onClick={handleClick}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The click is now handled by the Link that wraps this Avatar component.

src={getAvatarURL(workEmail)}
style={{
position: 'absolute',
Expand All @@ -430,32 +412,7 @@ function Menu() {
textDecoration: 'none'
}}
/>
<AvatarMenu
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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
Expand Down
19 changes: 19 additions & 0 deletions web-ui/src/components/menu/Menu.test.jsx
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'
Expand Down Expand Up @@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another way to grab the id could be to split the string into an array and pop off the last element:

const id = href.split('/').pop()

expect(id).toBe(testId);
});
});
Loading