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 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { Platform } from 'react-native';
  4. import { ColorSchemeRegistry } from '../../../base/color-scheme';
  5. import { BottomSheet, hideDialog, isDialogOpen } from '../../../base/dialog';
  6. import { CHAT_ENABLED, IOS_RECORDING_ENABLED, getFeatureFlag } from '../../../base/flags';
  7. import { connect } from '../../../base/redux';
  8. import { StyleType } from '../../../base/styles';
  9. import { SharedDocumentButton } from '../../../etherpad';
  10. import { InfoDialogButton, InviteButton } from '../../../invite';
  11. import { AudioRouteButton } from '../../../mobile/audio-mode';
  12. import { LiveStreamButton, RecordButton } from '../../../recording';
  13. import { RoomLockButton } from '../../../room-lock';
  14. import { ClosedCaptionButton } from '../../../subtitles';
  15. import { TileViewButton } from '../../../video-layout';
  16. import AudioOnlyButton from './AudioOnlyButton';
  17. import RaiseHandButton from './RaiseHandButton';
  18. import ToggleCameraButton from './ToggleCameraButton';
  19. /**
  20. * The type of the React {@code Component} props of {@link OverflowMenu}.
  21. */
  22. type Props = {
  23. /**
  24. * The color-schemed stylesheet of the dialog feature.
  25. */
  26. _bottomSheetStyles: StyleType,
  27. /**
  28. * Whether the chat feature has been enabled. The meeting info button will be displayed in its place when disabled.
  29. */
  30. _chatEnabled: boolean,
  31. /**
  32. * True if the overflow menu is currently visible, false otherwise.
  33. */
  34. _isOpen: boolean,
  35. /**
  36. * Whether the recoding button should be enabled or not.
  37. */
  38. _recordingEnabled: boolean,
  39. /**
  40. * Used for hiding the dialog when the selection was completed.
  41. */
  42. dispatch: Function
  43. };
  44. /**
  45. * The exported React {@code Component}. We need it to execute
  46. * {@link hideDialog}.
  47. *
  48. * XXX It does not break our coding style rule to not utilize globals for state,
  49. * because it is merely another name for {@code export}'s {@code default}.
  50. */
  51. let OverflowMenu_; // eslint-disable-line prefer-const
  52. /**
  53. * Implements a React {@code Component} with some extra actions in addition to
  54. * those in the toolbar.
  55. */
  56. class OverflowMenu extends Component<Props> {
  57. /**
  58. * Initializes a new {@code OverflowMenu} instance.
  59. *
  60. * @inheritdoc
  61. */
  62. constructor(props: Props) {
  63. super(props);
  64. // Bind event handlers so they are only bound once per instance.
  65. this._onCancel = this._onCancel.bind(this);
  66. }
  67. /**
  68. * Implements React's {@link Component#render()}.
  69. *
  70. * @inheritdoc
  71. * @returns {ReactElement}
  72. */
  73. render() {
  74. const buttonProps = {
  75. afterClick: this._onCancel,
  76. showLabel: true,
  77. styles: this.props._bottomSheetStyles
  78. };
  79. return (
  80. <BottomSheet onCancel = { this._onCancel }>
  81. <AudioRouteButton { ...buttonProps } />
  82. <ToggleCameraButton { ...buttonProps } />
  83. <AudioOnlyButton { ...buttonProps } />
  84. <RoomLockButton { ...buttonProps } />
  85. <ClosedCaptionButton { ...buttonProps } />
  86. {
  87. this.props._recordingEnabled
  88. && <RecordButton { ...buttonProps } />
  89. }
  90. <LiveStreamButton { ...buttonProps } />
  91. <TileViewButton { ...buttonProps } />
  92. <InviteButton { ...buttonProps } />
  93. {
  94. this.props._chatEnabled
  95. && <InfoDialogButton { ...buttonProps } />
  96. }
  97. <RaiseHandButton { ...buttonProps } />
  98. <SharedDocumentButton { ...buttonProps } />
  99. </BottomSheet>
  100. );
  101. }
  102. _onCancel: () => boolean;
  103. /**
  104. * Hides this {@code OverflowMenu}.
  105. *
  106. * @private
  107. * @returns {boolean}
  108. */
  109. _onCancel() {
  110. if (this.props._isOpen) {
  111. this.props.dispatch(hideDialog(OverflowMenu_));
  112. return true;
  113. }
  114. return false;
  115. }
  116. }
  117. /**
  118. * Function that maps parts of Redux state tree into component props.
  119. *
  120. * @param {Object} state - Redux state.
  121. * @private
  122. * @returns {Props}
  123. */
  124. function _mapStateToProps(state) {
  125. return {
  126. _bottomSheetStyles:
  127. ColorSchemeRegistry.get(state, 'BottomSheet'),
  128. _chatEnabled: getFeatureFlag(state, CHAT_ENABLED, true),
  129. _isOpen: isDialogOpen(state, OverflowMenu_),
  130. _recordingEnabled: Platform.OS !== 'ios' || getFeatureFlag(state, IOS_RECORDING_ENABLED)
  131. };
  132. }
  133. OverflowMenu_ = connect(_mapStateToProps)(OverflowMenu);
  134. export default OverflowMenu_;