From 1ac6817cc7e71341091c0e91331fc68594e0de6d Mon Sep 17 00:00:00 2001 From: FeimeiChen <54688836+FeimeiChen@users.noreply.github.com> Date: Wed, 9 Oct 2024 14:11:44 -1000 Subject: [PATCH] Refactor The GroupingsTable --- ui/src/components/table/groupings-table.tsx | 51 +++---------------- .../ grouping-description-cell.tsx | 11 ++++ .../table-element/ grouping-name-cell.tsx | 17 +++++++ .../table-element/grouping-path-cell.tsx | 5 +- .../table-element/groupings-table-columns.tsx | 21 ++++++-- .../components/table/groupings-table.test.tsx | 20 -------- .../ grouping-description-cell.test.tsx | 30 +++++++++++ .../ grouping-name-cell.test.tsx | 13 +++++ 8 files changed, 97 insertions(+), 71 deletions(-) create mode 100644 ui/src/components/table/table-element/ grouping-description-cell.tsx create mode 100644 ui/src/components/table/table-element/ grouping-name-cell.tsx create mode 100644 ui/tests/components/table/table-element/ grouping-description-cell.test.tsx create mode 100644 ui/tests/components/table/table-element/ grouping-name-cell.test.tsx diff --git a/ui/src/components/table/groupings-table.tsx b/ui/src/components/table/groupings-table.tsx index cb3df24b..b63ccea1 100644 --- a/ui/src/components/table/groupings-table.tsx +++ b/ui/src/components/table/groupings-table.tsx @@ -1,5 +1,4 @@ 'use client'; - import { useReactTable, flexRender, @@ -12,17 +11,14 @@ import { } from '@tanstack/react-table'; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table'; import ColumnSettings from '@/components/table/table-element/column-settings'; -import GroupingsTableColumns from '@/components/table/table-element/groupings-table-columns'; + import PaginationBar from '@/components/table/table-element/pagination-bar'; import GlobalFilter from '@/components/table/table-element/global-filter'; import SortArrow from '@/components/table/table-element/sort-arrow'; import { useState } from 'react'; -import { SquarePen } from 'lucide-react'; -import GroupingPathCell from '@/components/table/table-element/grouping-path-cell'; -import Link from 'next/link'; import { useLocalStorage } from 'usehooks-ts'; import { GroupingPath } from '@/lib/types'; -import TooltipOnTruncate from '@/components/table/table-element/tooltip-on-truncate'; +import GroupingsTableColumns from '@/components/table/table-element/groupings-table-columns'; const pageSize = parseInt(process.env.NEXT_PUBLIC_PAGE_SIZE as string); @@ -49,8 +45,6 @@ const GroupingsTable = ({ groupingPaths }: { groupingPaths: GroupingPath[] }) => enableMultiSort: true }); - const columnCount = table.getHeaderGroups()[0].headers.length; - return ( <>