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

reducer.ts 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import ReducerRegistry from '../redux/ReducerRegistry';
  2. import { assign } from '../redux/functions';
  3. import {
  4. HIDE_DIALOG,
  5. HIDE_SHEET,
  6. OPEN_DIALOG,
  7. OPEN_SHEET
  8. } from './actionTypes';
  9. export interface IDialogState {
  10. component?: Object;
  11. componentProps?: Object;
  12. sheet?: Object;
  13. sheetProps?: Object;
  14. }
  15. /**
  16. * Reduces redux actions which show or hide dialogs.
  17. *
  18. * @param {IDialogState} state - The current redux state.
  19. * @param {Action} action - The redux action to reduce.
  20. * @param {string} action.type - The type of the redux action to reduce..
  21. * @returns {State} The next redux state that is the result of reducing the
  22. * specified action.
  23. */
  24. ReducerRegistry.register('features/base/dialog', (state: IDialogState = {}, action) => {
  25. switch (action.type) {
  26. case HIDE_DIALOG: {
  27. const { component } = action;
  28. if (typeof component === 'undefined' || state.component === component) {
  29. return assign(state, {
  30. component: undefined,
  31. componentProps: undefined
  32. });
  33. }
  34. break;
  35. }
  36. case OPEN_DIALOG:
  37. return assign(state, {
  38. component: action.component,
  39. componentProps: action.componentProps
  40. });
  41. case HIDE_SHEET:
  42. return assign(state, {
  43. sheet: undefined,
  44. sheetProps: undefined
  45. });
  46. case OPEN_SHEET:
  47. return assign(state, {
  48. sheet: action.component,
  49. sheetProps: action.componentProps
  50. });
  51. }
  52. return state;
  53. });