Skip to content

Commit f5486bc

Browse files
fix(Storage): update data on path change
1 parent d474c6c commit f5486bc

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/containers/Storage/Storage.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
StorageTypes,
2626
setStorageType,
2727
setNodesUptimeFilter,
28+
setDataWasNotLoaded,
2829
VisibleEntitiesTitles,
2930
getStoragePoolsGroupsCount,
3031
getStorageNodesCount,
@@ -71,6 +72,7 @@ class Storage extends React.Component {
7172
nodeId: PropTypes.string,
7273
nodesUptimeFilter: PropTypes.string,
7374
setNodesUptimeFilter: PropTypes.func,
75+
setDataWasNotLoaded: PropTypes.func,
7476
};
7577

7678
componentDidMount() {
@@ -106,7 +108,8 @@ class Storage extends React.Component {
106108
}
107109

108110
componentDidUpdate(prevProps) {
109-
const {visibleEntities, storageType, autorefresh, database} = this.props;
111+
const {visibleEntities, storageType, autorefresh, database, tenant, setDataWasNotLoaded} =
112+
this.props;
110113

111114
const startFetch = () => {
112115
this.getStorageInfo({
@@ -144,6 +147,12 @@ class Storage extends React.Component {
144147
restartAutorefresh();
145148
}
146149
}
150+
151+
if (tenant !== prevProps.tenant) {
152+
setDataWasNotLoaded();
153+
startFetch();
154+
restartAutorefresh();
155+
}
147156
}
148157

149158
componentWillUnmount() {
@@ -367,6 +376,7 @@ const mapDispatchToProps = {
367376
getNodesList,
368377
setStorageType,
369378
setHeader,
379+
setDataWasNotLoaded,
370380
};
371381

372382
export default connect(mapStateToProps, mapDispatchToProps)(Storage);

src/store/reducers/storage.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const SET_USAGE_FILTER = 'storage/SET_USAGE_FILTER';
3434
const SET_VISIBLE_GROUPS = 'storage/SET_VISIBLE_GROUPS';
3535
const SET_STORAGE_TYPE = 'storage/SET_STORAGE_TYPE';
3636
const SET_NODES_UPTIME_FILTER = 'storage/SET_NODES_UPTIME_FILTER';
37+
const SET_DATA_WAS_NOT_LOADED = 'storage/SET_DATA_WAS_NOT_LOADED';
3738

3839
const initialState = {
3940
loading: true,
@@ -116,6 +117,12 @@ const storage = (state = initialState, action) => {
116117
error: undefined,
117118
};
118119
}
120+
case SET_DATA_WAS_NOT_LOADED: {
121+
return {
122+
...state,
123+
wasLoaded: false,
124+
};
125+
}
119126
default:
120127
return state;
121128
}
@@ -169,6 +176,12 @@ export function setNodesUptimeFilter(value) {
169176
};
170177
}
171178

179+
export const setDataWasNotLoaded = () => {
180+
return {
181+
type: SET_DATA_WAS_NOT_LOADED,
182+
};
183+
};
184+
172185
export const getStoragePools = (state) => state.storage.data?.StoragePools;
173186
export const getStoragePoolsGroupsCount = (state) => ({
174187
total: state.storage.data?.TotalGroups || 0,

0 commit comments

Comments
 (0)