選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

MoreTab.tsx 6.4KB

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