diff --git a/site/src/AppRouter.tsx b/site/src/AppRouter.tsx index d76dbc687da77..b7b0d0e6b9cf0 100644 --- a/site/src/AppRouter.tsx +++ b/site/src/AppRouter.tsx @@ -1,5 +1,5 @@ import { FC, lazy, Suspense } from "react" -import { Route, Routes } from "react-router-dom" +import { Navigate, Route, Routes } from "react-router-dom" import { AuthAndFrame } from "./components/AuthAndFrame/AuthAndFrame" import { RequireAuth } from "./components/RequireAuth/RequireAuth" import { SettingsLayout } from "./components/SettingsLayout/SettingsLayout" @@ -25,6 +25,7 @@ const WorkspaceAppErrorPage = lazy( const TerminalPage = lazy(() => import("./pages/TerminalPage/TerminalPage")) const WorkspacesPage = lazy(() => import("./pages/WorkspacesPage/WorkspacesPage")) const CreateWorkspacePage = lazy(() => import("./pages/CreateWorkspacePage/CreateWorkspacePage")) +const AuditPage = lazy(() => import("./pages/AuditPage/AuditPage")) export const AppRouter: FC = () => ( }> @@ -109,6 +110,24 @@ export const AppRouter: FC = () => ( /> + {/* REMARK: Route under construction + Eventually, we should gate this page + with permissions and licensing */} + + + ) : ( + + + + ) + } + > + + }> } /> } /> diff --git a/site/src/components/NavbarView/NavbarView.test.tsx b/site/src/components/NavbarView/NavbarView.test.tsx index 60740a8a4426b..c0755dbda196e 100644 --- a/site/src/components/NavbarView/NavbarView.test.tsx +++ b/site/src/components/NavbarView/NavbarView.test.tsx @@ -7,6 +7,19 @@ describe("NavbarView", () => { const noop = () => { return } + + const env = process.env + + // REMARK: copying process.env so we don't mutate that object or encounter conflicts between tests + beforeEach(() => { + process.env = { ...env } + }) + + // REMARK: restoring process.env + afterEach(() => { + process.env = env + }) + it("renders content", async () => { // When render() @@ -48,4 +61,21 @@ describe("NavbarView", () => { const element = await screen.findByText("B") expect(element).toBeDefined() }) + + it("audit nav link has the correct href", async () => { + render() + const auditLink = await screen.findByText(navLanguage.audit) + expect((auditLink as HTMLAnchorElement).href).toContain("/audit") + }) + + it("audit nav link is only visible in development", async () => { + process.env = { + ...env, + NODE_ENV: "production", + } + + render() + const auditLink = screen.queryByText(navLanguage.audit) + expect(auditLink).not.toBeInTheDocument() + }) }) diff --git a/site/src/components/NavbarView/NavbarView.tsx b/site/src/components/NavbarView/NavbarView.tsx index d982b35e3ad29..98dc8dd985e44 100644 --- a/site/src/components/NavbarView/NavbarView.tsx +++ b/site/src/components/NavbarView/NavbarView.tsx @@ -21,6 +21,7 @@ export const Language = { workspaces: "Workspaces", templates: "Templates", users: "Users", + audit: "Audit", } const NavItems: React.FC<{ className?: string; linkClassName?: string }> = ({ className }) => { @@ -47,6 +48,14 @@ const NavItems: React.FC<{ className?: string; linkClassName?: string }> = ({ cl {Language.users} + {/* REMARK: the below link is under-construction */} + {process.env.NODE_ENV !== "production" && ( + + + {Language.audit} + + + )} ) } diff --git a/site/src/pages/AuditPage/AuditPage.tsx b/site/src/pages/AuditPage/AuditPage.tsx new file mode 100644 index 0000000000000..c285ea2176eed --- /dev/null +++ b/site/src/pages/AuditPage/AuditPage.tsx @@ -0,0 +1,8 @@ +import { FC } from "react" + +// REMARK: This page is in-progress and hidden from users +const AuditPage: FC = () => { + return
Audit
+} + +export default AuditPage