Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

DialogContainer.tsx 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import { ModalTransition } from '@atlaskit/modal-dialog';
  2. import React, { Component, ComponentType } from 'react';
  3. import { IReduxState } from '../../../../app/types';
  4. import { IReactionEmojiProps } from '../../../../reactions/constants';
  5. // eslint-disable-next-line lines-around-comment
  6. // @ts-ignore
  7. import { JitsiPortal } from '../../../../toolbox/components/web';
  8. import { showOverflowDrawer } from '../../../../toolbox/functions.web';
  9. import { connect } from '../../../redux/functions';
  10. import DialogTransition from './DialogTransition';
  11. interface IProps {
  12. /**
  13. * The component to render.
  14. */
  15. _component: ComponentType;
  16. /**
  17. * The props to pass to the component that will be rendered.
  18. */
  19. _componentProps: Object;
  20. /**
  21. * Whether the dialog is using the new component.
  22. */
  23. _isNewDialog: boolean;
  24. /**
  25. * Whether the overflow drawer should be used.
  26. */
  27. _overflowDrawer: boolean;
  28. /**
  29. * Array of reactions to be displayed.
  30. */
  31. _reactionsQueue: Array<IReactionEmojiProps>;
  32. /**
  33. * True if the UI is in a compact state where we don't show dialogs.
  34. */
  35. _reducedUI: boolean;
  36. }
  37. /**
  38. * Implements a DialogContainer responsible for showing all dialogs. Necessary
  39. * for supporting @atlaskit's modal animations.
  40. *
  41. */
  42. class DialogContainer extends Component<IProps> {
  43. /**
  44. * Returns the dialog to be displayed.
  45. *
  46. * @private
  47. * @returns {ReactElement|null}
  48. */
  49. _renderDialogContent() {
  50. const {
  51. _component: component,
  52. _reducedUI: reducedUI
  53. } = this.props;
  54. return (
  55. component && !reducedUI
  56. ? React.createElement(component, this.props._componentProps)
  57. : null);
  58. }
  59. /**
  60. * Implements React's {@link Component#render()}.
  61. *
  62. * @inheritdoc
  63. * @returns {ReactElement}
  64. */
  65. render() {
  66. return this.props._isNewDialog ? (
  67. <DialogTransition>
  68. {this.props._overflowDrawer
  69. ? <JitsiPortal>{this._renderDialogContent()}</JitsiPortal>
  70. : this._renderDialogContent() }
  71. </DialogTransition>
  72. ) : (
  73. <ModalTransition>
  74. { this._renderDialogContent() }
  75. </ModalTransition>
  76. );
  77. }
  78. }
  79. /**
  80. * Maps (parts of) the redux state to the associated
  81. * {@code AbstractDialogContainer}'s props.
  82. *
  83. * @param {Object} state - The redux state.
  84. * @private
  85. * @returns {IProps}
  86. */
  87. function mapStateToProps(state: IReduxState) {
  88. const stateFeaturesBaseDialog = state['features/base/dialog'];
  89. const { reducedUI } = state['features/base/responsive-ui'];
  90. const overflowDrawer = showOverflowDrawer(state);
  91. return {
  92. _component: stateFeaturesBaseDialog.component,
  93. _componentProps: stateFeaturesBaseDialog.componentProps,
  94. _isNewDialog: stateFeaturesBaseDialog.isNewDialog,
  95. _overflowDrawer: overflowDrawer,
  96. _reducedUI: reducedUI
  97. };
  98. }
  99. export default connect(mapStateToProps)(DialogContainer);