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.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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({
  134. followMeEnabled: checked,
  135. followMeRecorderEnabled: checked ? false : undefined
  136. });
  137. }
  138. /**
  139. * Callback invoked to select if follow-me for recorder mode should be activated.
  140. *
  141. * @param {Object} e - The key event to handle.
  142. *
  143. * @returns {void}
  144. */
  145. _onFollowMeRecorderEnabledChanged({ target: { checked } }: React.ChangeEvent<HTMLInputElement>) {
  146. super._onChange({
  147. followMeEnabled: checked ? false : undefined,
  148. followMeRecorderEnabled: checked
  149. });
  150. }
  151. /**
  152. * Implements React's {@link Component#render()}.
  153. *
  154. * @inheritdoc
  155. * @returns {ReactElement}
  156. */
  157. render() {
  158. const {
  159. disableReactionsModeration,
  160. followMeActive,
  161. followMeEnabled,
  162. followMeRecorderActive,
  163. followMeRecorderEnabled,
  164. startAudioMuted,
  165. startVideoMuted,
  166. startReactionsMuted,
  167. t
  168. } = this.props;
  169. const classes = withStyles.getClasses(this.props);
  170. const followMeRecorderChecked = followMeRecorderEnabled && !followMeRecorderActive;
  171. return (
  172. <div
  173. className = { `moderator-tab ${classes.container}` }
  174. key = 'moderator'>
  175. <h2 className = { classes.title }>
  176. {t('settings.moderatorOptions')}
  177. </h2>
  178. <Checkbox
  179. checked = { startAudioMuted }
  180. className = { classes.checkbox }
  181. label = { t('settings.startAudioMuted') }
  182. name = 'start-audio-muted'
  183. onChange = { this._onStartAudioMutedChanged } />
  184. <Checkbox
  185. checked = { startVideoMuted }
  186. className = { classes.checkbox }
  187. label = { t('settings.startVideoMuted') }
  188. name = 'start-video-muted'
  189. onChange = { this._onStartVideoMutedChanged } />
  190. <Checkbox
  191. checked = { followMeEnabled && !followMeActive && !followMeRecorderChecked }
  192. className = { classes.checkbox }
  193. disabled = { followMeActive || followMeRecorderActive }
  194. label = { t('settings.followMe') }
  195. name = 'follow-me'
  196. onChange = { this._onFollowMeEnabledChanged } />
  197. <Checkbox
  198. checked = { followMeRecorderChecked }
  199. className = { classes.checkbox }
  200. disabled = { followMeRecorderActive || followMeActive }
  201. label = { t('settings.followMeRecorder') }
  202. name = 'follow-me-recorder'
  203. onChange = { this._onFollowMeRecorderEnabledChanged } />
  204. { !disableReactionsModeration
  205. && <Checkbox
  206. checked = { startReactionsMuted }
  207. className = { classes.checkbox }
  208. label = { t('settings.startReactionsMuted') }
  209. name = 'start-reactions-muted'
  210. onChange = { this._onStartReactionsMutedChanged } /> }
  211. </div>
  212. );
  213. }
  214. }
  215. export default withStyles(translate(ModeratorTab), styles);