Skip to content

Commit eb7d947

Browse files
authored
resolves #3356 (#3408)
1 parent 9c12b4e commit eb7d947

File tree

4 files changed

+67
-1
lines changed

4 files changed

+67
-1
lines changed

site/src/AppRouter.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { FC, lazy, Suspense } from "react"
2-
import { Route, Routes } from "react-router-dom"
2+
import { Navigate, Route, Routes } from "react-router-dom"
33
import { AuthAndFrame } from "./components/AuthAndFrame/AuthAndFrame"
44
import { RequireAuth } from "./components/RequireAuth/RequireAuth"
55
import { SettingsLayout } from "./components/SettingsLayout/SettingsLayout"
@@ -25,6 +25,7 @@ const WorkspaceAppErrorPage = lazy(
2525
const TerminalPage = lazy(() => import("./pages/TerminalPage/TerminalPage"))
2626
const WorkspacesPage = lazy(() => import("./pages/WorkspacesPage/WorkspacesPage"))
2727
const CreateWorkspacePage = lazy(() => import("./pages/CreateWorkspacePage/CreateWorkspacePage"))
28+
const AuditPage = lazy(() => import("./pages/AuditPage/AuditPage"))
2829

2930
export const AppRouter: FC = () => (
3031
<Suspense fallback={<></>}>
@@ -109,6 +110,24 @@ export const AppRouter: FC = () => (
109110
/>
110111
</Route>
111112

113+
{/* REMARK: Route under construction
114+
Eventually, we should gate this page
115+
with permissions and licensing */}
116+
<Route path="/audit">
117+
<Route
118+
index
119+
element={
120+
process.env.NODE_ENV === "production" ? (
121+
<Navigate to="/workspaces" />
122+
) : (
123+
<AuthAndFrame>
124+
<AuditPage />
125+
</AuthAndFrame>
126+
)
127+
}
128+
></Route>
129+
</Route>
130+
112131
<Route path="settings" element={<SettingsLayout />}>
113132
<Route path="account" element={<AccountPage />} />
114133
<Route path="security" element={<SecurityPage />} />

site/src/components/NavbarView/NavbarView.test.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@ describe("NavbarView", () => {
77
const noop = () => {
88
return
99
}
10+
11+
const env = process.env
12+
13+
// REMARK: copying process.env so we don't mutate that object or encounter conflicts between tests
14+
beforeEach(() => {
15+
process.env = { ...env }
16+
})
17+
18+
// REMARK: restoring process.env
19+
afterEach(() => {
20+
process.env = env
21+
})
22+
1023
it("renders content", async () => {
1124
// When
1225
render(<NavbarView user={MockUser} onSignOut={noop} />)
@@ -48,4 +61,21 @@ describe("NavbarView", () => {
4861
const element = await screen.findByText("B")
4962
expect(element).toBeDefined()
5063
})
64+
65+
it("audit nav link has the correct href", async () => {
66+
render(<NavbarView user={MockUser} onSignOut={noop} />)
67+
const auditLink = await screen.findByText(navLanguage.audit)
68+
expect((auditLink as HTMLAnchorElement).href).toContain("/audit")
69+
})
70+
71+
it("audit nav link is only visible in development", async () => {
72+
process.env = {
73+
...env,
74+
NODE_ENV: "production",
75+
}
76+
77+
render(<NavbarView user={MockUser} onSignOut={noop} />)
78+
const auditLink = screen.queryByText(navLanguage.audit)
79+
expect(auditLink).not.toBeInTheDocument()
80+
})
5181
})

site/src/components/NavbarView/NavbarView.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const Language = {
2121
workspaces: "Workspaces",
2222
templates: "Templates",
2323
users: "Users",
24+
audit: "Audit",
2425
}
2526

2627
const NavItems: React.FC<{ className?: string; linkClassName?: string }> = ({ className }) => {
@@ -47,6 +48,14 @@ const NavItems: React.FC<{ className?: string; linkClassName?: string }> = ({ cl
4748
{Language.users}
4849
</NavLink>
4950
</ListItem>
51+
{/* REMARK: the below link is under-construction */}
52+
{process.env.NODE_ENV !== "production" && (
53+
<ListItem button className={styles.item}>
54+
<NavLink className={styles.link} to="/audit">
55+
{Language.audit}
56+
</NavLink>
57+
</ListItem>
58+
)}
5059
</List>
5160
)
5261
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { FC } from "react"
2+
3+
// REMARK: This page is in-progress and hidden from users
4+
const AuditPage: FC = () => {
5+
return <div>Audit</div>
6+
}
7+
8+
export default AuditPage

0 commit comments

Comments
 (0)