@@ -4,11 +4,12 @@ import {NoSearchResults} from '@gravity-ui/illustrations';
44import { skipToken } from '@reduxjs/toolkit/query' ;
55import { isNil } from 'lodash' ;
66
7- import type { RenderControls } from '../../../../components/PaginatedTable' ;
87import {
98 DEFAULT_TABLE_ROW_HEIGHT ,
109 ResizeablePaginatedTable ,
1110} from '../../../../components/PaginatedTable' ;
11+ import { PaginatedTableProvider } from '../../../../components/PaginatedTable/PaginatedTableContext' ;
12+ import { TableWithControlsLayout } from '../../../../components/TableWithControlsLayout/TableWithControlsLayout' ;
1213import { partitionsApi } from '../../../../store/reducers/partitions/partitions' ;
1314import { topicApi } from '../../../../store/reducers/topic' ;
1415import type { TopicDataRequest } from '../../../../types/api/topic' ;
@@ -53,6 +54,8 @@ export function TopicData({parentRef, path, database}: TopicDataProps) {
5354 const [ baseOffset , setBaseOffset ] = React . useState < number > ( ) ;
5455 const [ baseEndOffset , setBaseEndOffset ] = React . useState < number > ( ) ;
5556
57+ const tableContainerRef = React . useRef < HTMLDivElement > ( null ) ;
58+
5659 const startRef = React . useRef < number > ( ) ;
5760 startRef . current = startOffset ;
5861
@@ -186,22 +189,20 @@ export function TopicData({parentRef, path, database}: TopicDataProps) {
186189 }
187190 } , [ currentData , isFetching , scrollToOffset ] ) ;
188191
189- const renderControls : RenderControls = ( ) => {
190- return (
191- < TopicDataControls
192- // component has uncontrolled components inside, so it should be rerendered on filters reset
193- key = { controlsKey }
194- columnsToSelect = { columnsToSelect }
195- handleSelectedColumnsUpdate = { setColumns }
196- partitions = { partitions }
197- partitionsLoading = { partitionsLoading }
198- partitionsError = { partitionsError }
199- startOffset = { startOffset }
200- endOffset = { endOffset }
201- scrollToOffset = { scrollToOffset }
202- />
203- ) ;
204- } ;
192+ const renderControls = (
193+ < TopicDataControls
194+ // component has uncontrolled components inside, so it should be rerendered on filters reset
195+ key = { controlsKey }
196+ columnsToSelect = { columnsToSelect }
197+ handleSelectedColumnsUpdate = { setColumns }
198+ partitions = { partitions }
199+ partitionsLoading = { partitionsLoading }
200+ partitionsError = { partitionsError }
201+ startOffset = { startOffset }
202+ endOffset = { endOffset }
203+ scrollToOffset = { scrollToOffset }
204+ />
205+ ) ;
205206
206207 const renderEmptyDataMessage = ( ) => {
207208 const hasFilters = selectedOffset || startTimestamp ;
@@ -225,26 +226,37 @@ export function TopicData({parentRef, path, database}: TopicDataProps) {
225226 return (
226227 ! isNil ( baseOffset ) &&
227228 ! isNil ( baseEndOffset ) && (
228- < ResizeablePaginatedTable
229- columnsWidthLSKey = { TOPIC_DATA_COLUMNS_WIDTH_LS_KEY }
230- parentRef = { parentRef }
231- columns = { columnsToShow }
232- fetchData = { getTopicData }
233- initialEntitiesCount = { baseEndOffset - baseOffset }
234- limit = { TOPIC_DATA_FETCH_LIMIT }
235- renderControls = { renderControls }
236- renderErrorMessage = { renderPaginatedTableErrorMessage }
237- renderEmptyDataMessage = { renderEmptyDataMessage }
238- filters = { tableFilters }
239- tableName = "topicData"
240- rowHeight = { DEFAULT_TABLE_ROW_HEIGHT }
241- keepCache = { false }
242- getRowClassName = { ( row ) => {
243- return b ( 'row' , {
244- active : Boolean ( selectedOffset && String ( row . Offset ) === selectedOffset ) ,
245- } ) ;
246- } }
247- />
229+ < PaginatedTableProvider >
230+ < TableWithControlsLayout >
231+ < TableWithControlsLayout . Controls >
232+ { renderControls }
233+ </ TableWithControlsLayout . Controls >
234+ < TableWithControlsLayout . Table ref = { tableContainerRef } >
235+ < ResizeablePaginatedTable
236+ columnsWidthLSKey = { TOPIC_DATA_COLUMNS_WIDTH_LS_KEY }
237+ parentRef = { parentRef }
238+ tableContainerRef = { tableContainerRef }
239+ columns = { columnsToShow }
240+ fetchData = { getTopicData }
241+ initialEntitiesCount = { baseEndOffset - baseOffset }
242+ limit = { TOPIC_DATA_FETCH_LIMIT }
243+ renderErrorMessage = { renderPaginatedTableErrorMessage }
244+ renderEmptyDataMessage = { renderEmptyDataMessage }
245+ filters = { tableFilters }
246+ tableName = "topicData"
247+ rowHeight = { DEFAULT_TABLE_ROW_HEIGHT }
248+ keepCache = { false }
249+ getRowClassName = { ( row ) => {
250+ return b ( 'row' , {
251+ active : Boolean (
252+ selectedOffset && String ( row . Offset ) === selectedOffset ,
253+ ) ,
254+ } ) ;
255+ } }
256+ />
257+ </ TableWithControlsLayout . Table >
258+ </ TableWithControlsLayout >
259+ </ PaginatedTableProvider >
248260 )
249261 ) ;
250262}
0 commit comments