[feature] Better loading indicator

- Use react-topbar-progress-indicator as a global loading indicator.
- Added a global reducer that only holds `isFetching` for now.
- Display loading indicator on any `*_REQUEST` actions.
- Closes #103
This commit is contained in:
Andrey Okonetchnikov
2016-10-20 18:16:46 +02:00
parent f7b74453ab
commit 188fec4529
5 changed files with 46 additions and 4 deletions

17
src/reducers/global.js Normal file
View File

@ -0,0 +1,17 @@
/* Reducer for some global UI state that we want to share between components
* Now being used for isFetching state to display global loading indicator
* */
const globalReducer = (state = { isFetching: false }, action) => {
if ((action.type.indexOf('REQUEST') > -1)) {
return { isFetching: true };
} else if (
(action.type.indexOf('SUCCESS') > -1) ||
(action.type.indexOf('FAILURE') > -1)
) {
return { isFetching: false };
}
return state;
};
export default globalReducer;

View File

@ -7,6 +7,7 @@ import editorialWorkflow, * as fromEditorialWorkflow from './editorialWorkflow';
import entryDraft from './entryDraft';
import collections from './collections';
import medias, * as fromMedias from './medias';
import global from './global';
const reducers = {
auth,
@ -18,6 +19,7 @@ const reducers = {
editorialWorkflow,
entryDraft,
medias,
global,
};
export default reducers;