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.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. import { Theme } from '@mui/material';
  2. import { withStyles } from '@mui/styles';
  3. import clsx from 'clsx';
  4. import React from 'react';
  5. import { WithTranslation } from 'react-i18next';
  6. import AbstractDialogTab, {
  7. IProps as AbstractDialogTabProps
  8. } from '../../../base/dialog/components/web/AbstractDialogTab';
  9. import { translate } from '../../../base/i18n/functions';
  10. import Checkbox from '../../../base/ui/components/web/Checkbox';
  11. import Select from '../../../base/ui/components/web/Select';
  12. import { MAX_ACTIVE_PARTICIPANTS } from '../../../filmstrip/constants';
  13. /**
  14. * The type of the React {@code Component} props of {@link MoreTab}.
  15. */
  16. export interface IProps extends AbstractDialogTabProps, WithTranslation {
  17. /**
  18. * CSS classes object.
  19. */
  20. classes: any;
  21. /**
  22. * The currently selected language to display in the language select
  23. * dropdown.
  24. */
  25. currentLanguage: string;
  26. /**
  27. * Whether to show hide self view setting.
  28. */
  29. disableHideSelfView: boolean;
  30. /**
  31. * Whether or not follow me is currently active (enabled by some other participant).
  32. */
  33. followMeActive: boolean;
  34. /**
  35. * Whether or not to hide self-view screen.
  36. */
  37. hideSelfView: boolean;
  38. /**
  39. * Whether we are in visitors mode.
  40. */
  41. iAmVisitor: boolean;
  42. /**
  43. * All available languages to display in the language select dropdown.
  44. */
  45. languages: Array<string>;
  46. /**
  47. * The number of max participants to display on stage.
  48. */
  49. maxStageParticipants: number;
  50. /**
  51. * Whether or not to display the language select dropdown.
  52. */
  53. showLanguageSettings: boolean;
  54. /**
  55. * Whether or not to display moderator-only settings.
  56. */
  57. showModeratorSettings: boolean;
  58. /**
  59. * Whether or not to show prejoin screen.
  60. */
  61. showPrejoinPage: boolean;
  62. /**
  63. * Whether or not to display the prejoin settings section.
  64. */
  65. showPrejoinSettings: boolean;
  66. /**
  67. * Wether or not the stage filmstrip is enabled.
  68. */
  69. stageFilmstripEnabled: boolean;
  70. }
  71. const styles = (theme: Theme) => {
  72. return {
  73. container: {
  74. display: 'flex',
  75. flexDirection: 'column' as const
  76. },
  77. divider: {
  78. margin: `${theme.spacing(4)} 0`,
  79. width: '100%',
  80. height: '1px',
  81. border: 0,
  82. backgroundColor: theme.palette.ui03
  83. },
  84. checkbox: {
  85. margin: `${theme.spacing(3)} 0`
  86. }
  87. };
  88. };
  89. /**
  90. * React {@code Component} for modifying language and moderator settings.
  91. *
  92. * @augments Component
  93. */
  94. class MoreTab extends AbstractDialogTab<IProps, any> {
  95. /**
  96. * Initializes a new {@code MoreTab} instance.
  97. *
  98. * @param {Object} props - The read-only properties with which the new
  99. * instance is to be initialized.
  100. */
  101. constructor(props: IProps) {
  102. super(props);
  103. // Bind event handler so it is only bound once for every instance.
  104. this._onShowPrejoinPageChanged = this._onShowPrejoinPageChanged.bind(this);
  105. this._renderMaxStageParticipantsSelect = this._renderMaxStageParticipantsSelect.bind(this);
  106. this._onMaxStageParticipantsSelect = this._onMaxStageParticipantsSelect.bind(this);
  107. this._onHideSelfViewChanged = this._onHideSelfViewChanged.bind(this);
  108. this._onLanguageItemSelect = this._onLanguageItemSelect.bind(this);
  109. }
  110. /**
  111. * Implements React's {@link Component#render()}.
  112. *
  113. * @inheritdoc
  114. * @returns {ReactElement}
  115. */
  116. render() {
  117. const {
  118. showPrejoinSettings,
  119. classes,
  120. disableHideSelfView,
  121. iAmVisitor,
  122. hideSelfView,
  123. showLanguageSettings,
  124. t } = this.props;
  125. return (
  126. <div
  127. className = { clsx('more-tab', classes.container) }
  128. key = 'more'>
  129. {showPrejoinSettings && <>
  130. {this._renderPrejoinScreenSettings()}
  131. <hr className = { classes.divider } />
  132. </>}
  133. {this._renderMaxStageParticipantsSelect()}
  134. {!disableHideSelfView && !iAmVisitor && (
  135. <Checkbox
  136. checked = { hideSelfView }
  137. className = { classes.checkbox }
  138. label = { t('videothumbnail.hideSelfView') }
  139. name = 'hide-self-view'
  140. onChange = { this._onHideSelfViewChanged } />
  141. )}
  142. {showLanguageSettings && this._renderLanguageSelect()}
  143. </div>
  144. );
  145. }
  146. /**
  147. * Callback invoked to select if the lobby
  148. * should be shown.
  149. *
  150. * @param {Object} e - The key event to handle.
  151. *
  152. * @returns {void}
  153. */
  154. _onShowPrejoinPageChanged({ target: { checked } }: React.ChangeEvent<HTMLInputElement>) {
  155. super._onChange({ showPrejoinPage: checked });
  156. }
  157. /**
  158. * Callback invoked to select a max number of stage participants from the select dropdown.
  159. *
  160. * @param {Object} e - The key event to handle.
  161. * @private
  162. * @returns {void}
  163. */
  164. _onMaxStageParticipantsSelect(e: React.ChangeEvent<HTMLSelectElement>) {
  165. const maxParticipants = Number(e.target.value);
  166. super._onChange({ maxStageParticipants: maxParticipants });
  167. }
  168. /**
  169. * Callback invoked to select if hide self view should be enabled.
  170. *
  171. * @param {Object} e - The key event to handle.
  172. *
  173. * @returns {void}
  174. */
  175. _onHideSelfViewChanged({ target: { checked } }: React.ChangeEvent<HTMLInputElement>) {
  176. super._onChange({ hideSelfView: checked });
  177. }
  178. /**
  179. * Callback invoked to select a language from select dropdown.
  180. *
  181. * @param {Object} e - The key event to handle.
  182. *
  183. * @returns {void}
  184. */
  185. _onLanguageItemSelect(e: React.ChangeEvent<HTMLSelectElement>) {
  186. const language = e.target.value;
  187. super._onChange({ currentLanguage: language });
  188. }
  189. /**
  190. * Returns the React Element for modifying prejoin screen settings.
  191. *
  192. * @private
  193. * @returns {ReactElement}
  194. */
  195. _renderPrejoinScreenSettings() {
  196. const { t, showPrejoinPage } = this.props;
  197. return (
  198. <Checkbox
  199. checked = { showPrejoinPage }
  200. label = { t('prejoin.showScreen') }
  201. name = 'show-prejoin-page'
  202. onChange = { this._onShowPrejoinPageChanged } />
  203. );
  204. }
  205. /**
  206. * Returns the React Element for the max stage participants dropdown.
  207. *
  208. * @returns {ReactElement}
  209. */
  210. _renderMaxStageParticipantsSelect() {
  211. const { maxStageParticipants, t, stageFilmstripEnabled } = this.props;
  212. if (!stageFilmstripEnabled) {
  213. return null;
  214. }
  215. const maxParticipantsItems = Array(MAX_ACTIVE_PARTICIPANTS).fill(0)
  216. .map((no, index) => {
  217. return {
  218. value: index + 1,
  219. label: `${index + 1}`
  220. };
  221. });
  222. return (
  223. <Select
  224. id = 'more-maxStageParticipants-select'
  225. label = { t('settings.maxStageParticipants') }
  226. onChange = { this._onMaxStageParticipantsSelect }
  227. options = { maxParticipantsItems }
  228. value = { maxStageParticipants } />
  229. );
  230. }
  231. /**
  232. * Returns the menu item for changing displayed language.
  233. *
  234. * @private
  235. * @returns {ReactElement}
  236. */
  237. _renderLanguageSelect() {
  238. const {
  239. classes,
  240. currentLanguage,
  241. languages,
  242. t
  243. } = this.props;
  244. const languageItems
  245. = languages.map((language: string) => {
  246. return {
  247. value: language,
  248. label: t(`languages:${language}`)
  249. };
  250. });
  251. return (
  252. <Select
  253. className = { classes.bottomMargin }
  254. id = 'more-language-select'
  255. label = { t('settings.language') }
  256. onChange = { this._onLanguageItemSelect }
  257. options = { languageItems }
  258. value = { currentLanguage } />
  259. );
  260. }
  261. }
  262. export default withStyles(styles)(translate(MoreTab));