@@ -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 />
@@ -202,6 +220,64 @@ function GroupedStorageNodesComponent({
202220 ) ;
203221}
204222
223+ interface StorageNodesTableGroupContentProps {
224+ database ?: string ;
225+ parentRef : React . RefObject < HTMLElement > ;
226+ nodeId ?: string | number ;
227+ groupId ?: string | number ;
228+ searchValue : string ;
229+ handleShowAllNodes : VoidFunction ;
230+ filterGroup : string ;
231+ filterGroupBy ?: NodesGroupByField ;
232+ columns : StorageNodesColumn [ ] ;
233+ initialEntitiesCount : number ;
234+ }
235+
236+ function StorageNodesTableGroupContent ( {
237+ database,
238+ parentRef,
239+ nodeId,
240+ groupId,
241+ searchValue,
242+ handleShowAllNodes,
243+ filterGroup,
244+ filterGroupBy,
245+ columns,
246+ initialEntitiesCount,
247+ } : StorageNodesTableGroupContentProps ) {
248+ const [ tableStyle , setTableStyle ] = React . useState < React . CSSProperties > ( { } ) ;
249+
250+ const handleDataFetched = React . useCallback ( ( data : PaginatedTableData < PreparedStorageNode > ) => {
251+ if ( data ?. columnSettings ) {
252+ const { maxSlotsPerDisk, maxDisksPerNode} = data . columnSettings ;
253+ setTableStyle ( {
254+ [ MAX_SLOTS_CSS_VAR ] : maxSlotsPerDisk ,
255+ [ MAX_DISKS_CSS_VAR ] : maxDisksPerNode ,
256+ } as React . CSSProperties ) ;
257+ }
258+ } , [ ] ) ;
259+
260+ return (
261+ < PaginatedStorageNodesTable
262+ database = { database }
263+ parentRef = { parentRef }
264+ nodeId = { nodeId }
265+ groupId = { groupId }
266+ searchValue = { searchValue }
267+ visibleEntities = { 'all' }
268+ nodesUptimeFilter = { NodesUptimeFilterValues . All }
269+ onShowAll = { handleShowAllNodes }
270+ filterGroup = { filterGroup }
271+ filterGroupBy = { filterGroupBy }
272+ renderErrorMessage = { renderPaginatedTableErrorMessage }
273+ columns = { columns }
274+ initialEntitiesCount = { initialEntitiesCount }
275+ tableStyle = { tableStyle }
276+ onDataFetched = { handleDataFetched }
277+ />
278+ ) ;
279+ }
280+
205281function useStorageNodesColumnsToSelect ( {
206282 database,
207283 viewContext,
0 commit comments