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

reducer.js 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. // @flow
  2. import { ReducerRegistry, set } from '../base/redux';
  3. import {
  4. CLEAR_TOOLBOX_TIMEOUT,
  5. FULL_SCREEN_CHANGED,
  6. SET_OVERFLOW_DRAWER,
  7. SET_OVERFLOW_MENU_VISIBLE,
  8. SET_TOOLBAR_HOVERED,
  9. SET_TOOLBOX_ENABLED,
  10. SET_TOOLBOX_TIMEOUT,
  11. SET_TOOLBOX_VISIBLE,
  12. TOGGLE_TOOLBOX_VISIBLE
  13. } from './actionTypes';
  14. /**
  15. * Initial state of toolbox's part of Redux store.
  16. */
  17. const INITIAL_STATE = {
  18. /**
  19. * The indicator which determines whether the Toolbox is enabled.
  20. *
  21. * @type {boolean}
  22. */
  23. enabled: true,
  24. /**
  25. * The indicator which determines whether a Toolbar in the Toolbox is
  26. * hovered.
  27. *
  28. * @type {boolean}
  29. */
  30. hovered: false,
  31. /**
  32. * The indicator which determines whether the overflow menu(s) are to be displayed as drawers.
  33. *
  34. * @type {boolean}
  35. */
  36. overflowDrawer: false,
  37. /**
  38. * The indicator which determines whether the OverflowMenu is visible.
  39. *
  40. * @type {boolean}
  41. */
  42. overflowMenuVisible: false,
  43. /**
  44. * A number, non-zero value which identifies the timer created by a call
  45. * to setTimeout().
  46. *
  47. * @type {number|null}
  48. */
  49. timeoutID: null,
  50. /**
  51. * The indicator that determines whether the Toolbox is visible.
  52. *
  53. * @type {boolean}
  54. */
  55. visible: false
  56. };
  57. ReducerRegistry.register(
  58. 'features/toolbox',
  59. (state: Object = INITIAL_STATE, action: Object) => {
  60. switch (action.type) {
  61. case CLEAR_TOOLBOX_TIMEOUT:
  62. return {
  63. ...state,
  64. timeoutID: undefined
  65. };
  66. case FULL_SCREEN_CHANGED:
  67. return {
  68. ...state,
  69. fullScreen: action.fullScreen
  70. };
  71. case SET_OVERFLOW_DRAWER:
  72. return {
  73. ...state,
  74. overflowDrawer: action.displayAsDrawer
  75. };
  76. case SET_OVERFLOW_MENU_VISIBLE:
  77. return {
  78. ...state,
  79. overflowMenuVisible: action.visible
  80. };
  81. case SET_TOOLBAR_HOVERED:
  82. return {
  83. ...state,
  84. hovered: action.hovered
  85. };
  86. case SET_TOOLBOX_ENABLED:
  87. return {
  88. ...state,
  89. enabled: action.enabled
  90. };
  91. case SET_TOOLBOX_TIMEOUT:
  92. return {
  93. ...state,
  94. timeoutID: action.timeoutID
  95. };
  96. case SET_TOOLBOX_VISIBLE:
  97. return set(state, 'visible', action.visible);
  98. case TOGGLE_TOOLBOX_VISIBLE:
  99. return set(state, 'visible', !state.visible);
  100. }
  101. return state;
  102. });