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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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. padding: '0 2px'
  77. },
  78. divider: {
  79. margin: `${theme.spacing(4)} 0`,
  80. width: '100%',
  81. height: '1px',
  82. border: 0,
  83. backgroundColor: theme.palette.ui03
  84. },
  85. checkbox: {
  86. margin: `${theme.spacing(3)} 0`
  87. }
  88. };
  89. };
  90. /**
  91. * React {@code Component} for modifying language and moderator settings.
  92. *
  93. * @augments Component
  94. */
  95. class MoreTab extends AbstractDialogTab<IProps, any> {
  96. /**
  97. * Initializes a new {@code MoreTab} instance.
  98. *
  99. * @param {Object} props - The read-only properties with which the new
  100. * instance is to be initialized.
  101. */
  102. constructor(props: IProps) {
  103. super(props);
  104. // Bind event handler so it is only bound once for every instance.
  105. this._onShowPrejoinPageChanged = this._onShowPrejoinPageChanged.bind(this);
  106. this._renderMaxStageParticipantsSelect = this._renderMaxStageParticipantsSelect.bind(this);
  107. this._onMaxStageParticipantsSelect = this._onMaxStageParticipantsSelect.bind(this);
  108. this._onHideSelfViewChanged = this._onHideSelfViewChanged.bind(this);
  109. this._onLanguageItemSelect = this._onLanguageItemSelect.bind(this);
  110. }
  111. /**
  112. * Implements React's {@link Component#render()}.
  113. *
  114. * @inheritdoc
  115. * @returns {ReactElement}
  116. */
  117. render() {
  118. const {
  119. showPrejoinSettings,
  120. classes,
  121. disableHideSelfView,
  122. iAmVisitor,
  123. hideSelfView,
  124. showLanguageSettings,
  125. t } = this.props;
  126. return (
  127. <div
  128. className = { clsx('more-tab', classes.container) }
  129. key = 'more'>
  130. {showPrejoinSettings && <>
  131. {this._renderPrejoinScreenSettings()}
  132. <hr className = { classes.divider } />
  133. </>}
  134. {this._renderMaxStageParticipantsSelect()}
  135. {!disableHideSelfView && !iAmVisitor && (
  136. <Checkbox
  137. checked = { hideSelfView }
  138. className = { classes.checkbox }
  139. label = { t('videothumbnail.hideSelfView') }
  140. name = 'hide-self-view'
  141. onChange = { this._onHideSelfViewChanged } />
  142. )}
  143. {showLanguageSettings && this._renderLanguageSelect()}
  144. </div>
  145. );
  146. }
  147. /**
  148. * Callback invoked to select if the lobby
  149. * should be shown.
  150. *
  151. * @param {Object} e - The key event to handle.
  152. *
  153. * @returns {void}
  154. */
  155. _onShowPrejoinPageChanged({ target: { checked } }: React.ChangeEvent<HTMLInputElement>) {
  156. super._onChange({ showPrejoinPage: checked });
  157. }
  158. /**
  159. * Callback invoked to select a max number of stage participants from the select dropdown.
  160. *
  161. * @param {Object} e - The key event to handle.
  162. * @private
  163. * @returns {void}
  164. */
  165. _onMaxStageParticipantsSelect(e: React.ChangeEvent<HTMLSelectElement>) {
  166. const maxParticipants = Number(e.target.value);
  167. super._onChange({ maxStageParticipants: maxParticipants });
  168. }
  169. /**
  170. * Callback invoked to select if hide self view should be enabled.
  171. *
  172. * @param {Object} e - The key event to handle.
  173. *
  174. * @returns {void}
  175. */
  176. _onHideSelfViewChanged({ target: { checked } }: React.ChangeEvent<HTMLInputElement>) {
  177. super._onChange({ hideSelfView: checked });
  178. }
  179. /**
  180. * Callback invoked to select a language from select dropdown.
  181. *
  182. * @param {Object} e - The key event to handle.
  183. *
  184. * @returns {void}
  185. */
  186. _onLanguageItemSelect(e: React.ChangeEvent<HTMLSelectElement>) {
  187. const language = e.target.value;
  188. super._onChange({ currentLanguage: language });
  189. }
  190. /**
  191. * Returns the React Element for modifying prejoin screen settings.
  192. *
  193. * @private
  194. * @returns {ReactElement}
  195. */
  196. _renderPrejoinScreenSettings() {
  197. const { t, showPrejoinPage } = this.props;
  198. return (
  199. <Checkbox
  200. checked = { showPrejoinPage }
  201. label = { t('prejoin.showScreen') }
  202. name = 'show-prejoin-page'
  203. onChange = { this._onShowPrejoinPageChanged } />
  204. );
  205. }
  206. /**
  207. * Returns the React Element for the max stage participants dropdown.
  208. *
  209. * @returns {ReactElement}
  210. */
  211. _renderMaxStageParticipantsSelect() {
  212. const { maxStageParticipants, t, stageFilmstripEnabled } = this.props;
  213. if (!stageFilmstripEnabled) {
  214. return null;
  215. }
  216. const maxParticipantsItems = Array(MAX_ACTIVE_PARTICIPANTS).fill(0)
  217. .map((no, index) => {
  218. return {
  219. value: index + 1,
  220. label: `${index + 1}`
  221. };
  222. });
  223. return (
  224. <Select
  225. id = 'more-maxStageParticipants-select'
  226. label = { t('settings.maxStageParticipants') }
  227. onChange = { this._onMaxStageParticipantsSelect }
  228. options = { maxParticipantsItems }
  229. value = { maxStageParticipants } />
  230. );
  231. }
  232. /**
  233. * Returns the menu item for changing displayed language.
  234. *
  235. * @private
  236. * @returns {ReactElement}
  237. */
  238. _renderLanguageSelect() {
  239. const {
  240. classes,
  241. currentLanguage,
  242. languages,
  243. t
  244. } = this.props;
  245. const languageItems
  246. = languages.map((language: string) => {
  247. return {
  248. value: language,
  249. label: t(`languages:${language}`)
  250. };
  251. });
  252. return (
  253. <Select
  254. className = { classes.bottomMargin }
  255. id = 'more-language-select'
  256. label = { t('settings.language') }
  257. onChange = { this._onLanguageItemSelect }
  258. options = { languageItems }
  259. value = { currentLanguage } />
  260. );
  261. }
  262. }
  263. export default withStyles(styles)(translate(MoreTab));