You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AbstractDialogContainer.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* @flow */
  2. import React, { Component } from 'react';
  3. import { type ReactionEmojiProps } from '../../../reactions/constants';
  4. /**
  5. * The type of the React {@code Component} props of {@link DialogContainer}.
  6. */
  7. type Props = {
  8. /**
  9. * The component to render.
  10. */
  11. _component: Function,
  12. /**
  13. * The props to pass to the component that will be rendered.
  14. */
  15. _componentProps: Object,
  16. /**
  17. * True if the dialog is a raw dialog (doesn't inherit behavior from other common frameworks, such as atlaskit).
  18. */
  19. _rawDialog: boolean,
  20. /**
  21. * True if the UI is in a compact state where we don't show dialogs.
  22. */
  23. _reducedUI: boolean,
  24. /**
  25. * Array of reactions to be displayed.
  26. */
  27. _reactionsQueue: Array<ReactionEmojiProps>
  28. };
  29. /**
  30. * Implements a DialogContainer responsible for showing all dialogs.
  31. */
  32. export default class AbstractDialogContainer extends Component<Props> {
  33. /**
  34. * Returns the dialog to be displayed.
  35. *
  36. * @private
  37. * @returns {ReactElement|null}
  38. */
  39. _renderDialogContent() {
  40. const {
  41. _component: component,
  42. _reducedUI: reducedUI
  43. } = this.props;
  44. return (
  45. component && !reducedUI
  46. ? React.createElement(component, this.props._componentProps)
  47. : null);
  48. }
  49. }
  50. /**
  51. * Maps (parts of) the redux state to the associated
  52. * {@code AbstractDialogContainer}'s props.
  53. *
  54. * @param {Object} state - The redux state.
  55. * @private
  56. * @returns {Props}
  57. */
  58. export function abstractMapStateToProps(state: Object): $Shape<Props> {
  59. const stateFeaturesBaseDialog = state['features/base/dialog'];
  60. const { reducedUI } = state['features/base/responsive-ui'];
  61. return {
  62. _component: stateFeaturesBaseDialog.component,
  63. _componentProps: stateFeaturesBaseDialog.componentProps,
  64. _rawDialog: stateFeaturesBaseDialog.rawDialog,
  65. _reducedUI: reducedUI
  66. };
  67. }