Console [CNS-34]: Tanstack table in the console#36350
Open
leedqin wants to merge 2 commits intoMaterializeInc:mainfrom
Open
Console [CNS-34]: Tanstack table in the console#36350leedqin wants to merge 2 commits intoMaterializeInc:mainfrom
leedqin wants to merge 2 commits intoMaterializeInc:mainfrom
Conversation
- TanStack Table UniversalTable component with a loading skeleton, column headers. sort icons and wraps it around the basic chakra variants - `useUniversalTable` hook to expose basic TanStack table API defaults for sorting, searching and pagination - tableColumnBuilders have basic search and sorting functions for the table data. Unit tests for these functions are in the test file - TablePagination is a pagination component for the table - TableSearch -- search the rows across the table using lodash debounce - TableTypes for basic table variants, UniversalTableProps and table search props - tanstack table guide for documenting tanstack table usage
4535c40 to
0c796a3
Compare
- Clusters table is now paginated with sorting functionalities for the columns, search for the clusters and cluster names showing up as links
0c796a3 to
ebc1bc0
Compare
SangJunBak
reviewed
May 1, 2026
Comment on lines
+169
to
+170
| // Static columns: defined at module scope so the table never remounts on | ||
| // data refresh. Dynamic data is fetched inside cell components. |
Contributor
There was a problem hiding this comment.
I feel like we don't need this comment
Comment on lines
+30
to
+33
| const currentPage = pageIndex + 1; | ||
| const from = pageIndex * pageSize + 1; | ||
| const to = Math.min(currentPage * pageSize, totalRows); | ||
|
|
Contributor
There was a problem hiding this comment.
I feel like we should keep variables zero-indexed then in the view, represent it as 1-indexed.
| if (a == null) return 1; | ||
| if (b == null) return -1; | ||
|
|
||
| return String(a).localeCompare(String(b), undefined, { numeric: true }); |
Contributor
There was a problem hiding this comment.
Whoa didn't know this existed. Super cool!
| return columns.some((cell) => { | ||
| const value = cell.getValue(); | ||
| if (value == null) return false; | ||
| return String(value).toLowerCase().includes(search); |
Contributor
There was a problem hiding this comment.
JSX might get caught in this search
Contributor
There was a problem hiding this comment.
I can imagine as a default filter, this would be okay. Any reason why we couldn't use the builtin ones https://tanstack.com/table/v8/docs/framework/react/examples/filters-fuzzy?
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
We need to add some sorting, filtering capabilities for our console tables. Tanstack tables let us do that without rethinking our current UI designs and it is very easy to integrate with existing table components. TanStack table is a headless UI library that provides powerful abstractions for sorting, filtering, and global search. This implementation wraps TanStack Table with Chakra UI components to maintain the visual elements while also TanStack's headless UI capabilities.
Linear Issue CNS-34
Core Components
UniversalTable.tsuseReactTablewith sensible defaults for sorting, filtering, pagination, and pinningUniversalTable.tsx<Table>components. Handles headers, rows, sorting indicators, loading skeletons, and sticky columnsTablePagination.tsxTableSearch.tsxtableColumnBuilders.tssortingFunctions.nullsLastfor nullable columns andfilterFunctions.globalTextFilterfor cross-column searchtableTypes.tsTableVariant,UniversalTableProps, and module augmentation forColumnMeta(addstooltip,isTruncated,minWidth)guide-tanstack-table.mdPartial Fixes MaterializeInc/database-issues#11176, MaterializeInc/database-issues#10108
This will make navigating tables/ pages with a lot of objects especially Clusters page that customers can benefit from sorting and searching for clusters.
How do you feel about this change? (Tips for the reviewer)
Pretty good! I have migrated Clusters List to the Tanstack table.I would recommend reading the testing guide first before reviewing the code. Demo video: https://materializeinc.slack.com/files/U08QMH7H6TC/F0A2EV4REUC/cluster_table.mov
Addressed feedback from this console PR:
enablePaginationprop and otherenableconfigurationscurrentPagevariable instead ofpageIndex+1](https://github.com/MaterializeInc/console/pull/3872#discussion_r2682670127)