From 937b889a5118927af72c341e959dedc792be52c3 Mon Sep 17 00:00:00 2001 From: Ana Filipa de Almeida Date: Mon, 29 Apr 2024 16:45:33 +0100 Subject: [PATCH] INN 2967 Create expanded rows layout (#1305) * Add expanded option * Disable sorting for now * Update type --- .../functions/[slug]/runs/RunsTable.tsx | 51 +++++++++++++++---- .../functions/[slug]/runs/page.tsx | 14 ++++- 2 files changed, 53 insertions(+), 12 deletions(-) diff --git a/ui/apps/dashboard/src/app/(organization-active)/(dashboard)/env/[environmentSlug]/functions/[slug]/runs/RunsTable.tsx b/ui/apps/dashboard/src/app/(organization-active)/(dashboard)/env/[environmentSlug]/functions/[slug]/runs/RunsTable.tsx index 4e0203d3c0..c53e31924f 100644 --- a/ui/apps/dashboard/src/app/(organization-active)/(dashboard)/env/[environmentSlug]/functions/[slug]/runs/RunsTable.tsx +++ b/ui/apps/dashboard/src/app/(organization-active)/(dashboard)/env/[environmentSlug]/functions/[slug]/runs/RunsTable.tsx @@ -1,4 +1,4 @@ -import { useMemo } from 'react'; +import { Fragment, useMemo } from 'react'; import { FunctionRunStatusIcon } from '@inngest/components/FunctionRunStatusIcon'; import { Skeleton } from '@inngest/components/Skeleton'; import { IDCell, StatusCell, TextCell, TimeCell } from '@inngest/components/Table'; @@ -11,8 +11,10 @@ import { createColumnHelper, flexRender, getCoreRowModel, + getExpandedRowModel, useReactTable, type OnChangeFn, + type Row, type SortingState, } from '@tanstack/react-table'; @@ -29,9 +31,18 @@ type RunsTableProps = { sorting?: SortingState; setSorting?: OnChangeFn; isLoading?: boolean; + renderSubComponent: (props: { id: string }) => React.ReactElement; + getRowCanExpand: (row: Row) => boolean; }; -export default function RunsTable({ data = [], isLoading, sorting, setSorting }: RunsTableProps) { +export default function RunsTable({ + data = [], + isLoading, + sorting, + setSorting, + getRowCanExpand, + renderSubComponent, +}: RunsTableProps) { // Render 8 empty lines for skeletons when data is loading const tableData = useMemo(() => (isLoading ? Array(8).fill({}) : data), [isLoading, data]); @@ -50,6 +61,8 @@ export default function RunsTable({ data = [], isLoading, sorting, setSorting }: data: tableData, columns: tableColumns, getCoreRowModel: getCoreRowModel(), + getExpandedRowModel: getExpandedRowModel(), + getRowCanExpand, manualSorting: true, onSortingChange: setSorting, state: { @@ -72,7 +85,7 @@ export default function RunsTable({ data = [], isLoading, sorting, setSorting }: {headerGroup.headers.map((header) => ( {header.isPlaceholder ? null : (
( - - {row.getVisibleCells().map((cell) => ( - - {flexRender(cell.column.columnDef.cell, cell.getContext())} - - ))} - + + + {row.getVisibleCells().map((cell) => ( + + {flexRender(cell.column.columnDef.cell, cell.getContext())} + + ))} + + {row.getIsExpanded() && ( + + + {renderSubComponent({ id: row.id })} + + + )} + ))} @@ -147,6 +173,7 @@ const columns = [ ); }, header: 'Status', + enableSorting: false, }), columnHelper.accessor('id', { cell: (info) => { @@ -159,6 +186,7 @@ const columns = [ ); }, header: 'Run ID', + enableSorting: false, }), columnHelper.accessor('queuedAt', { cell: (info) => { @@ -173,6 +201,7 @@ const columns = [ ); }, header: 'Queued At', + enableSorting: false, }), columnHelper.accessor('endedAt', { cell: (info) => { @@ -187,6 +216,7 @@ const columns = [ ); }, header: 'Ended At', + enableSorting: false, }), columnHelper.accessor('durationMS', { cell: (info) => { @@ -199,5 +229,6 @@ const columns = [ ); }, header: 'Duration', + enableSorting: false, }), ]; diff --git a/ui/apps/dashboard/src/app/(organization-active)/(dashboard)/env/[environmentSlug]/functions/[slug]/runs/page.tsx b/ui/apps/dashboard/src/app/(organization-active)/(dashboard)/env/[environmentSlug]/functions/[slug]/runs/page.tsx index e9c9b941cd..35bb5d5fb0 100644 --- a/ui/apps/dashboard/src/app/(organization-active)/(dashboard)/env/[environmentSlug]/functions/[slug]/runs/page.tsx +++ b/ui/apps/dashboard/src/app/(organization-active)/(dashboard)/env/[environmentSlug]/functions/[slug]/runs/page.tsx @@ -32,6 +32,11 @@ const GetRunsDocument = graphql(` } `); +const renderSubComponent = ({ id }: { id: string }) => { + /* TODO: Render the timeline instead */ + return

Subrow {id}

; +}; + export default function RunsPage() { const [filteredStatus, setFilteredStatus, removeFilteredStatus] = useStringArraySearchParam('filterStatus'); @@ -75,8 +80,13 @@ export default function RunsPage() { {/* TODO: wire button */}
- {/* @ts-ignore */} - + true} + /> ); }