Skip to content

Commit 2e5a3bd

Browse files
committed
fix(dashboard): keep the tenant logs page off application URLs
Every console path of one or two segments belongs to an application list or detail page, so /console/observability/logs took the Overview of an application named logs whose kind has the plural observability. Kubernetes names must start with an alphanumeric character, so the reserved "-" segment cannot collide with any application. Assisted-by: LLM Signed-off-by: ZverGuy <[email protected]>
1 parent 32a466f commit 2e5a3bd

4 files changed

Lines changed: 19 additions & 5 deletions

File tree

‎packages/system/dashboard/images/console/apps/console/src/routes/ConsolePage.routing.test.tsx‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ describe("ConsolePage routing", () => {
7171
expect(screen.queryByText(/Cluster-scoped capacity/i)).toBeNull()
7272
})
7373

74-
it("serves the tenant logs page under observability/", async () => {
74+
it("serves the tenant logs page under the reserved -/ segment", async () => {
7575
renderWithK8sProvider(
7676
<TenantProvider>
7777
<ConsolePage />
7878
</TenantProvider>,
79-
{ client: makeClient(), initialRoute: "/observability/logs" },
79+
{ client: makeClient(), initialRoute: "/-/observability/logs" },
8080
)
8181

8282
expect(await screen.findByText(/^Every application in/)).toBeInTheDocument()
@@ -94,4 +94,18 @@ describe("ConsolePage routing", () => {
9494
await waitFor(() => expect(client.list).toHaveBeenCalled())
9595
expect(screen.queryByText(/^Every application in/)).toBeNull()
9696
})
97+
98+
// No ApplicationDefinition plural or application name can be "-", so only
99+
// routes under it are safe from shadowing an application's own pages.
100+
it("leaves /observability/logs to an application named logs of kind observability", async () => {
101+
renderWithK8sProvider(
102+
<TenantProvider>
103+
<ConsolePage />
104+
</TenantProvider>,
105+
{ client: makeClient(), initialRoute: "/observability/logs" },
106+
)
107+
108+
expect(await screen.findByText("Loading…")).toBeInTheDocument()
109+
expect(screen.queryByText(/^Every application in/)).toBeNull()
110+
})
97111
})

‎packages/system/dashboard/images/console/apps/console/src/routes/ConsolePage.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export function ConsolePage() {
9797
path="migration/vmimporttasks/:name"
9898
element={<MigrationTaskDetailPage />}
9999
/>
100-
<Route path="observability/logs" element={<LogsPage />} />
100+
<Route path="-/observability/logs" element={<LogsPage />} />
101101
<Route path="new/:appName" element={<ApplicationOrderPage />} />
102102
<Route path=":plural/:name/edit" element={<ApplicationEditRoute />} />
103103
<Route path=":plural/:name/*" element={<ApplicationDetailPage />} />

‎packages/system/dashboard/images/console/apps/console/src/routes/sidebar-sections.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ describe("useConsoleSidebarSections — admin areas moved out", () => {
117117
wrapper: makeWrapper(client),
118118
})
119119
await waitFor(() => expect(result.current.length).toBeGreaterThan(0))
120-
expect(findItem(result.current, "Logs")?.to).toBe("/console/observability/logs")
120+
expect(findItem(result.current, "Logs")?.to).toBe("/console/-/observability/logs")
121121
expect(result.current.find((s) => s.title === "Observability")?.items).toHaveLength(1)
122122
})
123123
})

‎packages/system/dashboard/images/console/apps/console/src/routes/sidebar-sections.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export function useConsoleSidebarSections(): SidebarSection[] {
121121

122122
const observabilitySection: SidebarSection = {
123123
title: "Observability",
124-
items: [{ label: "Logs", to: "/console/observability/logs", icon: ScrollText }],
124+
items: [{ label: "Logs", to: "/console/-/observability/logs", icon: ScrollText }],
125125
}
126126

127127
return [...categorySections, backupsSection, migrationSection, observabilitySection]

0 commit comments

Comments
 (0)