Skip to content

Commit 1b73f13

Browse files
committed
implement pending mechanism
1 parent ae63c56 commit 1b73f13

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed

src-react/actions/bootstrap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { pending } from './common';
44

55
export function bootstrap() {
66
return dispatch => {
7-
dispatch(pending());
7+
dispatch(pending(4));
88
dispatch(fetchUngitConfig());
99
dispatch(fetchLatestVersion());
1010
dispatch(fetchGitVersion());

src-react/actions/common.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
/* This export common using actionCreator */
22
import * as types from 'constants/action-types';
33

4-
export function pending() {
4+
export function pending(count) {
55
return {
6-
type: types.PATH_PAGE_PENDING
6+
type: types.PATH_PAGE_PENDING,
7+
payload: count || 1
78
};
89
};
910

src-react/containers/path.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { Component } from 'react';
22
import { bindActionCreators } from 'redux';
33
import { connect } from 'react-redux'
44

5+
import AlerArea from 'components/alert-area';
56
import * as bootstrapActionCreators from 'actions/bootstrap';
67
import 'styles/styles.scss';
78

@@ -20,12 +21,19 @@ class Path extends Component {
2021
}
2122

2223
render() {
24+
const { path: { pending, errMessage }, app } = this.props;
2325
return (
2426
<div>
2527
<div className="app-top-margin"></div>
2628
<div className="app-wrapper">
27-
<div className="container" data-bind="shown: shown" data-ta-container="app">
28-
</div>
29+
{
30+
pending === 0 && errMessage.length === 0 ? (
31+
<AlerArea config={ this.props.config }
32+
gitVersionErrorVisible={ app.gitVersionErrorVisible }
33+
showNewVersionAvailable={ app.showNewVersionAvailable }
34+
showBugtrackingNagscreen={ app.showBugtrackingNagscreen } />
35+
) : null
36+
}
2937
</div>
3038
</div>
3139
);

src-react/reducers/path.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ import * as types from 'constants/action-types';
33
function path(state, action) {
44
switch(action.type) {
55
case types.PATH_PAGE_PENDING:
6-
return { ...state, pending: true };
6+
return { ...state, pending: state.pending + action.payload };
77
case types.RECEIVE_UNGIT_CONFIG:
88
case types.RECEIVE_USER_CONFIG:
99
case types.RECEIVE_GIT_VERSION:
1010
case types.RECEIVE_LATEST_VERSION:
11-
return { ...state, pending: false };
11+
return { ...state, pending: state.pending - 1 };
1212
case types.PATH_PAGE_API_ERR:
1313
const { payload: errMessage } = action;
14-
return { ...state, pending: false, errMessage: [ ...state.errMessage, errMessage ] };
14+
return { ...state, pending: state.pending - 1, errMessage: [ ...state.errMessage, errMessage ] };
1515
default:
1616
return { ...state };
1717
}

src-react/store.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const initialState = {
1010
latestVersion: null
1111
},
1212
path: {
13-
pending: false,
13+
pending: null,
1414
errMessage: []
1515
}
1616
};

0 commit comments

Comments
 (0)