-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce basic error page (fixes #4)
- Loading branch information
1 parent
0663c6b
commit 1727ce4
Showing
12 changed files
with
287 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { cn } from "@/lib/utils"; | ||
import { NavLink } from "react-router-dom"; | ||
|
||
export const MenuLink = ({ to, children }) => ( | ||
<NavLink | ||
to={to} | ||
className={({ isActive }) => | ||
cn( | ||
`text-sm font-medium transition-colors hover:text-primary`, | ||
!isActive && "text-muted-foreground", | ||
) | ||
} | ||
> | ||
{children} | ||
</NavLink> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
"use client"; | ||
|
||
import { MiniFunctionSummary } from "@/components/stats/function-summary"; | ||
import { MiniStatsChart } from "@/components/stats/mini-stats-chart"; | ||
import { Badge } from "@/components/ui/badge"; | ||
import { Tooltipped } from "@/components/ui/tooltipped"; | ||
import { ColumnDef, Table } from "@tanstack/react-table"; | ||
import { formatRelative } from "date-fns"; | ||
import { CheckCircle2, CirclePause, CircleX } from "lucide-react"; | ||
import { Link } from "react-router-dom"; | ||
|
||
export type FunctionItem = { | ||
name: string; | ||
amount: number; | ||
status: "pending" | "processing" | "success" | "failed"; | ||
email: string; | ||
}; | ||
|
||
export const columns: ColumnDef<FunctionItem>[] = [ | ||
{ | ||
accessorKey: "error", | ||
header: "Error", | ||
cell: ({ row }) => { | ||
const error = row.getValue("error"); | ||
return ( | ||
<span> | ||
<b>{error.type || "Invocation failed"}</b> | ||
<br /> | ||
{error.message.toString().substring(0, 250)} | ||
</span> | ||
); | ||
}, | ||
}, | ||
{ | ||
accessorKey: "name", | ||
header: "Function", | ||
cell: ({ row }) => { | ||
const name = row.getValue("name") as string; | ||
return ( | ||
<Link | ||
to={`/functions/${row.original.region}/${name}/invocations`} | ||
className="block text-primary" | ||
> | ||
<span className="font-semibold block">{name}</span> | ||
</Link> | ||
); | ||
}, | ||
filterFn: (row, id, value) => | ||
row.getValue("name")?.toLowerCase().includes(value.toLowerCase()), | ||
}, | ||
{ | ||
accessorKey: "errors", | ||
header: "Occurrences", | ||
enableSorting: false, | ||
cell: ({ row }) => { | ||
return ( | ||
<div className="lg:mr-10"> | ||
<MiniStatsChart | ||
title="Occurrences" | ||
color="var(--chart-2)" | ||
region={row.original.region} | ||
name={ | ||
row.original.name + | ||
"." + | ||
row.original.sk.replace("error#", "error.") | ||
} | ||
/> | ||
</div> | ||
); | ||
}, | ||
}, | ||
{ | ||
accessorKey: "lastSeen", | ||
header: "Last seen", | ||
cell: ({ row }) => { | ||
const lastSeen = row.getValue("lastSeen"); | ||
if (!lastSeen) return <span>-</span>; | ||
return <span>{formatRelative(new Date(lastSeen), new Date())}</span>; | ||
}, | ||
}, | ||
{ | ||
accessorKey: "lastInvocation", | ||
header: "Latest trace", | ||
cell: ({ row }) => { | ||
return ( | ||
<Link | ||
to={`/functions/${row.original.region}/${row.original.name}/invocations/${row.original.lastInvocation}`} | ||
className="block text-primary" | ||
> | ||
<span className="text-xs block font-mono"> | ||
{row.original.lastInvocation.split("/").pop()} | ||
</span> | ||
</Link> | ||
); | ||
}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { DataTable } from "@/components/tables/data-table"; | ||
import { StatsChart } from "@/components/stats/stats-chart"; | ||
|
||
import { columns } from "./columns"; | ||
import { useData } from "@/lib/api"; | ||
import { DataTableFilter } from "@/components/tables/data-table-filter"; | ||
import { useMemo, useState } from "react"; | ||
import { Button } from "@/components/ui/button"; | ||
|
||
const Errors = () => { | ||
const [startKey, setStartKey] = useState(""); | ||
const [previousKeys, setPreviousKeys] = useState<string[]>([]); | ||
|
||
const { | ||
data: { errors, nextStartKey }, | ||
} = useData(`errors?startKey=${encodeURIComponent(startKey)}`, { | ||
suspense: true, | ||
}); | ||
|
||
const goBack = () => { | ||
setStartKey(previousKeys.pop()); | ||
setPreviousKeys(previousKeys); | ||
}; | ||
const goNext = () => { | ||
setPreviousKeys([...previousKeys, startKey]); | ||
setStartKey(nextStartKey); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<h1 className="text-2xl font-bold">Errors</h1> | ||
<p className="prose prose-sm mb-4"> | ||
Errors are collected from all traced functions. | ||
</p> | ||
<DataTable | ||
id="errors" | ||
defaultSorting={[{ id: "lastSeen", desc: true }]} | ||
pageSize={50} | ||
columns={columns} | ||
data={errors} | ||
/> | ||
<div className="flex items-center justify-between"> | ||
<div className="text-xs text-muted-foreground"> | ||
Page {previousKeys.length + 1} ({errors.length} items) | ||
</div> | ||
<div className="flex items-center justify-end space-x-2 py-4"> | ||
<Button | ||
variant="outline" | ||
size="sm" | ||
onClick={() => goBack()} | ||
disabled={!previousKeys.length} | ||
> | ||
Previous | ||
</Button> | ||
<Button | ||
variant="outline" | ||
size="sm" | ||
onClick={() => goNext()} | ||
disabled={!nextStartKey} | ||
> | ||
Next | ||
</Button> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Errors; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.