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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. * Whether or not follow me is currently active (enabled by some other participant).
  23. */
  24. followMeActive: boolean;
  25. /**
  26. * The number of max participants to display on stage.
  27. */
  28. maxStageParticipants: number;
  29. /**
  30. * Whether or not to display moderator-only settings.
  31. */
  32. showModeratorSettings: boolean;
  33. /**
  34. * Whether or not to show prejoin screen.
  35. */
  36. showPrejoinPage: boolean;
  37. /**
  38. * Whether or not to display the prejoin settings section.
  39. */
  40. showPrejoinSettings: boolean;
  41. /**
  42. * Wether or not the stage filmstrip is enabled.
  43. */
  44. stageFilmstripEnabled: boolean;
  45. }
  46. const styles = (theme: Theme) => {
  47. return {
  48. container: {
  49. display: 'flex',
  50. flexDirection: 'column' as const
  51. },
  52. divider: {
  53. margin: `${theme.spacing(4)} 0`,
  54. width: '100%',
  55. height: '1px',
  56. border: 0,
  57. backgroundColor: theme.palette.ui03
  58. }
  59. };
  60. };
  61. /**
  62. * React {@code Component} for modifying language and moderator settings.
  63. *
  64. * @augments Component
  65. */
  66. class MoreTab extends AbstractDialogTab<IProps, any> {
  67. /**
  68. * Initializes a new {@code MoreTab} instance.
  69. *
  70. * @param {Object} props - The read-only properties with which the new
  71. * instance is to be initialized.
  72. */
  73. constructor(props: IProps) {
  74. super(props);
  75. // Bind event handler so it is only bound once for every instance.
  76. this._onShowPrejoinPageChanged = this._onShowPrejoinPageChanged.bind(this);
  77. this._renderMaxStageParticipantsSelect = this._renderMaxStageParticipantsSelect.bind(this);
  78. this._onMaxStageParticipantsSelect = this._onMaxStageParticipantsSelect.bind(this);
  79. }
  80. /**
  81. * Implements React's {@link Component#render()}.
  82. *
  83. * @inheritdoc
  84. * @returns {ReactElement}
  85. */
  86. render() {
  87. const { showPrejoinSettings, classes } = this.props;
  88. return (
  89. <div
  90. className = { clsx('more-tab', classes.container) }
  91. key = 'more'>
  92. {showPrejoinSettings && <>
  93. {this._renderPrejoinScreenSettings()}
  94. <hr className = { classes.divider } />
  95. </>}
  96. {this._renderMaxStageParticipantsSelect()}
  97. </div>
  98. );
  99. }
  100. /**
  101. * Callback invoked to select if the lobby
  102. * should be shown.
  103. *
  104. * @param {Object} e - The key event to handle.
  105. *
  106. * @returns {void}
  107. */
  108. _onShowPrejoinPageChanged({ target: { checked } }: React.ChangeEvent<HTMLInputElement>) {
  109. super._onChange({ showPrejoinPage: checked });
  110. }
  111. /**
  112. * Callback invoked to select a max number of stage participants from the select dropdown.
  113. *
  114. * @param {Object} e - The key event to handle.
  115. * @private
  116. * @returns {void}
  117. */
  118. _onMaxStageParticipantsSelect(e: React.ChangeEvent<HTMLSelectElement>) {
  119. const maxParticipants = Number(e.target.value);
  120. super._onChange({ maxStageParticipants: maxParticipants });
  121. }
  122. /**
  123. * Returns the React Element for modifying prejoin screen settings.
  124. *
  125. * @private
  126. * @returns {ReactElement}
  127. */
  128. _renderPrejoinScreenSettings() {
  129. const { t, showPrejoinPage } = this.props;
  130. return (
  131. <Checkbox
  132. checked = { showPrejoinPage }
  133. label = { t('prejoin.showScreen') }
  134. name = 'show-prejoin-page'
  135. onChange = { this._onShowPrejoinPageChanged } />
  136. );
  137. }
  138. /**
  139. * Returns the React Element for the max stage participants dropdown.
  140. *
  141. * @returns {ReactElement}
  142. */
  143. _renderMaxStageParticipantsSelect() {
  144. const { maxStageParticipants, t, stageFilmstripEnabled } = this.props;
  145. if (!stageFilmstripEnabled) {
  146. return null;
  147. }
  148. const maxParticipantsItems = Array(MAX_ACTIVE_PARTICIPANTS).fill(0)
  149. .map((no, index) => {
  150. return {
  151. value: index + 1,
  152. label: `${index + 1}`
  153. };
  154. });
  155. return (
  156. <Select
  157. label = { t('settings.maxStageParticipants') }
  158. onChange = { this._onMaxStageParticipantsSelect }
  159. options = { maxParticipantsItems }
  160. value = { maxStageParticipants } />
  161. );
  162. }
  163. }
  164. export default withStyles(styles)(translate(MoreTab));