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.

OverflowMenu.js 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. // @flow
  2. import React, { PureComponent } from 'react';
  3. import { ColorSchemeRegistry } from '../../../base/color-scheme';
  4. import { BottomSheet, hideDialog, isDialogOpen } from '../../../base/dialog';
  5. import { getFeatureFlag, REACTIONS_ENABLED } from '../../../base/flags';
  6. import { connect } from '../../../base/redux';
  7. import { StyleType } from '../../../base/styles';
  8. import { SharedDocumentButton } from '../../../etherpad';
  9. import { AudioRouteButton } from '../../../mobile/audio-mode';
  10. import { ParticipantsPaneButton } from '../../../participants-pane/components/native';
  11. import { ReactionMenu } from '../../../reactions/components';
  12. import { LiveStreamButton, RecordButton } from '../../../recording';
  13. import SecurityDialogButton from '../../../security/components/security-dialog/SecurityDialogButton';
  14. import { SharedVideoButton } from '../../../shared-video/components';
  15. import { ClosedCaptionButton } from '../../../subtitles';
  16. import { TileViewButton } from '../../../video-layout';
  17. import { getMovableButtons } from '../../functions.native';
  18. import HelpButton from '../HelpButton';
  19. import MuteEveryoneButton from '../MuteEveryoneButton';
  20. import MuteEveryonesVideoButton from '../MuteEveryonesVideoButton';
  21. import AudioOnlyButton from './AudioOnlyButton';
  22. import RaiseHandButton from './RaiseHandButton';
  23. import ScreenSharingButton from './ScreenSharingButton.js';
  24. import ToggleCameraButton from './ToggleCameraButton';
  25. /**
  26. * The type of the React {@code Component} props of {@link OverflowMenu}.
  27. */
  28. type Props = {
  29. /**
  30. * The color-schemed stylesheet of the dialog feature.
  31. */
  32. _bottomSheetStyles: StyleType,
  33. /**
  34. * True if the overflow menu is currently visible, false otherwise.
  35. */
  36. _isOpen: boolean,
  37. /**
  38. * Whether the recoding button should be enabled or not.
  39. */
  40. _recordingEnabled: boolean,
  41. /**
  42. * The width of the screen.
  43. */
  44. _width: number,
  45. /**
  46. * Whether or not the reactions feature is enabled.
  47. */
  48. _reactionsEnabled: boolean,
  49. /**
  50. * Used for hiding the dialog when the selection was completed.
  51. */
  52. dispatch: Function
  53. };
  54. type State = {
  55. /**
  56. * True if the bottom scheet is scrolled to the top.
  57. */
  58. scrolledToTop: boolean
  59. }
  60. /**
  61. * The exported React {@code Component}. We need it to execute
  62. * {@link hideDialog}.
  63. *
  64. * XXX It does not break our coding style rule to not utilize globals for state,
  65. * because it is merely another name for {@code export}'s {@code default}.
  66. */
  67. let OverflowMenu_; // eslint-disable-line prefer-const
  68. /**
  69. * Implements a React {@code Component} with some extra actions in addition to
  70. * those in the toolbar.
  71. */
  72. class OverflowMenu extends PureComponent<Props, State> {
  73. /**
  74. * Initializes a new {@code OverflowMenu} instance.
  75. *
  76. * @inheritdoc
  77. */
  78. constructor(props: Props) {
  79. super(props);
  80. this.state = {
  81. scrolledToTop: true
  82. };
  83. // Bind event handlers so they are only bound once per instance.
  84. this._onCancel = this._onCancel.bind(this);
  85. this._renderReactionMenu = this._renderReactionMenu.bind(this);
  86. }
  87. /**
  88. * Implements React's {@link Component#render()}.
  89. *
  90. * @inheritdoc
  91. * @returns {ReactElement}
  92. */
  93. render() {
  94. const { _bottomSheetStyles, _width, _reactionsEnabled } = this.props;
  95. const toolbarButtons = getMovableButtons(_width);
  96. const buttonProps = {
  97. afterClick: this._onCancel,
  98. showLabel: true,
  99. styles: _bottomSheetStyles.buttons
  100. };
  101. const topButtonProps = {
  102. afterClick: this._onCancel,
  103. showLabel: true,
  104. styles: {
  105. ..._bottomSheetStyles.buttons,
  106. style: {
  107. ..._bottomSheetStyles.buttons.style,
  108. borderTopLeftRadius: 16,
  109. borderTopRightRadius: 16
  110. }
  111. }
  112. };
  113. return (
  114. <BottomSheet
  115. onCancel = { this._onCancel }
  116. renderFooter = { _reactionsEnabled && !toolbarButtons.has('raisehand')
  117. ? this._renderReactionMenu
  118. : null }>
  119. <AudioRouteButton { ...topButtonProps } />
  120. <ParticipantsPaneButton { ...buttonProps } />
  121. <AudioOnlyButton { ...buttonProps } />
  122. {!_reactionsEnabled && !toolbarButtons.has('raisehand') && <RaiseHandButton { ...buttonProps } />}
  123. <SecurityDialogButton { ...buttonProps } />
  124. <ScreenSharingButton { ...buttonProps } />
  125. {!toolbarButtons.has('togglecamera') && <ToggleCameraButton { ...buttonProps } />}
  126. {!toolbarButtons.has('tileview') && <TileViewButton { ...buttonProps } />}
  127. <RecordButton { ...buttonProps } />
  128. <LiveStreamButton { ...buttonProps } />
  129. <SharedVideoButton { ...buttonProps } />
  130. <ClosedCaptionButton { ...buttonProps } />
  131. <SharedDocumentButton { ...buttonProps } />
  132. <MuteEveryoneButton { ...buttonProps } />
  133. <MuteEveryonesVideoButton { ...buttonProps } />
  134. <HelpButton { ...buttonProps } />
  135. </BottomSheet>
  136. );
  137. }
  138. _onCancel: () => boolean;
  139. /**
  140. * Hides this {@code OverflowMenu}.
  141. *
  142. * @private
  143. * @returns {boolean}
  144. */
  145. _onCancel() {
  146. if (this.props._isOpen) {
  147. this.props.dispatch(hideDialog(OverflowMenu_));
  148. return true;
  149. }
  150. return false;
  151. }
  152. _renderReactionMenu: () => React$Element<any>;
  153. /**
  154. * Functoin to render the reaction menu as the footer of the bottom sheet.
  155. *
  156. * @returns {React$Element}
  157. */
  158. _renderReactionMenu() {
  159. return (<ReactionMenu
  160. onCancel = { this._onCancel }
  161. overflowMenu = { true } />);
  162. }
  163. }
  164. /**
  165. * Function that maps parts of Redux state tree into component props.
  166. *
  167. * @param {Object} state - Redux state.
  168. * @private
  169. * @returns {Props}
  170. */
  171. function _mapStateToProps(state) {
  172. return {
  173. _bottomSheetStyles: ColorSchemeRegistry.get(state, 'BottomSheet'),
  174. _isOpen: isDialogOpen(state, OverflowMenu_),
  175. _width: state['features/base/responsive-ui'].clientWidth,
  176. _reactionsEnabled: getFeatureFlag(state, REACTIONS_ENABLED, false)
  177. };
  178. }
  179. OverflowMenu_ = connect(_mapStateToProps)(OverflowMenu);
  180. export default OverflowMenu_;