[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:
17
src/reducers/global.js
Normal file
17
src/reducers/global.js
Normal 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;
|
@ -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;
|
||||
|
Reference in New Issue
Block a user