Skip to content

chore: add users link to nav bar #1797

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 3 commits into from
May 26, 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
20 changes: 19 additions & 1 deletion site/src/components/NavbarView/NavbarView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { screen } from "@testing-library/react"
import React from "react"
import { MockUser } from "../../testHelpers/entities"
import { render } from "../../testHelpers/renderHelpers"
import { NavbarView } from "./NavbarView"
import { Language as navLanguage, NavbarView } from "./NavbarView"

describe("NavbarView", () => {
const noop = () => {
Expand All @@ -16,6 +16,24 @@ describe("NavbarView", () => {
await screen.findAllByText("Coder", { exact: false })
})

it("workspaces nav link has the correct href", async () => {
render(<NavbarView user={MockUser} onSignOut={noop} displayAdminDropdown />)
const workspacesLink = await screen.findByText(navLanguage.workspaces)
expect((workspacesLink as HTMLAnchorElement).href).toContain("/workspaces")
})

it("templates nav link has the correct href", async () => {
render(<NavbarView user={MockUser} onSignOut={noop} displayAdminDropdown />)
const templatesLink = await screen.findByText(navLanguage.templates)
expect((templatesLink as HTMLAnchorElement).href).toContain("/templates")
})

it("users nav link has the correct href", async () => {
render(<NavbarView user={MockUser} onSignOut={noop} displayAdminDropdown />)
const userLink = await screen.findByText(navLanguage.users)
expect((userLink as HTMLAnchorElement).href).toContain("/users")
})

it("renders profile picture for user", async () => {
// Given
const mockUser = {
Expand Down
15 changes: 13 additions & 2 deletions site/src/components/NavbarView/NavbarView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ export interface NavbarViewProps {
displayAdminDropdown: boolean
}

export const Language = {
workspaces: "Workspaces",
templates: "Templates",
users: "Users",
}
Copy link
Member Author

Choose a reason for hiding this comment

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

If this is overkill, just say the word. Was thinking about future us and our translated UI.

Copy link
Contributor

Choose a reason for hiding this comment

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

Praise: Looks great to me!


export const NavbarView: React.FC<NavbarViewProps> = ({ user, onSignOut, displayAdminDropdown }) => {
const styles = useStyles()
return (
Expand All @@ -27,12 +33,17 @@ export const NavbarView: React.FC<NavbarViewProps> = ({ user, onSignOut, display
</ListItem>
<ListItem button className={styles.item}>
<NavLink className={styles.link} to="/workspaces">
Workspaces
{Language.workspaces}
</NavLink>
</ListItem>
<ListItem button className={styles.item}>
<NavLink className={styles.link} to="/templates">
Templates
{Language.templates}
</NavLink>
</ListItem>
<ListItem button className={styles.item}>
<NavLink className={styles.link} to="/users">
{Language.users}
</NavLink>
</ListItem>
</List>
Expand Down