From c9a15cb8aed81e3b72d4e703c381474c6dc4db2b Mon Sep 17 00:00:00 2001 From: ZverGuy Date: Wed, 4 Nov 2026 18:56:01 +0700 Subject: [PATCH] fix(dashboard): suggest a longer metrics range only when there is one With the longest range already picked, the empty panel still told the reader to try a longer range, which the picker cannot offer. Assisted-by: LLM Signed-off-by: ZverGuy --- .../src/components/observability/MetricsView.test.tsx | 11 +++++++++++ .../src/components/observability/MetricsView.tsx | 6 ++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/system/dashboard/images/console/apps/console/src/components/observability/MetricsView.test.tsx b/packages/system/dashboard/images/console/apps/console/src/components/observability/MetricsView.test.tsx index b4c7fc3a4..d3f1fc1dd 100644 --- a/packages/system/dashboard/images/console/apps/console/src/components/observability/MetricsView.test.tsx +++ b/packages/system/dashboard/images/console/apps/console/src/components/observability/MetricsView.test.tsx @@ -87,6 +87,17 @@ describe("MetricsView", () => { for (const status of screen.getAllByRole("status")) expect(status).toHaveClass("h-[230px]") }) + it("suggests a longer range only while one exists", async () => { + const { client } = clientWith(() => Response.json({ status: "success", data: { resultType: "matrix", result: [] } })) + renderWithK8sProvider(, { client }) + await waitFor(() => expect(screen.getAllByText("Try a longer range.")).toHaveLength(3)) + + await userEvent.click(screen.getByRole("button", { name: "7d" })) + + await waitFor(() => expect(screen.getAllByText("No data for this range.")).toHaveLength(3)) + expect(screen.queryByText("Try a longer range.")).toBeNull() + }) + it("holds each chart's place while it loads", () => { const { client } = clientWith(() => new Promise(() => {})) diff --git a/packages/system/dashboard/images/console/apps/console/src/components/observability/MetricsView.tsx b/packages/system/dashboard/images/console/apps/console/src/components/observability/MetricsView.tsx index ce7bcbe38..fac2a6b91 100644 --- a/packages/system/dashboard/images/console/apps/console/src/components/observability/MetricsView.tsx +++ b/packages/system/dashboard/images/console/apps/console/src/components/observability/MetricsView.tsx @@ -23,6 +23,8 @@ export function MetricsView({ scope }: { scope: ObservabilityScope }) { const client = useK8sClient() const root = metricsRoot(scope) const [range, setRange] = useState("1h") + const rangeKeys = Object.keys(RANGES) as RangeKey[] + const longestRange = range === rangeKeys[rangeKeys.length - 1] const results = useQueries({ queries: METRIC_PANELS.map((panel) => ({ @@ -48,7 +50,7 @@ export function MetricsView({ scope }: { scope: ObservabilityScope }) {

Resource consumption

- +
{wide ? ( @@ -62,7 +64,7 @@ export function MetricsView({ scope }: { scope: ObservabilityScope }) { ) : isLoading || !data ? ( ) : data.series.length === 0 ? ( - + ) : ( )}