Skip to content

Commit e350669

Browse files
authored
Fix walkthough state caching (#527)
* fix state caching between walkthroughs currently, if a user starts a walkthrough and then, without performing a refresh of their page, navigates to another walkthrough, it causes an issue with the manifest of the previous walkthrough being used to provision services in the new walkthrough. this results in services not being provisioned when they are required in walkthroughs. this change ensures that navigating back to the main page will ensure the manifest cache for the previous walkthrough is cleared. verification: - have an existing rhmi installation from master - update the web app image to point to quay.io/aidenkeating/tutorial-web-app:fix-caching-2 - open walkthrough 2 (3scale) to the first page, no services should be provisioned - without refreshing, navigate to walkthrough 1, ensure that fuse and amq are provisioned * bump version to 2.19.4
1 parent c348dac commit e350669

File tree

5 files changed

+18
-4
lines changed

5 files changed

+18
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "integreatly-web-app",
3-
"version": "2.19.3",
3+
"version": "2.19.4",
44
"private": true,
55
"proxy": "http://localhost:5001/",
66
"dependencies": {

src/pages/landing/landingPage.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ import { DISPLAY_SERVICES } from '../../services/middlewareServices';
1818

1919
class LandingPage extends React.Component {
2020
componentDidMount() {
21-
const { getProgress, getCustomWalkthroughs } = this.props;
21+
const { getProgress, getCustomWalkthroughs, resetCurrentWalkthrough } = this.props;
2222
getCustomWalkthroughs();
23+
resetCurrentWalkthrough();
2324
getProgress();
2425
}
2526

@@ -82,6 +83,7 @@ class LandingPage extends React.Component {
8283
LandingPage.propTypes = {
8384
getProgress: PropTypes.func,
8485
getCustomWalkthroughs: PropTypes.func,
86+
resetCurrentWalkthrough: PropTypes.func,
8587
middlewareServices: PropTypes.object,
8688
walkthroughServices: PropTypes.object,
8789
user: PropTypes.object,
@@ -95,6 +97,7 @@ LandingPage.propTypes = {
9597
LandingPage.defaultProps = {
9698
getProgress: noop,
9799
getCustomWalkthroughs: noop,
100+
resetCurrentWalkthrough: noop,
98101
middlewareServices: {
99102
customServices: {},
100103
data: {}
@@ -111,6 +114,7 @@ LandingPage.defaultProps = {
111114
const mapDispatchToProps = dispatch => ({
112115
getWalkthroughs: language => dispatch(reduxActions.walkthroughActions.getWalkthroughs(language)),
113116
getCustomWalkthroughs: () => dispatch(reduxActions.walkthroughActions.getCustomWalkthroughs()),
117+
resetCurrentWalkthrough: () => dispatch(reduxActions.threadActions.resetCustomThread()),
114118
getProgress: () => dispatch(reduxActions.userActions.getProgress()),
115119
launchAMQOnline: (username, namespace) => provisionAMQOnline(dispatch, username, namespace),
116120
launchAMQOnlineV4: (username, namespace) => provisionAMQOnlineV4(dispatch, username, namespace)

src/redux/actions/threadActions.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ const getThread = (language, id) => ({
77
payload: threadServices.getThread(language, id)
88
});
99

10+
const resetCustomThread = () => ({
11+
type: threadTypes.CLEAR_THREAD,
12+
payload: Promise.resolve({})
13+
});
14+
1015
const getCustomThread = id => ({
1116
type: threadTypes.GET_THREAD,
1217
payload: threadServices.getCustomThread(id)
@@ -44,5 +49,6 @@ export {
4449
updateThreadProgress,
4550
initCustomThreadSuccess,
4651
initCustomThreadFailure,
47-
initCustomThreadPending
52+
initCustomThreadPending,
53+
resetCustomThread
4854
};

src/redux/constants/threadConstants.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ const GET_THREAD = 'GET_THREAD';
22
const INIT_THREAD = 'INIT_THREAD';
33
const UPDATE_THREAD_PROGRESS = 'UPDATE_THREAD_PROGRESS';
44
const UPDATE_CURRENT_THREAD = 'UPDATE_CURRENT_THREAD';
5+
const CLEAR_THREAD = 'CLEAR_THREAD';
56

6-
export { GET_THREAD, INIT_THREAD, UPDATE_THREAD_PROGRESS, UPDATE_CURRENT_THREAD };
7+
export { GET_THREAD, INIT_THREAD, UPDATE_THREAD_PROGRESS, UPDATE_CURRENT_THREAD, CLEAR_THREAD };

src/redux/reducers/threadReducers.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ const initialState = {
2424

2525
const threadReducers = (state = initialState, action) => {
2626
switch (action.type) {
27+
case FULFILLED_ACTION(threadTypes.CLEAR_THREAD):
28+
return Object.assign({}, initialState, { threadProgress: state.threadProgress });
29+
2730
// Error/Rejected
2831
case REJECTED_ACTION(threadTypes.GET_THREAD):
2932
return setStateProp(

0 commit comments

Comments
 (0)