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.

MoreTab.tsx 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. import React from 'react';
  2. import { WithTranslation } from 'react-i18next';
  3. import AbstractDialogTab, {
  4. IProps as AbstractDialogTabProps
  5. } from '../../../base/dialog/components/web/AbstractDialogTab';
  6. import { translate } from '../../../base/i18n/functions';
  7. import Checkbox from '../../../base/ui/components/web/Checkbox';
  8. import Select from '../../../base/ui/components/web/Select';
  9. import { MAX_ACTIVE_PARTICIPANTS } from '../../../filmstrip/constants';
  10. /**
  11. * The type of the React {@code Component} props of {@link MoreTab}.
  12. */
  13. export type Props = AbstractDialogTabProps & WithTranslation & {
  14. /**
  15. * Whether or not follow me is currently active (enabled by some other participant).
  16. */
  17. followMeActive: boolean;
  18. /**
  19. * The number of max participants to display on stage.
  20. */
  21. maxStageParticipants: number;
  22. /**
  23. * Whether or not to display moderator-only settings.
  24. */
  25. showModeratorSettings: boolean;
  26. /**
  27. * Whether or not to show prejoin screen.
  28. */
  29. showPrejoinPage: boolean;
  30. /**
  31. * Whether or not to display the prejoin settings section.
  32. */
  33. showPrejoinSettings: boolean;
  34. /**
  35. * Wether or not the stage filmstrip is enabled.
  36. */
  37. stageFilmstripEnabled: boolean;
  38. /**
  39. * Invoked to obtain translated strings.
  40. */
  41. t: Function;
  42. };
  43. /**
  44. * React {@code Component} for modifying language and moderator settings.
  45. *
  46. * @augments Component
  47. */
  48. class MoreTab extends AbstractDialogTab<Props, any> {
  49. /**
  50. * Initializes a new {@code MoreTab} instance.
  51. *
  52. * @param {Object} props - The read-only properties with which the new
  53. * instance is to be initialized.
  54. */
  55. constructor(props: Props) {
  56. super(props);
  57. // Bind event handler so it is only bound once for every instance.
  58. this._onShowPrejoinPageChanged = this._onShowPrejoinPageChanged.bind(this);
  59. this._renderMaxStageParticipantsSelect = this._renderMaxStageParticipantsSelect.bind(this);
  60. this._onMaxStageParticipantsSelect = this._onMaxStageParticipantsSelect.bind(this);
  61. }
  62. /**
  63. * Implements React's {@link Component#render()}.
  64. *
  65. * @inheritdoc
  66. * @returns {ReactElement}
  67. */
  68. render() {
  69. const content = [];
  70. content.push(this._renderSettingsLeft());
  71. content.push(this._renderSettingsRight());
  72. return (
  73. <div
  74. className = 'more-tab box'
  75. key = 'more'>
  76. { content }
  77. </div>
  78. );
  79. }
  80. /**
  81. * Callback invoked to select if the lobby
  82. * should be shown.
  83. *
  84. * @param {Object} e - The key event to handle.
  85. *
  86. * @returns {void}
  87. */
  88. _onShowPrejoinPageChanged({ target: { checked } }: React.ChangeEvent<HTMLInputElement>) {
  89. super._onChange({ showPrejoinPage: checked });
  90. }
  91. /**
  92. * Callback invoked to select a max number of stage participants from the select dropdown.
  93. *
  94. * @param {Object} e - The key event to handle.
  95. * @private
  96. * @returns {void}
  97. */
  98. _onMaxStageParticipantsSelect(e: React.ChangeEvent<HTMLSelectElement>) {
  99. const maxParticipants = Number(e.target.value);
  100. super._onChange({ maxStageParticipants: maxParticipants });
  101. }
  102. /**
  103. * Returns the React Element for modifying prejoin screen settings.
  104. *
  105. * @private
  106. * @returns {ReactElement}
  107. */
  108. _renderPrejoinScreenSettings() {
  109. const { t, showPrejoinPage } = this.props;
  110. return (
  111. <div
  112. className = 'settings-sub-pane-element'
  113. key = 'prejoin-screen'>
  114. <span className = 'checkbox-label'>
  115. { t('prejoin.premeeting') }
  116. </span>
  117. <Checkbox
  118. checked = { showPrejoinPage }
  119. label = { t('prejoin.showScreen') }
  120. name = 'show-prejoin-page'
  121. onChange = { this._onShowPrejoinPageChanged } />
  122. </div>
  123. );
  124. }
  125. /**
  126. * Returns the React Element for the max stage participants dropdown.
  127. *
  128. * @returns {ReactElement}
  129. */
  130. _renderMaxStageParticipantsSelect() {
  131. const { maxStageParticipants, t, stageFilmstripEnabled } = this.props;
  132. if (!stageFilmstripEnabled) {
  133. return null;
  134. }
  135. const maxParticipantsItems = Array(MAX_ACTIVE_PARTICIPANTS).fill(0)
  136. .map((no, index) => {
  137. return {
  138. value: index + 1,
  139. label: `${index + 1}`
  140. };
  141. });
  142. return (
  143. <div
  144. className = 'settings-sub-pane-element'
  145. key = 'maxStageParticipants'>
  146. <div className = 'dropdown-menu'>
  147. <Select
  148. label = { t('settings.maxStageParticipants') }
  149. onChange = { this._onMaxStageParticipantsSelect }
  150. options = { maxParticipantsItems }
  151. value = { maxStageParticipants } />
  152. </div>
  153. </div>
  154. );
  155. }
  156. /**
  157. * Returns the React element that needs to be displayed on the right half of the more tabs.
  158. *
  159. * @private
  160. * @returns {ReactElement}
  161. */
  162. _renderSettingsRight() {
  163. return (
  164. <div
  165. className = 'settings-sub-pane right'
  166. key = 'settings-sub-pane-right'>
  167. { this._renderMaxStageParticipantsSelect() }
  168. </div>
  169. );
  170. }
  171. /**
  172. * Returns the React element that needs to be displayed on the left half of the more tabs.
  173. *
  174. * @returns {ReactElement}
  175. */
  176. _renderSettingsLeft() {
  177. const { showPrejoinSettings } = this.props;
  178. return (
  179. <div
  180. className = 'settings-sub-pane left'
  181. key = 'settings-sub-pane-left'>
  182. { showPrejoinSettings && this._renderPrejoinScreenSettings() }
  183. </div>
  184. );
  185. }
  186. }
  187. export default translate(MoreTab);