@@ -16,17 +16,20 @@ import {EntitiesCount} from '../../components/EntitiesCount';
1616import {
1717 getStorageInfo ,
1818 setInitialState ,
19- getFilteredEntities ,
2019 setVisibleEntities ,
2120 setStorageFilter ,
2221 setUsageFilter ,
2322 setStorageType ,
2423 setNodesUptimeFilter ,
2524 setDataWasNotLoaded ,
26- getStoragePoolsGroupsCount ,
27- getStorageNodesCount ,
28- getUsageFilterOptions ,
2925} from '../../store/reducers/storage/storage' ;
26+ import {
27+ selectFilteredGroups ,
28+ selectFilteredNodes ,
29+ selectStorageNodesCount ,
30+ selectStorageGroupsCount ,
31+ selectUsageFilterOptions ,
32+ } from '../../store/reducers/storage/selectors' ;
3033import { VISIBLE_ENTITIES , STORAGE_TYPES } from '../../store/reducers/storage/constants' ;
3134import { getNodesList , selectNodesMap } from '../../store/reducers/nodesList' ;
3235import StorageGroups from './StorageGroups/StorageGroups' ;
@@ -54,7 +57,8 @@ class Storage extends React.Component {
5457 database : PropTypes . bool ,
5558 getStorageInfo : PropTypes . func ,
5659 setInitialState : PropTypes . func ,
57- flatListStorageEntities : PropTypes . array ,
60+ storageNodes : PropTypes . array ,
61+ storageGroups : PropTypes . array ,
5862 groupsCount : PropTypes . object ,
5963 nodesCount : PropTypes . object ,
6064 setStorageFilter : PropTypes . func ,
@@ -166,7 +170,8 @@ class Storage extends React.Component {
166170
167171 renderDataTable ( ) {
168172 const {
169- flatListStorageEntities,
173+ storageNodes,
174+ storageGroups,
170175 visibleEntities,
171176 nodesUptimeFilter,
172177 nodes,
@@ -179,7 +184,7 @@ class Storage extends React.Component {
179184 { storageType === STORAGE_TYPES . groups && (
180185 < StorageGroups
181186 visibleEntities = { visibleEntities }
182- data = { flatListStorageEntities }
187+ data = { storageGroups }
183188 tableSettings = { tableSettings }
184189 nodes = { nodes }
185190 onShowAll = { ( ) => this . onGroupVisibilityChange ( VISIBLE_ENTITIES . all ) }
@@ -189,7 +194,7 @@ class Storage extends React.Component {
189194 < StorageNodes
190195 visibleEntities = { visibleEntities }
191196 nodesUptimeFilter = { nodesUptimeFilter }
192- data = { flatListStorageEntities }
197+ data = { storageNodes }
193198 tableSettings = { tableSettings }
194199 onShowAll = { this . onShowAllNodes }
195200 additionalNodesInfo = { additionalNodesInfo }
@@ -219,18 +224,27 @@ class Storage extends React.Component {
219224 } ;
220225
221226 renderEntitiesCount ( ) {
222- const { storageType, groupsCount, nodesCount, flatListStorageEntities, loading, wasLoaded} =
223- this . props ;
227+ const {
228+ storageType,
229+ groupsCount,
230+ nodesCount,
231+ storageGroups,
232+ storageNodes,
233+ loading,
234+ wasLoaded,
235+ } = this . props ;
224236
225237 const entityName = storageType === STORAGE_TYPES . groups ? 'Groups' : 'Nodes' ;
226238 const count = storageType === STORAGE_TYPES . groups ? groupsCount : nodesCount ;
239+ const current =
240+ storageType === STORAGE_TYPES . groups ? storageGroups . length : storageNodes . length ;
227241
228242 return (
229243 < EntitiesCount
230244 label = { entityName }
231245 loading = { loading && ! wasLoaded }
232246 total = { count . total }
233- current = { flatListStorageEntities . length }
247+ current = { current }
234248 />
235249 ) ;
236250 }
@@ -318,11 +332,12 @@ function mapStateToProps(state) {
318332 } = state . storage ;
319333
320334 return {
321- flatListStorageEntities : getFilteredEntities ( state ) ,
322- groupsCount : getStoragePoolsGroupsCount ( state ) ,
335+ storageNodes : selectFilteredNodes ( state ) ,
336+ storageGroups : selectFilteredGroups ( state ) ,
337+ nodesCount : selectStorageNodesCount ( state ) ,
338+ groupsCount : selectStorageGroupsCount ( state ) ,
323339 autorefresh : state . schema . autorefresh ,
324340 nodes : selectNodesMap ( state ) ,
325- nodesCount : getStorageNodesCount ( state ) ,
326341 loading,
327342 wasLoaded,
328343 error,
@@ -331,7 +346,7 @@ function mapStateToProps(state) {
331346 filter,
332347 usageFilter,
333348 nodesUptimeFilter,
334- usageFilterOptions : getUsageFilterOptions ( state ) ,
349+ usageFilterOptions : selectUsageFilterOptions ( state ) ,
335350 } ;
336351}
337352
0 commit comments