Skip to content

refactor: Remove user roles from dropdown #4419

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

Merged
merged 4 commits into from
Oct 7, 2022
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
4 changes: 2 additions & 2 deletions site/src/components/BorderedMenu/BorderedMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ const useStyles = makeStyles((theme) => ({

"&[data-variant='user-dropdown'] $paperRoot": {
paddingBottom: theme.spacing(1),
width: 292,
minWidth: 292,
},
},
paperRoot: {
width: "292px",
minWidth: 292,
border: `2px solid ${theme.palette.secondary.dark}`,
borderRadius: theme.shape.borderRadius,
boxShadow: theme.shadows[6],
Expand Down
5 changes: 2 additions & 3 deletions site/src/components/UserDropdown/UsersDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,10 @@ export const useStyles = makeStyles((theme) => ({

menuItem: {
height: navHeight,
padding: `${theme.spacing(1.5)}px 0px ${theme.spacing(1.5)}px ${theme.spacing(2.75)}px`,
padding: theme.spacing(1.5, 0),

"&:hover": {
backgroundColor: theme.palette.action.hover,
transition: "background-color 0.3s ease",
backgroundColor: "transparent",
},
},
}))
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { screen } from "@testing-library/react"
import { MockOwnerRole, MockUser } from "../../testHelpers/entities"
import { MockUser } from "../../testHelpers/entities"
import { render } from "../../testHelpers/renderHelpers"
import { Language, UserDropdownContent } from "./UserDropdownContent"

Expand All @@ -23,12 +23,6 @@ describe("UserDropdownContent", () => {
expect(screen.getByText(Language.signOutLabel)).toBeDefined()
})

it("displays the user's roles", () => {
render(<UserDropdownContent user={MockUser} onSignOut={jest.fn()} onPopoverClose={jest.fn()} />)

expect(screen.getByText(MockOwnerRole.display_name)).toBeDefined()
})

it("has the correct link for the account item", () => {
render(<UserDropdownContent user={MockUser} onSignOut={jest.fn()} onPopoverClose={jest.fn()} />)

Expand Down
27 changes: 2 additions & 25 deletions site/src/components/UserDropdownContent/UserDropdownContent.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Chip from "@material-ui/core/Chip"
import Divider from "@material-ui/core/Divider"
import ListItemIcon from "@material-ui/core/ListItemIcon"
import ListItemText from "@material-ui/core/ListItemText"
Expand All @@ -9,7 +8,6 @@ import AccountIcon from "@material-ui/icons/AccountCircleOutlined"
import { FC } from "react"
import { Link } from "react-router-dom"
import * as TypesGen from "../../api/typesGenerated"
import { Role } from "../../api/typesGenerated"
import { navHeight } from "../../theme/constants"
import { DocsIcon } from "../Icons/DocsIcon"
import { LogoutIcon } from "../Icons/LogoutIcon"
Expand Down Expand Up @@ -46,13 +44,6 @@ export const UserDropdownContent: FC<UserDropdownContentProps> = ({
</div>
<Typography className={styles.userName}>{user.username}</Typography>
<Typography className={styles.userEmail}>{user.email}</Typography>
<ul className={styles.chipContainer}>
{user.roles.map((role: Role) => (
<li key={role.name} className={styles.chipStyles}>
<Chip classes={{ root: styles.chipRoot }} label={role.display_name} />
</li>
))}
</ul>
</div>

<Divider />
Expand Down Expand Up @@ -94,7 +85,7 @@ export const UserDropdownContent: FC<UserDropdownContentProps> = ({

const useStyles = makeStyles((theme) => ({
root: {
paddingTop: theme.spacing(3),
padding: theme.spacing(3, 2),
textAlign: "center",
},
avatarContainer: {
Expand All @@ -116,27 +107,13 @@ const useStyles = makeStyles((theme) => ({
},
userName: {
fontSize: 16,
marginBottom: theme.spacing(0.5),
marginTop: theme.spacing(1),
},
userEmail: {
fontSize: 14,
letterSpacing: 0.2,
color: theme.palette.text.secondary,
},
chipContainer: {
display: "flex",
justifyContent: "center",
flexWrap: "wrap",
listStyle: "none",
margin: "0",
padding: `${theme.spacing(1.5)}px ${theme.spacing(2.75)}px`,
},
chipStyles: {
margin: theme.spacing(0.5),
},
chipRoot: {
backgroundColor: theme.palette.secondary.dark,
},
link: {
textDecoration: "none",
color: "inherit",
Expand Down