Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

DialogContainer.tsx 2.4KB

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