Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // @flow
  2. import type { Dispatch } from 'redux';
  3. import {
  4. SET_TOOLBOX_ENABLED,
  5. SET_TOOLBOX_VISIBLE,
  6. TOGGLE_TOOLBOX_VISIBLE
  7. } from './actionTypes';
  8. /**
  9. * Enables/disables the toolbox.
  10. *
  11. * @param {boolean} enabled - True to enable the toolbox or false to disable it.
  12. * @returns {{
  13. * type: SET_TOOLBOX_ENABLED,
  14. * enabled: boolean
  15. * }}
  16. */
  17. export function setToolboxEnabled(enabled: boolean): Object {
  18. return {
  19. type: SET_TOOLBOX_ENABLED,
  20. enabled
  21. };
  22. }
  23. /**
  24. * Shows/hides the toolbox.
  25. *
  26. * @param {boolean} visible - True to show the toolbox or false to hide it.
  27. * @returns {Function}
  28. */
  29. export function setToolboxVisible(visible: boolean): Object {
  30. return (dispatch: Dispatch<any>, getState: Function) => {
  31. const { toolbarConfig: { alwaysVisible } } = getState()['features/base/config'];
  32. if (!visible && alwaysVisible) {
  33. return;
  34. }
  35. dispatch({
  36. type: SET_TOOLBOX_VISIBLE,
  37. visible
  38. });
  39. };
  40. }
  41. /**
  42. * Action to toggle the toolbox visibility.
  43. *
  44. * @returns {Function}
  45. */
  46. export function toggleToolboxVisible() {
  47. return (dispatch: Dispatch<any>, getState: Function) => {
  48. const state = getState();
  49. const { toolbarConfig: { alwaysVisible } } = state['features/base/config'];
  50. const { visible } = state['features/toolbox'];
  51. if (visible && alwaysVisible) {
  52. return;
  53. }
  54. dispatch({
  55. type: TOGGLE_TOOLBOX_VISIBLE
  56. });
  57. };
  58. }