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 <maximbel2003@gmail.com>
This commit is contained in:
ZverGuy committed 2026-11-09 15:47:34 +07:00
1 parent 32a466fb14
commit 2e5a3bd6a7
4 files changed
+19 -5

No files matched your search

@@ -71,12 +71,12 @@ describe("ConsolePage routing", () => {
expect(screen.queryByText(/Cluster-scoped capacity/i)).toBeNull()
})
it("serves the tenant logs page under observability/", async () => {
it("serves the tenant logs page under the reserved -/ segment", async () => {
renderWithK8sProvider(
<TenantProvider>
<ConsolePage />
</TenantProvider>,
{ client: makeClient(), initialRoute: "/observability/logs" },
{ client: makeClient(), initialRoute: "/-/observability/logs" },
)
expect(await screen.findByText(/^Every application in/)).toBeInTheDocument()
@@ -94,4 +94,18 @@ describe("ConsolePage routing", () => {
await waitFor(() => expect(client.list).toHaveBeenCalled())
expect(screen.queryByText(/^Every application in/)).toBeNull()
})
// No ApplicationDefinition plural or application name can be "-", so only
// routes under it are safe from shadowing an application's own pages.
it("leaves /observability/logs to an application named logs of kind observability", async () => {
renderWithK8sProvider(
<TenantProvider>
<ConsolePage />
</TenantProvider>,
{ client: makeClient(), initialRoute: "/observability/logs" },
)
expect(await screen.findByText("Loading…")).toBeInTheDocument()
expect(screen.queryByText(/^Every application in/)).toBeNull()
})
})
@@ -97,7 +97,7 @@ export function ConsolePage() {
path="migration/vmimporttasks/:name"
element={<MigrationTaskDetailPage />}
/>
<Route path="observability/logs" element={<LogsPage />} />
<Route path="-/observability/logs" element={<LogsPage />} />
<Route path="new/:appName" element={<ApplicationOrderPage />} />
<Route path=":plural/:name/edit" element={<ApplicationEditRoute />} />
<Route path=":plural/:name/*" element={<ApplicationDetailPage />} />
@@ -117,7 +117,7 @@ describe("useConsoleSidebarSections — admin areas moved out", () => {
wrapper: makeWrapper(client),
})
await waitFor(() => expect(result.current.length).toBeGreaterThan(0))
expect(findItem(result.current, "Logs")?.to).toBe("/console/observability/logs")
expect(findItem(result.current, "Logs")?.to).toBe("/console/-/observability/logs")
expect(result.current.find((s) => s.title === "Observability")?.items).toHaveLength(1)
})
})
@@ -121,7 +121,7 @@ export function useConsoleSidebarSections(): SidebarSection[] {
const observabilitySection: SidebarSection = {
title: "Observability",
items: [{ label: "Logs", to: "/console/observability/logs", icon: ScrollText }],
items: [{ label: "Logs", to: "/console/-/observability/logs", icon: ScrollText }],
}
return [...categorySections, backupsSection, migrationSection, observabilitySection]