@@ -7,29 +7,39 @@ import {ResizeableDataTable} from '../ResizeableDataTable/ResizeableDataTable';
77import { shardsColumnIdToGetColumn } from './columns' ;
88import type { TopShardsColumnId } from './constants' ;
99import { TOP_SHARDS_COLUMNS_WIDTH_LS_KEY , isSortableTopShardsColumn } from './constants' ;
10+ import type { ShardsColumn } from './types' ;
1011
1112export interface ShardsTableProps
1213 extends Omit < ResizeableDataTableProps < KeyValueRow > , 'columnsWidthLSKey' | 'columns' > {
1314 columnsIds : TopShardsColumnId [ ] ;
1415 database : string ;
16+ columns ?: ShardsColumn [ ] ;
1517 schemaPath ?: string ;
1618}
1719
18- export function ShardsTable ( { columnsIds, schemaPath, database, ...props } : ShardsTableProps ) {
19- const columns = React . useMemo (
20- ( ) =>
21- columnsIds
22- . filter ( ( id ) => id in shardsColumnIdToGetColumn )
23- . map ( ( id ) => {
24- const column = shardsColumnIdToGetColumn [ id ] ( { database, schemaPath} ) ;
20+ export function ShardsTable ( {
21+ columnsIds,
22+ schemaPath,
23+ database,
24+ columns : propsColumns ,
25+ ...props
26+ } : ShardsTableProps ) {
27+ const columns = React . useMemo ( ( ) => {
28+ if ( propsColumns ) {
29+ return propsColumns ;
30+ }
2531
26- return {
27- ...column ,
28- sortable : isSortableTopShardsColumn ( column . name ) ,
29- } ;
30- } ) ,
31- [ columnsIds , database , schemaPath ] ,
32- ) ;
32+ return columnsIds
33+ . filter ( ( id ) => id in shardsColumnIdToGetColumn )
34+ . map ( ( id ) => {
35+ const column = shardsColumnIdToGetColumn [ id ] ( { database, schemaPath} ) ;
36+
37+ return {
38+ ...column ,
39+ sortable : isSortableTopShardsColumn ( column . name ) ,
40+ } ;
41+ } ) ;
42+ } , [ columnsIds , database , propsColumns , schemaPath ] ) ;
3343
3444 return (
3545 < ResizeableDataTable
0 commit comments