Skip to content

feat(site): Add Admin Dropdown menu #885

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 27 commits into from
Apr 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
More porting, wip
  • Loading branch information
presleyp committed Apr 6, 2022
commit a9e4dd4fa9dc507f3a0eeed4170a9775f433e68e
29 changes: 24 additions & 5 deletions site/src/components/BorderedMenu/types.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
/**
* Shared types used by multiple components go here.
*/
import SvgIcon from "@material-ui/core/SvgIcon";
import { RouteProps } from "react-router-dom";

import { RouteConfig } from "../../router"
export type RouteNavbarGroup = "main" | "admin"

export interface NavbarEntryProps extends Pick<RouteConfig, "description" | "featureFlag" | "Icon" | "label" | "path"> {
interface BasicRouteConfig {
path: string
/** Use to match when the path includes variables. */
re?: RegExp
component: RouteProps["component"]
enabled: boolean
label?: string
Icon?: typeof SvgIcon
group?: RouteNavbarGroup
hideNavbar?: boolean
description?: string
}

interface RouteConfigWithNav extends BasicRouteConfig {
label: string
icon: typeof SvgIcon
group: RouteNavbarGroup
}

export type RouteConfig = BasicRouteConfig | RouteConfigWithNav
export interface NavbarEntryProps extends Pick<RouteConfig, "description" | "Icon" | "label" | "path"> {
selected: boolean
className?: string
onClick?: () => void
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/Sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import List from "@material-ui/core/List"
import ListItem from "@material-ui/core/ListItem"
import { makeStyles } from "@material-ui/core/styles"
import React from "react"
import { combineClasses } from "../../util/combine-classes"
import { combineClasses } from "../../util/combineClasses"

export interface SidebarItem {
value: string
Expand Down
28 changes: 28 additions & 0 deletions site/src/util/combineClasses.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { combineClasses } from "./combineClasses"

const staticStyles = {
text: "MuiText",
success: "MuiText-Green",
warning: "MuiText-Red",
}

describe("combineClasses", () => {
it.each([
// Falsy
[undefined, undefined],
[{ [staticStyles.text]: false }, undefined],
[{ [staticStyles.text]: undefined }, undefined],
[[], undefined],

// Truthy
[{ [staticStyles.text]: true }, "MuiText"],
[{ [staticStyles.text]: true, [staticStyles.warning]: true }, "MuiText MuiText-Red"],
[[staticStyles.text], "MuiText"],

// Mixed
[{ [staticStyles.text]: true, [staticStyles.success]: false }, "MuiText"],
[[staticStyles.text, staticStyles.success], "MuiText MuiText-Green"],
])(`classNames(%p) returns %p`, (staticClasses, result) => {
expect(combineClasses(staticClasses)).toBe(result)
})
})
File renamed without changes.