@@ -23,7 +23,7 @@ import {nodesApi} from '../../store/reducers/nodes/nodes';
2323import type { NodesPreparedEntity } from '../../store/reducers/nodes/types' ;
2424import { useProblemFilter } from '../../store/reducers/settings/hooks' ;
2525import type { AdditionalNodesProps } from '../../types/additionalProps' ;
26- import type { NodesGroupByField } from '../../types/api/nodes' ;
26+ import type { NodesGroupByField , NodesPeerRole } from '../../types/api/nodes' ;
2727import { useAutoRefreshInterval } from '../../utils/hooks' ;
2828import { useIsUserAllowedToMakeChanges } from '../../utils/hooks/useIsUserAllowedToMakeChanges' ;
2929import { useSelectedColumns } from '../../utils/hooks/useSelectedColumns' ;
@@ -169,6 +169,7 @@ function NodesComponent({
169169 const { searchValue, uptimeFilter, peerRoleFilter} = useNodesPageQueryParams ( groupByParams ) ;
170170 const { problemFilter} = useProblemFilter ( ) ;
171171 const viewerNodesHandlerHasGrouping = useViewerNodesHandlerHasGrouping ( ) ;
172+ const tableContainerRef = React . useRef < HTMLDivElement > ( null ) ;
172173
173174 const { columnsToShow, columnsToSelect, setColumns} = useSelectedColumns (
174175 columns ,
@@ -190,7 +191,7 @@ function NodesComponent({
190191 handleSelectedColumnsUpdate = { setColumns }
191192 />
192193 </ TableWithControlsLayout . Controls >
193- < TableWithControlsLayout . Table >
194+ < TableWithControlsLayout . Table ref = { tableContainerRef } >
194195 < NodesTable
195196 path = { path }
196197 database = { database }
@@ -200,6 +201,7 @@ function NodesComponent({
200201 peerRoleFilter = { peerRoleFilter }
201202 columns = { columnsToShow }
202203 parentRef = { parentRef }
204+ tableContainerRef = { tableContainerRef }
203205 />
204206 </ TableWithControlsLayout . Table >
205207 </ TableWithControlsLayout >
@@ -237,6 +239,63 @@ function NodesControlsWithTableState({
237239 ) ;
238240}
239241
242+ interface NodeGroupProps {
243+ name : string ;
244+ count : number ;
245+ isExpanded : boolean ;
246+ path ?: string ;
247+ database ?: string ;
248+ searchValue : string ;
249+ peerRoleFilter ?: NodesPeerRole ;
250+ groupByParam ?: NodesGroupByField ;
251+ columns : Column < NodesPreparedEntity > [ ] ;
252+ parentRef : React . RefObject < HTMLElement > ;
253+ onIsExpandedChange : ( name : string , isExpanded : boolean ) => void ;
254+ }
255+
256+ const NodeGroup = React . memo ( function NodeGroup ( {
257+ name,
258+ count,
259+ isExpanded,
260+ path,
261+ database,
262+ searchValue,
263+ peerRoleFilter,
264+ groupByParam,
265+ columns,
266+ parentRef,
267+ onIsExpandedChange,
268+ } : NodeGroupProps ) {
269+ const tableContainerRef = React . useRef < HTMLDivElement > ( null ) ;
270+
271+ return (
272+ < TableGroup
273+ key = { name }
274+ title = { name }
275+ count = { count }
276+ entityName = { i18n ( 'nodes' ) }
277+ expanded = { isExpanded }
278+ onIsExpandedChange = { onIsExpandedChange }
279+ ref = { tableContainerRef }
280+ >
281+ < NodesTable
282+ path = { path }
283+ database = { database }
284+ searchValue = { searchValue }
285+ problemFilter = { 'All' }
286+ uptimeFilter = { NodesUptimeFilterValues . All }
287+ peerRoleFilter = { peerRoleFilter }
288+ filterGroup = { name }
289+ filterGroupBy = { groupByParam }
290+ initialEntitiesCount = { count }
291+ columns = { columns }
292+ parentRef = { parentRef }
293+ tableContainerRef = { tableContainerRef }
294+ />
295+ </ TableGroup >
296+ ) ;
297+ } ) ;
298+
240299function GroupedNodesComponent ( {
241300 path,
242301 database,
@@ -250,6 +309,7 @@ function GroupedNodesComponent({
250309} : NodesComponentProps ) {
251310 const { searchValue, peerRoleFilter, groupByParam} = useNodesPageQueryParams ( groupByParams ) ;
252311 const [ autoRefreshInterval ] = useAutoRefreshInterval ( ) ;
312+ const tableContainerRef = React . useRef < HTMLDivElement > ( null ) ;
253313
254314 const { columnsToShow, columnsToSelect, setColumns} = useSelectedColumns (
255315 columns ,
@@ -299,28 +359,20 @@ function GroupedNodesComponent({
299359 const isExpanded = expandedGroups [ name ] ;
300360
301361 return (
302- < TableGroup
362+ < NodeGroup
303363 key = { name }
304- title = { name }
364+ name = { name }
305365 count = { count }
306- entityName = { i18n ( 'nodes' ) }
307- expanded = { isExpanded }
366+ isExpanded = { isExpanded }
367+ path = { path }
368+ database = { database }
369+ searchValue = { searchValue }
370+ peerRoleFilter = { peerRoleFilter }
371+ groupByParam = { groupByParam }
372+ columns = { columnsToShow }
373+ parentRef = { parentRef }
308374 onIsExpandedChange = { setIsGroupExpanded }
309- >
310- < NodesTable
311- path = { path }
312- database = { database }
313- searchValue = { searchValue }
314- problemFilter = { 'All' }
315- uptimeFilter = { NodesUptimeFilterValues . All }
316- peerRoleFilter = { peerRoleFilter }
317- filterGroup = { name }
318- filterGroupBy = { groupByParam }
319- initialEntitiesCount = { count }
320- columns = { columnsToShow }
321- parentRef = { parentRef }
322- />
323- </ TableGroup >
375+ />
324376 ) ;
325377 } ) ;
326378 }
@@ -341,7 +393,11 @@ function GroupedNodesComponent({
341393 />
342394 </ TableWithControlsLayout . Controls >
343395 { error ? < ResponseError error = { error } /> : null }
344- < TableWithControlsLayout . Table loading = { isLoading } className = { b ( 'groups-wrapper' ) } >
396+ < TableWithControlsLayout . Table
397+ ref = { tableContainerRef }
398+ loading = { isLoading }
399+ className = { b ( 'groups-wrapper' ) }
400+ >
345401 { renderGroups ( ) }
346402 </ TableWithControlsLayout . Table >
347403 </ TableWithControlsLayout >
0 commit comments