all files / src/explore/reducers/ saveModalReducer.js

0% Statements 0/20
0% Branches 0/8
0% Functions 0/7
0% Lines 0/12
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29                                                         
/* eslint camelcase: 0 */
import * as actions from '../actions/saveModalActions';
 
export default function saveModalReducer(state = {}, action) {
  const actionHandlers = {
    [actions.FETCH_DASHBOARDS_SUCCEEDED]() {
      return Object.assign({}, state, { dashboards: action.choices });
    },
    [actions.FETCH_DASHBOARDS_FAILED]() {
      return Object.assign({}, state,
        { saveModalAlert: `fetching dashboards failed for ${action.userId}` });
    },
    [actions.SAVE_SLICE_FAILED]() {
      return Object.assign({}, state, { saveModalAlert: 'Failed to save slice' });
    },
    [actions.SAVE_SLICE_SUCCESS](data) {
      return Object.assign({}, state, { data });
    },
    [actions.REMOVE_SAVE_MODAL_ALERT]() {
      return Object.assign({}, state, { saveModalAlert: null });
    },
  };
 
  if (action.type in actionHandlers) {
    return actionHandlers[action.type]();
  }
  return state;
}