@@ -3,12 +3,15 @@ import React from 'react';
33import { ResponseError } from '../../components/Errors/ResponseError' ;
44import { LoaderWrapper } from '../../components/LoaderWrapper/LoaderWrapper' ;
55import type { RenderControls } from '../../components/PaginatedTable' ;
6+ import type { PaginatedTableData } from '../../components/PaginatedTable/types' ;
67import { TableWithControlsLayout } from '../../components/TableWithControlsLayout/TableWithControlsLayout' ;
78import {
89 useCapabilitiesLoaded ,
910 useViewerNodesHandlerHasGrouping ,
1011} from '../../store/reducers/capabilities/hooks' ;
1112import { storageApi } from '../../store/reducers/storage/storage' ;
13+ import type { PreparedStorageNode } from '../../store/reducers/storage/types' ;
14+ import type { NodesGroupByField } from '../../types/api/nodes' ;
1215import { useAutoRefreshInterval } from '../../utils/hooks' ;
1316import { useAdditionalNodesProps } from '../../utils/hooks/useAdditionalNodesProps' ;
1417import { NodesUptimeFilterValues } from '../../utils/nodes' ;
@@ -17,6 +20,7 @@ import type {PaginatedStorageProps} from './PaginatedStorage';
1720import { StorageNodesControls } from './StorageControls/StorageControls' ;
1821import { PaginatedStorageNodesTable } from './StorageNodes/PaginatedStorageNodesTable' ;
1922import { useStorageNodesSelectedColumns } from './StorageNodes/columns/hooks' ;
23+ import type { StorageNodesColumn } from './StorageNodes/columns/types' ;
2024import { TableGroup } from './TableGroup/TableGroup' ;
2125import { useExpandedGroups } from './TableGroup/useExpandedTableGroups' ;
2226import i18n from './i18n' ;
@@ -55,6 +59,9 @@ export const PaginatedStorageNodes = (props: PaginatedStorageProps) => {
5559 return < LoaderWrapper loading = { ! capabilitiesLoaded } > { renderContent ( ) } </ LoaderWrapper > ;
5660} ;
5761
62+ const MAX_SLOTS_CSS_VAR = '--maximum-slots' ;
63+ const MAX_DISKS_CSS_VAR = '--maximum-disks' ;
64+
5865function StorageNodesComponent ( {
5966 database,
6067 nodeId,
@@ -73,6 +80,18 @@ function StorageNodesComponent({
7380 viewContext,
7481 } ) ;
7582
83+ const [ tableStyle , setTableStyle ] = React . useState < React . CSSProperties > ( { } ) ;
84+
85+ const handleDataFetched = React . useCallback ( ( data : any ) => {
86+ if ( data ?. columnSettings ) {
87+ const { maxSlotsPerDisk, maxDisksPerNode} = data . columnSettings ;
88+ setTableStyle ( {
89+ [ MAX_SLOTS_CSS_VAR ] : maxSlotsPerDisk ,
90+ [ MAX_DISKS_CSS_VAR ] : maxDisksPerNode ,
91+ } as React . CSSProperties ) ;
92+ }
93+ } , [ ] ) ;
94+
7695 const renderControls : RenderControls = ( { totalEntities, foundEntities, inited} ) => {
7796 return (
7897 < StorageNodesControls
@@ -101,6 +120,8 @@ function StorageNodesComponent({
101120 renderErrorMessage = { renderPaginatedTableErrorMessage }
102121 columns = { columnsToShow }
103122 initialEntitiesCount = { initialEntitiesCount }
123+ tableStyle = { tableStyle }
124+ onDataFetched = { handleDataFetched }
104125 />
105126 ) ;
106127}
@@ -168,18 +189,15 @@ function GroupedStorageNodesComponent({
168189 expanded = { isExpanded }
169190 onIsExpandedChange = { setIsGroupExpanded }
170191 >
171- < PaginatedStorageNodesTable
192+ < StorageNodesTableGroupContent
172193 database = { database }
173194 parentRef = { parentRef }
174195 nodeId = { nodeId }
175196 groupId = { groupId }
176197 searchValue = { searchValue }
177- visibleEntities = { 'all' }
178- nodesUptimeFilter = { NodesUptimeFilterValues . All }
179- onShowAll = { handleShowAllNodes }
198+ handleShowAllNodes = { handleShowAllNodes }
180199 filterGroup = { name }
181200 filterGroupBy = { storageNodesGroupByParam }
182- renderErrorMessage = { renderPaginatedTableErrorMessage }
183201 columns = { columnsToShow }
184202 initialEntitiesCount = { count }
185203 />
@@ -206,6 +224,64 @@ function GroupedStorageNodesComponent({
206224 ) ;
207225}
208226
227+ interface StorageNodesTableGroupContentProps {
228+ database ?: string ;
229+ parentRef : React . RefObject < HTMLElement > ;
230+ nodeId ?: string | number ;
231+ groupId ?: string | number ;
232+ searchValue : string ;
233+ handleShowAllNodes : VoidFunction ;
234+ filterGroup : string ;
235+ filterGroupBy ?: NodesGroupByField ;
236+ columns : StorageNodesColumn [ ] ;
237+ initialEntitiesCount : number ;
238+ }
239+
240+ function StorageNodesTableGroupContent ( {
241+ database,
242+ parentRef,
243+ nodeId,
244+ groupId,
245+ searchValue,
246+ handleShowAllNodes,
247+ filterGroup,
248+ filterGroupBy,
249+ columns,
250+ initialEntitiesCount,
251+ } : StorageNodesTableGroupContentProps ) {
252+ const [ tableStyle , setTableStyle ] = React . useState < React . CSSProperties > ( { } ) ;
253+
254+ const handleDataFetched = React . useCallback ( ( data : PaginatedTableData < PreparedStorageNode > ) => {
255+ if ( data ?. columnSettings ) {
256+ const { maxSlotsPerDisk, maxDisksPerNode} = data . columnSettings ;
257+ setTableStyle ( {
258+ [ MAX_SLOTS_CSS_VAR ] : maxSlotsPerDisk ,
259+ [ MAX_DISKS_CSS_VAR ] : maxDisksPerNode ,
260+ } as React . CSSProperties ) ;
261+ }
262+ } , [ ] ) ;
263+
264+ return (
265+ < PaginatedStorageNodesTable
266+ database = { database }
267+ parentRef = { parentRef }
268+ nodeId = { nodeId }
269+ groupId = { groupId }
270+ searchValue = { searchValue }
271+ visibleEntities = { 'all' }
272+ nodesUptimeFilter = { NodesUptimeFilterValues . All }
273+ onShowAll = { handleShowAllNodes }
274+ filterGroup = { filterGroup }
275+ filterGroupBy = { filterGroupBy }
276+ renderErrorMessage = { renderPaginatedTableErrorMessage }
277+ columns = { columns }
278+ initialEntitiesCount = { initialEntitiesCount }
279+ tableStyle = { tableStyle }
280+ onDataFetched = { handleDataFetched }
281+ />
282+ ) ;
283+ }
284+
209285function useStorageNodesColumnsToSelect ( {
210286 database,
211287 viewContext,
0 commit comments