Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tschoffelen committed Sep 7, 2024
1 parent f528eb3 commit 0663c6b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ export function DataTableFilter<TData, TValue>({
variant="outline"
size="sm"
className={cn(
selectedValues.size < 1 && "text-muted-foreground",
"h-8 border-dashed",
selectedValues.size < 1 && "text-muted-foreground border-dashed",
"h-8",
)}
>
<PlusCircledIcon className="mr-2 h-4 w-4" />
Expand Down
4 changes: 3 additions & 1 deletion packages/dashboard/src/components/tables/data-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ interface DataTableProps<TData, TValue> {
columns: ColumnDef<TData, TValue>[];
data: TData[];
defaultSorting?: SortingState;
defaultVisibility?: Record<string, boolean>;
paginate?: boolean;
pageSize?: number;
children?: (table: Table<TData>) => React.ReactNode;
Expand All @@ -43,6 +44,7 @@ export function DataTable<TData, TValue>({
columns,
data,
defaultSorting = [],
defaultVisibility = {},
paginate = false,
pageSize = 20,
children,
Expand All @@ -62,7 +64,7 @@ export function DataTable<TData, TValue>({
);
const [columnVisibility, setColumnVisibility] = useUserState(
`table/${id}/visibility`,
[],
defaultVisibility,
);

const table = useReactTable({
Expand Down
12 changes: 12 additions & 0 deletions packages/dashboard/src/routes/functions/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ 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";

Expand Down Expand Up @@ -80,6 +81,17 @@ export const columns: ColumnDef<FunctionItem>[] = [
return <span>{row.getValue("memoryAllocated") || "-"} MB</span>;
},
},
{
accessorKey: "lastInvocation",
header: "Last invoked",
cell: ({ row }) => {
const lastInvocation = row.getValue("lastInvocation");
if (!lastInvocation) return <span>-</span>;
return (
<span>{formatRelative(new Date(lastInvocation), new Date())}</span>
);
},
},
{
accessorKey: "tags",
header: "Tags",
Expand Down
1 change: 1 addition & 0 deletions packages/dashboard/src/routes/functions/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const Functions = () => {
<DataTable
id="functions"
defaultSorting={[{ id: "name", desc: false }]}
defaultVisibility={{lastInvocation: false, tags: false}}
columns={columns}
data={mappedFunctions}
paginate
Expand Down
4 changes: 2 additions & 2 deletions packages/dashboard/src/routes/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default function Root() {
>
Functions
</Link>
<Link
{/* <Link
to="/issues"
className="text-sm font-medium text-muted-foreground transition-colors hover:text-primary"
>
Expand All @@ -62,7 +62,7 @@ export default function Root() {
className="text-sm font-medium text-muted-foreground transition-colors hover:text-primary"
>
Settings
</Link>
</Link> */}
</nav>
<div className="ml-auto flex items-center space-x-4">
<DatePicker />
Expand Down

0 comments on commit 0663c6b

Please sign in to comment.