mirror of
https://github.com/datahub-project/datahub.git
synced 2025-07-28 20:09:59 +00:00
35 lines
860 B
JavaScript
35 lines
860 B
JavaScript
![]() |
import { ActionTypes } from 'wherehows-web/actions/browse';
|
||
|
|
||
|
/**
|
||
|
* Initial state for browse feature
|
||
|
* @type {{viewingEntity: string}}
|
||
|
*/
|
||
|
const initialState = {
|
||
|
viewingEntity: 'datasets'
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Reduces browse actions into state object
|
||
|
* @param {Object} state = initialState
|
||
|
* @param {Object} action Flux Standard Action FSA object
|
||
|
* @return {Object} final state of the browse key in the store
|
||
|
*/
|
||
|
export default (state = initialState, action = {}) => {
|
||
|
switch (action.type) {
|
||
|
case ActionTypes.REQUEST_BROWSE_DATA:
|
||
|
case ActionTypes.SELECT_BROWSE_DATA:
|
||
|
return Object.assign({}, state, {
|
||
|
isFetching: true,
|
||
|
viewingEntity: action.payload.viewingEntity
|
||
|
});
|
||
|
|
||
|
case ActionTypes.RECEIVE_BROWSE_DATA:
|
||
|
return Object.assign({}, state, {
|
||
|
isFetching: false
|
||
|
});
|
||
|
|
||
|
default:
|
||
|
return state;
|
||
|
}
|
||
|
};
|