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 clsx from 'clsx';
  3. import React from 'react';
  4. import { WithTranslation } from 'react-i18next';
  5. import { withStyles } from 'tss-react/mui';
  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?: Partial<Record<keyof ReturnType<typeof styles>, string>>;
  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. * Whether 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. disableHideSelfView,
  121. iAmVisitor,
  122. hideSelfView,
  123. showLanguageSettings,
  124. t
  125. } = this.props;
  126. const classes = withStyles.getClasses(this.props);
  127. return (
  128. <div
  129. className = { clsx('more-tab', classes.container) }
  130. key = 'more'>
  131. {showPrejoinSettings && <>
  132. {this._renderPrejoinScreenSettings()}
  133. <hr className = { classes.divider } />
  134. </>}
  135. {this._renderMaxStageParticipantsSelect()}
  136. {!disableHideSelfView && !iAmVisitor && (
  137. <Checkbox
  138. checked = { hideSelfView }
  139. className = { classes.checkbox }
  140. label = { t('videothumbnail.hideSelfView') }
  141. name = 'hide-self-view'
  142. onChange = { this._onHideSelfViewChanged } />
  143. )}
  144. {showLanguageSettings && this._renderLanguageSelect()}
  145. </div>
  146. );
  147. }
  148. /**
  149. * Callback invoked to select if the lobby
  150. * should be shown.
  151. *
  152. * @param {Object} e - The key event to handle.
  153. *
  154. * @returns {void}
  155. */
  156. _onShowPrejoinPageChanged({ target: { checked } }: React.ChangeEvent<HTMLInputElement>) {
  157. super._onChange({ showPrejoinPage: checked });
  158. }
  159. /**
  160. * Callback invoked to select a max number of stage participants from the select dropdown.
  161. *
  162. * @param {Object} e - The key event to handle.
  163. * @private
  164. * @returns {void}
  165. */
  166. _onMaxStageParticipantsSelect(e: React.ChangeEvent<HTMLSelectElement>) {
  167. const maxParticipants = Number(e.target.value);
  168. super._onChange({ maxStageParticipants: maxParticipants });
  169. }
  170. /**
  171. * Callback invoked to select if hide self view should be enabled.
  172. *
  173. * @param {Object} e - The key event to handle.
  174. *
  175. * @returns {void}
  176. */
  177. _onHideSelfViewChanged({ target: { checked } }: React.ChangeEvent<HTMLInputElement>) {
  178. super._onChange({ hideSelfView: checked });
  179. }
  180. /**
  181. * Callback invoked to select a language from select dropdown.
  182. *
  183. * @param {Object} e - The key event to handle.
  184. *
  185. * @returns {void}
  186. */
  187. _onLanguageItemSelect(e: React.ChangeEvent<HTMLSelectElement>) {
  188. const language = e.target.value;
  189. super._onChange({ currentLanguage: language });
  190. }
  191. /**
  192. * Returns the React Element for modifying prejoin screen settings.
  193. *
  194. * @private
  195. * @returns {ReactElement}
  196. */
  197. _renderPrejoinScreenSettings() {
  198. const { t, showPrejoinPage } = this.props;
  199. return (
  200. <Checkbox
  201. checked = { showPrejoinPage }
  202. label = { t('prejoin.showScreen') }
  203. name = 'show-prejoin-page'
  204. onChange = { this._onShowPrejoinPageChanged } />
  205. );
  206. }
  207. /**
  208. * Returns the React Element for the max stage participants dropdown.
  209. *
  210. * @returns {ReactElement}
  211. */
  212. _renderMaxStageParticipantsSelect() {
  213. const { maxStageParticipants, t, stageFilmstripEnabled } = this.props;
  214. if (!stageFilmstripEnabled) {
  215. return null;
  216. }
  217. const maxParticipantsItems = Array(MAX_ACTIVE_PARTICIPANTS).fill(0)
  218. .map((no, index) => {
  219. return {
  220. value: index + 1,
  221. label: `${index + 1}`
  222. };
  223. });
  224. return (
  225. <Select
  226. id = 'more-maxStageParticipants-select'
  227. label = { t('settings.maxStageParticipants') }
  228. onChange = { this._onMaxStageParticipantsSelect }
  229. options = { maxParticipantsItems }
  230. value = { maxStageParticipants } />
  231. );
  232. }
  233. /**
  234. * Returns the menu item for changing displayed language.
  235. *
  236. * @private
  237. * @returns {ReactElement}
  238. */
  239. _renderLanguageSelect() {
  240. const {
  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. 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(translate(MoreTab), styles);