You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

reducer.js 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* @flow */
  2. import { assign, ReducerRegistry } from '../redux';
  3. import { HIDE_DIALOG, OPEN_DIALOG } from './actionTypes';
  4. /**
  5. * Reduces redux actions which show or hide dialogs.
  6. *
  7. * @param {State} state - The current redux state.
  8. * @param {Action} action - The redux action to reduce.
  9. * @param {string} action.type - The type of the redux action to reduce..
  10. * @returns {State} The next redux state that is the result of reducing the
  11. * specified action.
  12. */
  13. ReducerRegistry.register('features/base/dialog', (state = {}, action) => {
  14. switch (action.type) {
  15. case HIDE_DIALOG: {
  16. const { component } = action;
  17. if (typeof component === 'undefined' || state.component === component) {
  18. return assign(state, {
  19. component: undefined,
  20. componentProps: undefined,
  21. rawDialog: false
  22. });
  23. }
  24. break;
  25. }
  26. case OPEN_DIALOG:
  27. return assign(state, {
  28. component: action.component,
  29. componentProps: action.componentProps,
  30. rawDialog: action.rawDialog
  31. });
  32. }
  33. return state;
  34. });