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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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. import { SS_DEFAULT_FRAME_RATE } from '../../constants';
  11. /**
  12. * The type of the React {@code Component} props of {@link MoreTab}.
  13. */
  14. export type Props = AbstractDialogTabProps & WithTranslation & {
  15. /**
  16. * The currently selected desktop share frame rate in the frame rate select dropdown.
  17. */
  18. currentFramerate: string;
  19. /**
  20. * All available desktop capture frame rates.
  21. */
  22. desktopShareFramerates: Array<number>;
  23. /**
  24. * Whether or not follow me is currently active (enabled by some other participant).
  25. */
  26. followMeActive: boolean;
  27. /**
  28. * The number of max participants to display on stage.
  29. */
  30. maxStageParticipants: number;
  31. /**
  32. * Whether or not to display moderator-only settings.
  33. */
  34. showModeratorSettings: boolean;
  35. /**
  36. * Whether or not to show prejoin screen.
  37. */
  38. showPrejoinPage: boolean;
  39. /**
  40. * Whether or not to display the prejoin settings section.
  41. */
  42. showPrejoinSettings: boolean;
  43. /**
  44. * Wether or not the stage filmstrip is enabled.
  45. */
  46. stageFilmstripEnabled: boolean;
  47. /**
  48. * Invoked to obtain translated strings.
  49. */
  50. t: Function;
  51. };
  52. /**
  53. * React {@code Component} for modifying language and moderator settings.
  54. *
  55. * @augments Component
  56. */
  57. class MoreTab extends AbstractDialogTab<Props, any> {
  58. /**
  59. * Initializes a new {@code MoreTab} instance.
  60. *
  61. * @param {Object} props - The read-only properties with which the new
  62. * instance is to be initialized.
  63. */
  64. constructor(props: Props) {
  65. super(props);
  66. // Bind event handler so it is only bound once for every instance.
  67. this._onFramerateItemSelect = this._onFramerateItemSelect.bind(this);
  68. this._onShowPrejoinPageChanged = this._onShowPrejoinPageChanged.bind(this);
  69. this._renderMaxStageParticipantsSelect = this._renderMaxStageParticipantsSelect.bind(this);
  70. this._onMaxStageParticipantsSelect = this._onMaxStageParticipantsSelect.bind(this);
  71. }
  72. /**
  73. * Implements React's {@link Component#render()}.
  74. *
  75. * @inheritdoc
  76. * @returns {ReactElement}
  77. */
  78. render() {
  79. const content = [];
  80. content.push(this._renderSettingsLeft());
  81. content.push(this._renderSettingsRight());
  82. return (
  83. <div
  84. className = 'more-tab box'
  85. key = 'more'>
  86. { content }
  87. </div>
  88. );
  89. }
  90. /**
  91. * Callback invoked to select a frame rate from the select dropdown.
  92. *
  93. * @param {Object} e - The key event to handle.
  94. * @private
  95. * @returns {void}
  96. */
  97. _onFramerateItemSelect(e: React.ChangeEvent<HTMLSelectElement>) {
  98. const frameRate = e.target.value;
  99. super._onChange({ currentFramerate: frameRate });
  100. }
  101. /**
  102. * Callback invoked to select if the lobby
  103. * should be shown.
  104. *
  105. * @param {Object} e - The key event to handle.
  106. *
  107. * @returns {void}
  108. */
  109. _onShowPrejoinPageChanged({ target: { checked } }: React.ChangeEvent<HTMLInputElement>) {
  110. super._onChange({ showPrejoinPage: checked });
  111. }
  112. /**
  113. * Callback invoked to select a max number of stage participants from the select dropdown.
  114. *
  115. * @param {Object} e - The key event to handle.
  116. * @private
  117. * @returns {void}
  118. */
  119. _onMaxStageParticipantsSelect(e: React.ChangeEvent<HTMLSelectElement>) {
  120. const maxParticipants = Number(e.target.value);
  121. super._onChange({ maxStageParticipants: maxParticipants });
  122. }
  123. /**
  124. * Returns the React Element for the desktop share frame rate dropdown.
  125. *
  126. * @returns {ReactElement}
  127. */
  128. _renderFramerateSelect() {
  129. const { currentFramerate, desktopShareFramerates, t } = this.props;
  130. const frameRateItems = desktopShareFramerates.map((frameRate: number) => {
  131. return {
  132. value: frameRate,
  133. label: `${frameRate} ${t('settings.framesPerSecond')}`
  134. };
  135. });
  136. return (
  137. <div
  138. className = 'settings-sub-pane-element'
  139. key = 'frameRate'>
  140. <div className = 'dropdown-menu'>
  141. <Select
  142. bottomLabel = { parseInt(currentFramerate, 10) > SS_DEFAULT_FRAME_RATE
  143. ? t('settings.desktopShareHighFpsWarning')
  144. : t('settings.desktopShareWarning') }
  145. label = { t('settings.desktopShareFramerate') }
  146. onChange = { this._onFramerateItemSelect }
  147. options = { frameRateItems }
  148. value = { currentFramerate } />
  149. </div>
  150. </div>
  151. );
  152. }
  153. /**
  154. * Returns the React Element for modifying prejoin screen settings.
  155. *
  156. * @private
  157. * @returns {ReactElement}
  158. */
  159. _renderPrejoinScreenSettings() {
  160. const { t, showPrejoinPage } = this.props;
  161. return (
  162. <div
  163. className = 'settings-sub-pane-element'
  164. key = 'prejoin-screen'>
  165. <span className = 'checkbox-label'>
  166. { t('prejoin.premeeting') }
  167. </span>
  168. <Checkbox
  169. checked = { showPrejoinPage }
  170. label = { t('prejoin.showScreen') }
  171. name = 'show-prejoin-page'
  172. onChange = { this._onShowPrejoinPageChanged } />
  173. </div>
  174. );
  175. }
  176. /**
  177. * Returns the React Element for the max stage participants dropdown.
  178. *
  179. * @returns {ReactElement}
  180. */
  181. _renderMaxStageParticipantsSelect() {
  182. const { maxStageParticipants, t, stageFilmstripEnabled } = this.props;
  183. if (!stageFilmstripEnabled) {
  184. return null;
  185. }
  186. const maxParticipantsItems = Array(MAX_ACTIVE_PARTICIPANTS).fill(0)
  187. .map((no, index) => {
  188. return {
  189. value: index + 1,
  190. label: `${index + 1}`
  191. };
  192. });
  193. return (
  194. <div
  195. className = 'settings-sub-pane-element'
  196. key = 'maxStageParticipants'>
  197. <div className = 'dropdown-menu'>
  198. <Select
  199. label = { t('settings.maxStageParticipants') }
  200. onChange = { this._onMaxStageParticipantsSelect }
  201. options = { maxParticipantsItems }
  202. value = { maxStageParticipants } />
  203. </div>
  204. </div>
  205. );
  206. }
  207. /**
  208. * Returns the React element that needs to be displayed on the right half of the more tabs.
  209. *
  210. * @private
  211. * @returns {ReactElement}
  212. */
  213. _renderSettingsRight() {
  214. return (
  215. <div
  216. className = 'settings-sub-pane right'
  217. key = 'settings-sub-pane-right'>
  218. { this._renderFramerateSelect() }
  219. { this._renderMaxStageParticipantsSelect() }
  220. </div>
  221. );
  222. }
  223. /**
  224. * Returns the React element that needs to be displayed on the left half of the more tabs.
  225. *
  226. * @returns {ReactElement}
  227. */
  228. _renderSettingsLeft() {
  229. const { showPrejoinSettings } = this.props;
  230. return (
  231. <div
  232. className = 'settings-sub-pane left'
  233. key = 'settings-sub-pane-left'>
  234. { showPrejoinSettings && this._renderPrejoinScreenSettings() }
  235. </div>
  236. );
  237. }
  238. }
  239. export default translate(MoreTab);