Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. ๐ซ Status page with uptime monitoring & API monitoring as code ๐ซ openstatus.dev
bun drizzle-orm monitoring monitoring-as-code nextjs observability on-call open-source shadcn-ui status-page statuspage synthetic-monitoring tinybird turso uptime uptime-checker uptime-monitor
Something went wrong. Try again.
3.2 kB ยท 104 lines
TSX
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105"use client";
import type { RouterOutputs } from "@openstatus/api";import type { PrivateLocation } from "@openstatus/db/src/schema";import type { ColumnDef } from "@tanstack/react-table";
import { HoverCardTimestamp } from "@/components/common/hover-card-timestamp";import { Pill } from "@/components/common/pill";import { TableCellDate } from "@/components/data-table/table-cell-date";import { config, getMetadata } from "@/data/audit-logs.client";import { cn } from "@/lib/utils";
type AuditLog = RouterOutputs["tinybird"]["auditLog"]["data"][number];
export function getColumns( privateLocations?: PrivateLocation[],): ColumnDef<AuditLog>[] { const metadata = getMetadata(privateLocations); return [ { id: "icon", accessorFn: (row) => row.action, header: () => null, enableSorting: false, enableHiding: false, cell: ({ row }) => { const value = row.getValue("action"); const { icon: Icon, color } = config[value as keyof typeof config]; if (!Icon) return null; return <Icon className={cn("size-4", color)} />; }, meta: { headerClassName: "w-7", }, }, { accessorKey: "action", header: "Action", enableSorting: false, enableHiding: false, cell: ({ row }) => { const value = row.getValue("action"); const { title } = config[value as keyof typeof config]; if (!title) return null; return <div>{title}</div>; }, }, { accessorKey: "metadata", header: "Information", enableSorting: false, enableHiding: false, cell: ({ row }) => { const value = row.getValue("metadata"); if (!value) return null; return ( <div className="flex flex-wrap gap-2"> {Object.entries(value) .filter(([key, value]) => metadata[key as keyof typeof metadata]?.visible(value), ) .map(([key, value]) => { return ( <Pill key={key} label={metadata[key as keyof typeof metadata].key} value={metadata[key as keyof typeof metadata]?.format( value, )} /> ); })} </div> ); }, }, { accessorKey: "timestamp", header: "Timestamp", enableSorting: false, enableHiding: false, cell: ({ row }) => { const value = row.getValue("timestamp"); if (value instanceof Date) { return ( <HoverCardTimestamp date={value}> <TableCellDate value={value} className="font-mono" /> </HoverCardTimestamp> ); } const date = new Date(Number(value)); if (Number.isNaN(date.getTime())) { return <div className="font-mono">{String(value)}</div>; }
return ( <HoverCardTimestamp date={date}> <TableCellDate value={date} className="font-mono" /> </HoverCardTimestamp> ); }, }, ];}