From b2d5a1ffdfd27617f143c0cf02c10202e243a28b Mon Sep 17 00:00:00 2001 From: Owen Date: Fri, 17 Apr 2026 17:45:49 -0700 Subject: [PATCH] Remove weird extra status history component --- src/components/ProxyResourcesTable.tsx | 84 +------------------------- src/components/UptimeMiniBar.tsx | 16 ++++- 2 files changed, 17 insertions(+), 83 deletions(-) diff --git a/src/components/ProxyResourcesTable.tsx b/src/components/ProxyResourcesTable.tsx index 119ba9cab..cb56174f2 100644 --- a/src/components/ProxyResourcesTable.tsx +++ b/src/components/ProxyResourcesTable.tsx @@ -56,6 +56,7 @@ import { TooltipTrigger } from "@app/components/ui/tooltip"; import type { StatusHistoryResponse } from "@server/lib/statusHistory"; +import UptimeMiniBar from "./UptimeMiniBar"; export type TargetHealth = { targetId: number; @@ -338,82 +339,6 @@ export default function ProxyResourcesTable({ ); } - function ResourceStatusHistory({ - resourceId, - api - }: { - resourceId: number; - api: ReturnType; - }) { - const { data: history, isLoading: loading } = useQuery({ - queryKey: ["RESOURCE_STATUS_HISTORY", resourceId, 30], - queryFn: async ({ signal }) => { - const res = await api.get( - `/resource/${resourceId}/status-history`, - { - params: { days: 30 }, - signal - } - ); - return (res.data.data ?? res.data) as StatusHistoryResponse; - }, - staleTime: 5 * 60 * 1000, - meta: { api } - }); - - if (loading) { - return ( -
- {Array.from({ length: 90 }).map((_, i) => ( -
- ))} -
- ); - } - - if (!history) return null; - - return ( -
- -
- {history.days.map((bucket, i) => { - const colorClass = - bucket.status === "good" - ? "bg-green-500" - : bucket.status === "degraded" - ? "bg-yellow-500" - : bucket.status === "bad" - ? "bg-red-500" - : "bg-muted"; - return ( - - -
- - - - {bucket.date}:{" "} - {bucket.uptimePercent}% uptime - - - - ); - })} -
- - - {history.overallUptimePercent.toFixed(1)}% uptime - -
- ); - } - const proxyColumns: ExtendedColumnDef[] = [ { accessorKey: "name", @@ -517,14 +442,11 @@ export default function ProxyResourcesTable({ { id: "statusHistory", friendlyName: t("uptime30d"), - header: () => {t("statusHistory")}, + header: () => {t("uptime30d")}, cell: ({ row }) => { const resourceRow = row.original; return ( - + ); } }, diff --git a/src/components/UptimeMiniBar.tsx b/src/components/UptimeMiniBar.tsx index 5685b9ca5..b9574054a 100644 --- a/src/components/UptimeMiniBar.tsx +++ b/src/components/UptimeMiniBar.tsx @@ -39,6 +39,7 @@ const barColorClass: Record = { type UptimeMiniBarProps = { orgId?: string; siteId?: number; + resourceId?: number; healthCheckId?: number; days?: number; }; @@ -46,6 +47,7 @@ type UptimeMiniBarProps = { export default function UptimeMiniBar({ orgId, siteId, + resourceId, healthCheckId, days = 30 }: UptimeMiniBarProps) { @@ -60,12 +62,22 @@ export default function UptimeMiniBar({ const hcQuery = useQuery({ ...orgQueries.healthCheckStatusHistory({ orgId: orgId ?? "", healthCheckId: healthCheckId ?? 0, days }), - enabled: healthCheckId != null && siteId == null, + enabled: healthCheckId != null && siteId == null && resourceId == null, meta: { api }, staleTime: 5 * 60 * 1000 }); - const { data, isLoading } = siteId != null ? siteQuery : hcQuery; + const resourceQuery = useQuery({ + ...orgQueries.resourceStatusHistory({ resourceId, days }), + enabled: resourceId != null && siteId == null && healthCheckId == null, + meta: { api }, + staleTime: 5 * 60 * 1000 + }); + + const { data, isLoading } = + siteId != null ? siteQuery : + resourceId != null ? resourceQuery : + hcQuery; if (isLoading) { return (