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

reducer.ts 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. import ReducerRegistry from '../base/redux/ReducerRegistry';
  2. import { set } from '../base/redux/functions';
  3. import {
  4. CLEAR_TOOLBOX_TIMEOUT,
  5. FULL_SCREEN_CHANGED,
  6. SET_HANGUP_MENU_VISIBLE,
  7. SET_OVERFLOW_DRAWER,
  8. SET_OVERFLOW_MENU_VISIBLE,
  9. SET_TOOLBAR_HOVERED,
  10. SET_TOOLBOX_ENABLED,
  11. SET_TOOLBOX_SHIFT_UP,
  12. SET_TOOLBOX_TIMEOUT,
  13. SET_TOOLBOX_VISIBLE,
  14. TOGGLE_TOOLBOX_VISIBLE
  15. } from './actionTypes';
  16. /**
  17. * Initial state of toolbox's part of Redux store.
  18. */
  19. const INITIAL_STATE = {
  20. /**
  21. * The indicator which determines whether the Toolbox is enabled.
  22. *
  23. * @type {boolean}
  24. */
  25. enabled: true,
  26. /**
  27. * The indicator which determines whether the hangup menu is visible.
  28. *
  29. * @type {boolean}
  30. */
  31. hangupMenuVisible: false,
  32. /**
  33. * The indicator which determines whether a Toolbar in the Toolbox is
  34. * hovered.
  35. *
  36. * @type {boolean}
  37. */
  38. hovered: false,
  39. /**
  40. * The indicator which determines whether the overflow menu(s) are to be displayed as drawers.
  41. *
  42. * @type {boolean}
  43. */
  44. overflowDrawer: false,
  45. /**
  46. * The indicator which determines whether the OverflowMenu is visible.
  47. *
  48. * @type {boolean}
  49. */
  50. overflowMenuVisible: false,
  51. /**
  52. * Whether to shift the toolbar up (in case it overlaps the tiles names).
  53. */
  54. shiftUp: false,
  55. /**
  56. * A number, non-zero value which identifies the timer created by a call
  57. * to setTimeout().
  58. *
  59. * @type {number|null}
  60. */
  61. timeoutID: null,
  62. /**
  63. * The indicator that determines whether the Toolbox is visible.
  64. *
  65. * @type {boolean}
  66. */
  67. visible: false
  68. };
  69. export interface IToolboxState {
  70. enabled: boolean;
  71. fullScreen?: boolean;
  72. hangupMenuVisible: boolean;
  73. hovered: boolean;
  74. overflowDrawer: boolean;
  75. overflowMenuVisible: boolean;
  76. shiftUp: boolean;
  77. timeoutID?: number | null;
  78. visible: boolean;
  79. }
  80. ReducerRegistry.register<IToolboxState>(
  81. 'features/toolbox',
  82. (state = INITIAL_STATE, action): IToolboxState => {
  83. switch (action.type) {
  84. case CLEAR_TOOLBOX_TIMEOUT:
  85. return {
  86. ...state,
  87. timeoutID: undefined
  88. };
  89. case FULL_SCREEN_CHANGED:
  90. return {
  91. ...state,
  92. fullScreen: action.fullScreen
  93. };
  94. case SET_HANGUP_MENU_VISIBLE:
  95. return {
  96. ...state,
  97. hangupMenuVisible: action.visible
  98. };
  99. case SET_OVERFLOW_DRAWER:
  100. return {
  101. ...state,
  102. overflowDrawer: action.displayAsDrawer
  103. };
  104. case SET_OVERFLOW_MENU_VISIBLE:
  105. return {
  106. ...state,
  107. overflowMenuVisible: action.visible
  108. };
  109. case SET_TOOLBAR_HOVERED:
  110. return {
  111. ...state,
  112. hovered: action.hovered
  113. };
  114. case SET_TOOLBOX_ENABLED:
  115. return {
  116. ...state,
  117. enabled: action.enabled
  118. };
  119. case SET_TOOLBOX_TIMEOUT:
  120. return {
  121. ...state,
  122. timeoutID: action.timeoutID
  123. };
  124. case SET_TOOLBOX_SHIFT_UP:
  125. return {
  126. ...state,
  127. shiftUp: action.shiftUp
  128. };
  129. case SET_TOOLBOX_VISIBLE:
  130. return set(state, 'visible', action.visible);
  131. case TOGGLE_TOOLBOX_VISIBLE:
  132. return set(state, 'visible', !state.visible);
  133. }
  134. return state;
  135. });