diff --git a/src/features/atlas/AtlasCard.tsx b/src/features/atlas/AtlasCard.tsx index 88ffaa5..1c0908c 100644 --- a/src/features/atlas/AtlasCard.tsx +++ b/src/features/atlas/AtlasCard.tsx @@ -34,7 +34,7 @@ import { AccuracyChip } from "../nodes/AccuracyChip"; import { useAtlasObserver } from "./useAtlasObserver"; import type { CardHandleProps } from "./useCardDrag"; import { ViewTabs } from "./ViewTabs"; -import { TelemetrySourceTag } from "../nodes/ForeignObserver"; +import { TelemetrySourceTag, telemetrySourceInfo } from "../nodes/ForeignObserver"; import { allLocal } from "../nodes/poller-seats"; import { PollerClaimTags } from "../nodes/NodePollerSection"; @@ -489,6 +489,10 @@ export function AtlasCard({ const lastReading = tab.polling?.latestReadingAt ?? telSample.latestAt; const pollerName = tab.polling?.poller?.name; const pollState = !tab.polling ? null : polledNow ? (pollerName ? t("atlas.telemetry.polledBy", { name: pollerName }) : t("atlas.telemetry.polled")) : t("atlas.telemetry.notPolled"); + // Readings from an observer this server does not manage are tagged in the footer. With nobody here polling, + // the tag stands in for "Not polled": the repeater is polled, only not by this server. + const outsideSource = tel.foreign === "all" || tel.foreign === "some"; + const localSource = allLocal(tab.polling?.foreign); const windowLabel = obs.sample.partial ? t("atlas.observerPartialCoverage") : t(`atlas.ranges.${range}`); const observerTile = (id: ObserverTile, slot: number) => { const sample = obs.sample; @@ -666,15 +670,17 @@ export function AtlasCard({ )} {view === "telemetry" && node && (
- {(tel.foreign === "all" || tel.foreign === "some") &&
}
{telemetryTiles.map((id, slot) => {telemetryTile(id, slot)})}
{footer( - tab.polling - ? lead(polledNow, t(polledNow ? "atlas.telemetry.polledShort" : "atlas.telemetry.notPolledShort"), polledNow ? lastReading : null) - : lastReading != null && lead(null, t("atlas.telemetry.lastReading"), lastReading), + <> + {tab.polling + ? (polledNow || !outsideSource) && lead(polledNow, t(polledNow ? "atlas.telemetry.polledShort" : "atlas.telemetry.notPolledShort"), polledNow ? lastReading : null) + : lastReading != null && lead(null, t("atlas.telemetry.lastReading"), lastReading)} + {outsideSource && } + , polledNow && pollerName ? t("atlas.telemetry.byPoller", { name: pollerName }) : "", tel, - [pollState, lastReading != null && `${t("atlas.telemetry.lastReading")} ${formatAbsolute(lastReading)}`, t("atlas.telemetry.help")], + [(polledNow || !outsideSource) && pollState, outsideSource && t(telemetrySourceInfo(localSource)), lastReading != null && `${t("atlas.telemetry.lastReading")} ${formatAbsolute(lastReading)}`, t("atlas.telemetry.help")], )}
)} diff --git a/src/features/nodes/ForeignObserver.tsx b/src/features/nodes/ForeignObserver.tsx index 1cf9bc9..b7fa825 100644 --- a/src/features/nodes/ForeignObserver.tsx +++ b/src/features/nodes/ForeignObserver.tsx @@ -10,12 +10,14 @@ import type { NodePollingForeign, TelemetryForeign } from "./types"; const TAG = "inline-flex shrink-0 items-center rounded-sm border px-1.5 py-px font-mono text-[10px] font-semibold tracking-wider uppercase"; const OUTSIDE = `${TAG} border-dashed border-text-muted/60 text-text-normal`; -// info overrides the foreign note, for a local-mode observer. -function OutsideTag({ label, info, chip = "foreign-observer" }: { label: string; info?: string; chip?: "foreign-observer" | "local-observer" }) { +// info overrides the foreign note, for a local-mode observer. bare leaves the note to a tip the row already has. +function OutsideTag({ label, info, chip = "foreign-observer", bare = false }: { label: string; info?: string; chip?: "foreign-observer" | "local-observer"; bare?: boolean }) { const { t } = useTranslation(); + const tag = {label}; + if (bare) return tag; return ( - {label} + {tag} ); @@ -33,13 +35,16 @@ export function LocalObserverTag({ source = false }: { source?: boolean }) { } // One tag for a telemetry panel, from the server's count of foreign readings behind it. -export function TelemetrySourceTag({ foreign, local = false }: { foreign: TelemetryForeign | undefined; local?: boolean }) { +export function TelemetrySourceTag({ foreign, local = false, bare = false }: { foreign: TelemetryForeign | undefined; local?: boolean; bare?: boolean }) { const { t } = useTranslation(); if (foreign !== "all" && foreign !== "some") return null; - if (local) return ; - return ; + if (local) return ; + return ; } +// What a bare source tag's row says about it in its own tip. +export const telemetrySourceInfo = (local: boolean): string => (local ? "nodeDetail.foreignObserver.localSourceInfo" : "nodeDetail.foreignObserver.info"); + export function AlsoCheckedTag() { const { t } = useTranslation(); return {t("nodeDetail.foreignObserver.alsoChecked")}; diff --git a/tests/features/atlas/AtlasCard.test.tsx b/tests/features/atlas/AtlasCard.test.tsx index ec45ae3..59c6942 100644 --- a/tests/features/atlas/AtlasCard.test.tsx +++ b/tests/features/atlas/AtlasCard.test.tsx @@ -717,8 +717,31 @@ describe("AtlasCard", () => { client.clear(); vi.mocked(api.getNodeTelemetry).mockResolvedValue({ ...week, foreign: "all" } as never); mount({ view: "telemetry" }); - expect(await screen.findByText("Foreign source")).toBeInTheDocument(); + const tag = await screen.findByText("Foreign source"); expect(screen.getByText("4.23V")).toBeInTheDocument(); + // It sits in the bottom row with the polling line, under the tiles, and that row has one info tip. + const row = tag.closest("[data-card-footer]") as HTMLElement; + expect(row).not.toBeNull(); + expect(within(row).getAllByRole("button")).toHaveLength(1); + expect(within(row).getByRole("button")).toHaveTextContent(/observer this site doesn't manage/); + // Nobody here polls it, and the tag says who does: the row does not also call it not polled. + expect(within(row).queryByText("Not polled")).toBeNull(); + expect(within(row).getByRole("button")).not.toHaveTextContent(/Not being polled/); + }); + + it("lets the source tag stand in for Not polled when nobody here polls the repeater", async () => { + vi.mocked(api.getNodePolling).mockResolvedValue(polling({ poller: null })); + const { unmount } = mount({ view: "telemetry" }); + await screen.findByText("4.23V"); + expect(screen.getByText("Not polled")).toBeInTheDocument(); + unmount(); + client.clear(); + vi.mocked(api.getNodeTelemetry).mockResolvedValue({ ...week, foreign: "all" } as never); + mount({ view: "telemetry" }); + const row = (await screen.findByText("Foreign source")).closest("[data-card-footer]") as HTMLElement; + expect(within(row).queryByText("Not polled")).toBeNull(); + expect(within(row).getByRole("button")).not.toHaveTextContent(/Not being polled/); + expect(within(row).getByRole("button")).toHaveTextContent(/observer this site doesn't manage/); }); it("draws two readings as dots, not a line", async () => {