Skip to content

Commit b438f70

Browse files
committed
feat(Storage): show total nodes count
1 parent 5e31cfe commit b438f70

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/containers/Storage/Storage.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
setStorageType,
2222
VisibleEntitiesTitles,
2323
getStoragePoolsGroupsCount,
24+
getStorageNodesCount,
2425
} from '../../store/reducers/storage';
2526
import {getNodesList} from '../../store/reducers/clusterNodes';
2627
import StorageGroups from './StorageGroups/StorageGroups';
@@ -54,6 +55,7 @@ class Storage extends React.Component {
5455
setInitialState: PropTypes.func,
5556
flatListStorageEntities: PropTypes.array,
5657
groupsCount: PropTypes.object,
58+
nodesCount: PropTypes.object,
5759
setStorageFilter: PropTypes.func,
5860
setVisibleEntities: PropTypes.func,
5961
visibleEntities: PropTypes.string,
@@ -205,28 +207,23 @@ class Storage extends React.Component {
205207
const {
206208
storageType,
207209
groupsCount,
208-
flatListStorageEntities,
210+
nodesCount,
209211
loading,
210212
wasLoaded,
211213
} = this.props;
212214

213215
let label = `${storageType === StorageTypes.groups ? 'Groups' : 'Nodes'}: `;
216+
const count = storageType === StorageTypes.groups ? groupsCount : nodesCount;
214217

215218
if (loading && !wasLoaded) {
216219
label += '...';
217220
return label;
218221
}
219222

220-
if (storageType === StorageTypes.nodes) {
221-
label += flatListStorageEntities.length;
222-
}
223-
224-
if (storageType === StorageTypes.groups) {
225-
if (groupsCount.total === groupsCount.found) {
226-
label += groupsCount.total;
227-
} else {
228-
label += `${groupsCount.found} out of ${groupsCount.total}`;
229-
}
223+
if (count.total === count.found) {
224+
label += count.total;
225+
} else {
226+
label += `${count.found} of ${count.total}`;
230227
}
231228

232229
return label;
@@ -309,6 +306,7 @@ function mapStateToProps(state) {
309306
groupsCount: getStoragePoolsGroupsCount(state),
310307
autorefresh: state.schema.autorefresh,
311308
nodes: getNodesObject(state),
309+
nodesCount: getStorageNodesCount(state),
312310
loading,
313311
wasLoaded,
314312
error,

src/store/reducers/storage.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ export const getStoragePoolsGroupsCount = (state) => ({
130130
found: state.storage.data?.FoundGroups || 0,
131131
});
132132
export const getStorageNodes = (state) => state.storage.data?.Nodes;
133+
export const getStorageNodesCount = (state) => ({
134+
total: state.storage.data?.TotalNodes || 0,
135+
found: state.storage.data?.FoundNodes || 0,
136+
});
133137
export const getStorageFilter = (state) => state.storage.filter;
134138
export const getVisibleEntities = (state) => state.storage.visible;
135139
export const getStorageType = (state) => state.storage.type;

0 commit comments

Comments
 (0)