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.

ModeratorTab.tsx 7.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. import { Theme } from '@mui/material';
  2. import React from 'react';
  3. import { WithTranslation } from 'react-i18next';
  4. import { withStyles } from 'tss-react/mui';
  5. import AbstractDialogTab, {
  6. IProps as AbstractDialogTabProps } from '../../../base/dialog/components/web/AbstractDialogTab';
  7. import { translate } from '../../../base/i18n/functions';
  8. import { withPixelLineHeight } from '../../../base/styles/functions.web';
  9. import Checkbox from '../../../base/ui/components/web/Checkbox';
  10. /**
  11. * The type of the React {@code Component} props of {@link ModeratorTab}.
  12. */
  13. export interface IProps extends AbstractDialogTabProps, WithTranslation {
  14. /**
  15. * CSS classes object.
  16. */
  17. classes?: Partial<Record<keyof ReturnType<typeof styles>, string>>;
  18. /**
  19. * If set hides the reactions moderation setting.
  20. */
  21. disableReactionsModeration: boolean;
  22. /**
  23. * Whether or not follow me is currently active (enabled by some other participant).
  24. */
  25. followMeActive: boolean;
  26. /**
  27. * Whether or not the user has selected the Follow Me feature to be enabled.
  28. */
  29. followMeEnabled: boolean;
  30. /**
  31. * Whether follow me for recorder is currently active (enabled by some other participant).
  32. */
  33. followMeRecorderActive: boolean;
  34. /**
  35. * Whether the user has selected the Follow Me Recorder feature to be enabled.
  36. */
  37. followMeRecorderEnabled: boolean;
  38. /**
  39. * Whether or not the user has selected the Start Audio Muted feature to be
  40. * enabled.
  41. */
  42. startAudioMuted: boolean;
  43. /**
  44. * Whether or not the user has selected the Start Reactions Muted feature to be
  45. * enabled.
  46. */
  47. startReactionsMuted: boolean;
  48. /**
  49. * Whether or not the user has selected the Start Video Muted feature to be
  50. * enabled.
  51. */
  52. startVideoMuted: boolean;
  53. }
  54. const styles = (theme: Theme) => {
  55. return {
  56. container: {
  57. display: 'flex',
  58. flexDirection: 'column' as const
  59. },
  60. title: {
  61. ...withPixelLineHeight(theme.typography.heading6),
  62. color: `${theme.palette.text01} !important`,
  63. marginBottom: theme.spacing(3)
  64. },
  65. checkbox: {
  66. marginBottom: theme.spacing(3)
  67. }
  68. };
  69. };
  70. /**
  71. * React {@code Component} for modifying language and moderator settings.
  72. *
  73. * @augments Component
  74. */
  75. class ModeratorTab extends AbstractDialogTab<IProps, any> {
  76. /**
  77. * Initializes a new {@code ModeratorTab} instance.
  78. *
  79. * @param {Object} props - The read-only properties with which the new
  80. * instance is to be initialized.
  81. */
  82. constructor(props: IProps) {
  83. super(props);
  84. // Bind event handler so it is only bound once for every instance.
  85. this._onStartAudioMutedChanged = this._onStartAudioMutedChanged.bind(this);
  86. this._onStartVideoMutedChanged = this._onStartVideoMutedChanged.bind(this);
  87. this._onStartReactionsMutedChanged = this._onStartReactionsMutedChanged.bind(this);
  88. this._onFollowMeEnabledChanged = this._onFollowMeEnabledChanged.bind(this);
  89. this._onFollowMeRecorderEnabledChanged = this._onFollowMeRecorderEnabledChanged.bind(this);
  90. }
  91. /**
  92. * Callback invoked to select if conferences should start
  93. * with audio muted.
  94. *
  95. * @param {Object} e - The key event to handle.
  96. *
  97. * @returns {void}
  98. */
  99. _onStartAudioMutedChanged({ target: { checked } }: React.ChangeEvent<HTMLInputElement>) {
  100. super._onChange({ startAudioMuted: checked });
  101. }
  102. /**
  103. * Callback invoked to select if conferences should start
  104. * with video disabled.
  105. *
  106. * @param {Object} e - The key event to handle.
  107. *
  108. * @returns {void}
  109. */
  110. _onStartVideoMutedChanged({ target: { checked } }: React.ChangeEvent<HTMLInputElement>) {
  111. super._onChange({ startVideoMuted: checked });
  112. }
  113. /**
  114. * Callback invoked to select if conferences should start
  115. * with reactions muted.
  116. *
  117. * @param {Object} e - The key event to handle.
  118. *
  119. * @returns {void}
  120. */
  121. _onStartReactionsMutedChanged({ target: { checked } }: React.ChangeEvent<HTMLInputElement>) {
  122. super._onChange({ startReactionsMuted: checked });
  123. }
  124. /**
  125. * Callback invoked to select if follow-me mode
  126. * should be activated.
  127. *
  128. * @param {Object} e - The key event to handle.
  129. *
  130. * @returns {void}
  131. */
  132. _onFollowMeEnabledChanged({ target: { checked } }: React.ChangeEvent<HTMLInputElement>) {
  133. super._onChange({ followMeEnabled: checked });
  134. }
  135. /**
  136. * Callback invoked to select if follow-me for recorder mode should be activated.
  137. *
  138. * @param {Object} e - The key event to handle.
  139. *
  140. * @returns {void}
  141. */
  142. _onFollowMeRecorderEnabledChanged({ target: { checked } }: React.ChangeEvent<HTMLInputElement>) {
  143. super._onChange({ followMeRecorderEnabled: checked });
  144. }
  145. /**
  146. * Implements React's {@link Component#render()}.
  147. *
  148. * @inheritdoc
  149. * @returns {ReactElement}
  150. */
  151. render() {
  152. const {
  153. disableReactionsModeration,
  154. followMeActive,
  155. followMeEnabled,
  156. followMeRecorderActive,
  157. followMeRecorderEnabled,
  158. startAudioMuted,
  159. startVideoMuted,
  160. startReactionsMuted,
  161. t
  162. } = this.props;
  163. const classes = withStyles.getClasses(this.props);
  164. return (
  165. <div
  166. className = { `moderator-tab ${classes.container}` }
  167. key = 'moderator'>
  168. <h2 className = { classes.title }>
  169. {t('settings.moderatorOptions')}
  170. </h2>
  171. <Checkbox
  172. checked = { startAudioMuted }
  173. className = { classes.checkbox }
  174. label = { t('settings.startAudioMuted') }
  175. name = 'start-audio-muted'
  176. onChange = { this._onStartAudioMutedChanged } />
  177. <Checkbox
  178. checked = { startVideoMuted }
  179. className = { classes.checkbox }
  180. label = { t('settings.startVideoMuted') }
  181. name = 'start-video-muted'
  182. onChange = { this._onStartVideoMutedChanged } />
  183. <Checkbox
  184. checked = { followMeEnabled && !followMeActive }
  185. className = { classes.checkbox }
  186. disabled = { followMeActive || followMeRecorderActive }
  187. label = { t('settings.followMe') }
  188. name = 'follow-me'
  189. onChange = { this._onFollowMeEnabledChanged } />
  190. <Checkbox
  191. checked = { followMeRecorderEnabled && !followMeRecorderActive }
  192. className = { classes.checkbox }
  193. disabled = { followMeRecorderActive || followMeActive }
  194. label = { t('settings.followMeRecorder') }
  195. name = 'follow-me-recorder'
  196. onChange = { this._onFollowMeRecorderEnabledChanged } />
  197. { !disableReactionsModeration
  198. && <Checkbox
  199. checked = { startReactionsMuted }
  200. className = { classes.checkbox }
  201. label = { t('settings.startReactionsMuted') }
  202. name = 'start-reactions-muted'
  203. onChange = { this._onStartReactionsMutedChanged } /> }
  204. </div>
  205. );
  206. }
  207. }
  208. export default withStyles(translate(ModeratorTab), styles);