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

actions.js 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { HIDE_DIALOG, OPEN_DIALOG } from './actionTypes';
  2. /**
  3. * Signals Dialog to close its dialog.
  4. *
  5. * @returns {{
  6. * type: HIDE_DIALOG
  7. * }}
  8. */
  9. export function hideDialog() {
  10. return {
  11. type: HIDE_DIALOG
  12. };
  13. }
  14. /**
  15. * Signals Dialog to open dialog.
  16. *
  17. * @param {Object} component - The component to display as dialog.
  18. * @param {Object} [componentProps] - The React <tt>Component</tt> props of the
  19. * specified <tt>component</tt>.
  20. * @returns {Object}
  21. */
  22. export function openDialog(component, componentProps) {
  23. return {
  24. type: OPEN_DIALOG,
  25. component,
  26. componentProps
  27. };
  28. }
  29. /**
  30. * Signals Dialog to open a dialog with the specified component if the component
  31. * is not already open. If it is open, then Dialog is signaled to close its
  32. * dialog.
  33. *
  34. * @param {Object} component - The component to display as dialog.
  35. * @param {Object} [componentProps] - The React <tt>Component</tt> props of the
  36. * specified <tt>component</tt>.
  37. * @returns {Object}
  38. */
  39. export function toggleDialog(component, componentProps) {
  40. return (dispatch, getState) => {
  41. if (getState()['features/base/dialog'].component === component) {
  42. dispatch(hideDialog());
  43. } else {
  44. dispatch(openDialog(component, componentProps));
  45. }
  46. };
  47. }