9
9
useViewerNodesHandlerHasGrouping ,
10
10
} from '../../store/reducers/capabilities/hooks' ;
11
11
import { storageApi } from '../../store/reducers/storage/storage' ;
12
+ import type { NodesGroupByField } from '../../types/api/nodes' ;
12
13
import { useAutoRefreshInterval } from '../../utils/hooks' ;
13
14
import { useAdditionalNodesProps } from '../../utils/hooks/useAdditionalNodesProps' ;
14
15
import { NodesUptimeFilterValues } from '../../utils/nodes' ;
@@ -17,12 +18,14 @@ import type {PaginatedStorageProps} from './PaginatedStorage';
17
18
import { StorageNodesControls } from './StorageControls/StorageControls' ;
18
19
import { PaginatedStorageNodesTable } from './StorageNodes/PaginatedStorageNodesTable' ;
19
20
import { useStorageNodesSelectedColumns } from './StorageNodes/columns/hooks' ;
21
+ import type { StorageNodesColumnsSettings } from './StorageNodes/columns/types' ;
20
22
import { TableGroup } from './TableGroup/TableGroup' ;
21
23
import { useExpandedGroups } from './TableGroup/useExpandedTableGroups' ;
22
24
import i18n from './i18n' ;
23
25
import { b , renderPaginatedTableErrorMessage } from './shared' ;
24
26
import type { StorageViewContext } from './types' ;
25
27
import { useStorageQueryParams } from './useStorageQueryParams' ;
28
+ import { useStorageColumnsSettings } from './utils' ;
26
29
27
30
import './Storage.scss' ;
28
31
@@ -68,9 +71,12 @@ function StorageNodesComponent({
68
71
69
72
const viewerNodesHandlerHasGrouping = useViewerNodesHandlerHasGrouping ( ) ;
70
73
74
+ const { handleDataFetched, columnsSettings} = useStorageColumnsSettings ( ) ;
75
+
71
76
const { columnsToShow, columnsToSelect, setColumns} = useStorageNodesColumnsToSelect ( {
72
77
database,
73
78
viewContext,
79
+ columnsSettings,
74
80
} ) ;
75
81
76
82
const renderControls : RenderControls = ( { totalEntities, foundEntities, inited} ) => {
@@ -101,6 +107,7 @@ function StorageNodesComponent({
101
107
renderErrorMessage = { renderPaginatedTableErrorMessage }
102
108
columns = { columnsToShow }
103
109
initialEntitiesCount = { initialEntitiesCount }
110
+ onDataFetched = { handleDataFetched }
104
111
/>
105
112
) ;
106
113
}
@@ -116,7 +123,7 @@ function GroupedStorageNodesComponent({
116
123
117
124
const { searchValue, storageNodesGroupByParam, handleShowAllNodes} = useStorageQueryParams ( ) ;
118
125
119
- const { columnsToShow , columnsToSelect, setColumns} = useStorageNodesColumnsToSelect ( {
126
+ const { columnsToSelect, setColumns} = useStorageNodesColumnsToSelect ( {
120
127
database,
121
128
viewContext,
122
129
} ) ;
@@ -168,19 +175,15 @@ function GroupedStorageNodesComponent({
168
175
expanded = { isExpanded }
169
176
onIsExpandedChange = { setIsGroupExpanded }
170
177
>
171
- < PaginatedStorageNodesTable
178
+ < StorageNodesTableGroupContent
172
179
database = { database }
173
180
parentRef = { parentRef }
174
181
nodeId = { nodeId }
175
182
groupId = { groupId }
176
183
searchValue = { searchValue }
177
- visibleEntities = { 'all' }
178
- nodesUptimeFilter = { NodesUptimeFilterValues . All }
179
- onShowAll = { handleShowAllNodes }
184
+ handleShowAllNodes = { handleShowAllNodes }
180
185
filterGroup = { name }
181
186
filterGroupBy = { storageNodesGroupByParam }
182
- renderErrorMessage = { renderPaginatedTableErrorMessage }
183
- columns = { columnsToShow }
184
187
initialEntitiesCount = { count }
185
188
/>
186
189
</ TableGroup >
@@ -206,12 +209,66 @@ function GroupedStorageNodesComponent({
206
209
) ;
207
210
}
208
211
212
+ interface StorageNodesTableGroupContentProps {
213
+ database ?: string ;
214
+ parentRef : React . RefObject < HTMLElement > ;
215
+ nodeId ?: string | number ;
216
+ groupId ?: string | number ;
217
+ searchValue : string ;
218
+ handleShowAllNodes : VoidFunction ;
219
+ filterGroup : string ;
220
+ filterGroupBy ?: NodesGroupByField ;
221
+ viewContext ?: StorageViewContext ;
222
+ initialEntitiesCount : number ;
223
+ }
224
+
225
+ function StorageNodesTableGroupContent ( {
226
+ database,
227
+ parentRef,
228
+ nodeId,
229
+ groupId,
230
+ searchValue,
231
+ handleShowAllNodes,
232
+ filterGroup,
233
+ filterGroupBy,
234
+ viewContext,
235
+ initialEntitiesCount,
236
+ } : StorageNodesTableGroupContentProps ) {
237
+ const { handleDataFetched, columnsSettings} = useStorageColumnsSettings ( ) ;
238
+ const { columnsToShow} = useStorageNodesColumnsToSelect ( {
239
+ database,
240
+ viewContext,
241
+ columnsSettings,
242
+ } ) ;
243
+
244
+ return (
245
+ < PaginatedStorageNodesTable
246
+ database = { database }
247
+ parentRef = { parentRef }
248
+ nodeId = { nodeId }
249
+ groupId = { groupId }
250
+ searchValue = { searchValue }
251
+ visibleEntities = { 'all' }
252
+ nodesUptimeFilter = { NodesUptimeFilterValues . All }
253
+ onShowAll = { handleShowAllNodes }
254
+ filterGroup = { filterGroup }
255
+ filterGroupBy = { filterGroupBy }
256
+ renderErrorMessage = { renderPaginatedTableErrorMessage }
257
+ columns = { columnsToShow }
258
+ initialEntitiesCount = { initialEntitiesCount }
259
+ onDataFetched = { handleDataFetched }
260
+ />
261
+ ) ;
262
+ }
263
+
209
264
function useStorageNodesColumnsToSelect ( {
210
265
database,
211
266
viewContext,
267
+ columnsSettings,
212
268
} : {
213
269
database ?: string ;
214
270
viewContext ?: StorageViewContext ;
271
+ columnsSettings ?: StorageNodesColumnsSettings ;
215
272
} ) {
216
273
const additionalNodesProps = useAdditionalNodesProps ( ) ;
217
274
const { visibleEntities} = useStorageQueryParams ( ) ;
@@ -221,5 +278,6 @@ function useStorageNodesColumnsToSelect({
221
278
visibleEntities,
222
279
database,
223
280
viewContext,
281
+ columnsSettings,
224
282
} ) ;
225
283
}
0 commit comments