您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

reducer.js 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. });
  22. }
  23. break;
  24. }
  25. case OPEN_DIALOG:
  26. return assign(state, {
  27. component: action.component,
  28. componentProps: action.componentProps
  29. });
  30. }
  31. return state;
  32. });