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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. import { Theme } from '@mui/material';
  2. import { withStyles } from '@mui/styles';
  3. import React from 'react';
  4. import { WithTranslation } from 'react-i18next';
  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: any;
  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 or not the user has selected the Start Audio Muted feature to be
  32. * enabled.
  33. */
  34. startAudioMuted: boolean;
  35. /**
  36. * Whether or not the user has selected the Start Reactions Muted feature to be
  37. * enabled.
  38. */
  39. startReactionsMuted: boolean;
  40. /**
  41. * Whether or not the user has selected the Start Video Muted feature to be
  42. * enabled.
  43. */
  44. startVideoMuted: boolean;
  45. }
  46. const styles = (theme: Theme) => {
  47. return {
  48. container: {
  49. display: 'flex',
  50. flexDirection: 'column' as const
  51. },
  52. title: {
  53. ...withPixelLineHeight(theme.typography.heading6),
  54. color: `${theme.palette.text01} !important`,
  55. marginBottom: theme.spacing(3)
  56. },
  57. checkbox: {
  58. marginBottom: theme.spacing(3)
  59. }
  60. };
  61. };
  62. /**
  63. * React {@code Component} for modifying language and moderator settings.
  64. *
  65. * @augments Component
  66. */
  67. class ModeratorTab extends AbstractDialogTab<IProps, any> {
  68. /**
  69. * Initializes a new {@code ModeratorTab} instance.
  70. *
  71. * @param {Object} props - The read-only properties with which the new
  72. * instance is to be initialized.
  73. */
  74. constructor(props: IProps) {
  75. super(props);
  76. // Bind event handler so it is only bound once for every instance.
  77. this._onStartAudioMutedChanged = this._onStartAudioMutedChanged.bind(this);
  78. this._onStartVideoMutedChanged = this._onStartVideoMutedChanged.bind(this);
  79. this._onStartReactionsMutedChanged = this._onStartReactionsMutedChanged.bind(this);
  80. this._onFollowMeEnabledChanged = this._onFollowMeEnabledChanged.bind(this);
  81. }
  82. /**
  83. * Callback invoked to select if conferences should start
  84. * with audio muted.
  85. *
  86. * @param {Object} e - The key event to handle.
  87. *
  88. * @returns {void}
  89. */
  90. _onStartAudioMutedChanged({ target: { checked } }: React.ChangeEvent<HTMLInputElement>) {
  91. super._onChange({ startAudioMuted: checked });
  92. }
  93. /**
  94. * Callback invoked to select if conferences should start
  95. * with video disabled.
  96. *
  97. * @param {Object} e - The key event to handle.
  98. *
  99. * @returns {void}
  100. */
  101. _onStartVideoMutedChanged({ target: { checked } }: React.ChangeEvent<HTMLInputElement>) {
  102. super._onChange({ startVideoMuted: checked });
  103. }
  104. /**
  105. * Callback invoked to select if conferences should start
  106. * with reactions muted.
  107. *
  108. * @param {Object} e - The key event to handle.
  109. *
  110. * @returns {void}
  111. */
  112. _onStartReactionsMutedChanged({ target: { checked } }: React.ChangeEvent<HTMLInputElement>) {
  113. super._onChange({ startReactionsMuted: checked });
  114. }
  115. /**
  116. * Callback invoked to select if follow-me mode
  117. * should be activated.
  118. *
  119. * @param {Object} e - The key event to handle.
  120. *
  121. * @returns {void}
  122. */
  123. _onFollowMeEnabledChanged({ target: { checked } }: React.ChangeEvent<HTMLInputElement>) {
  124. super._onChange({ followMeEnabled: checked });
  125. }
  126. /**
  127. * Implements React's {@link Component#render()}.
  128. *
  129. * @inheritdoc
  130. * @returns {ReactElement}
  131. */
  132. render() {
  133. const {
  134. classes,
  135. disableReactionsModeration,
  136. followMeActive,
  137. followMeEnabled,
  138. startAudioMuted,
  139. startVideoMuted,
  140. startReactionsMuted,
  141. t
  142. } = this.props;
  143. return (
  144. <div
  145. className = { `moderator-tab ${classes.container}` }
  146. key = 'moderator'>
  147. <h2 className = { classes.title }>
  148. {t('settings.moderatorOptions')}
  149. </h2>
  150. <Checkbox
  151. checked = { startAudioMuted }
  152. className = { classes.checkbox }
  153. label = { t('settings.startAudioMuted') }
  154. name = 'start-audio-muted'
  155. onChange = { this._onStartAudioMutedChanged } />
  156. <Checkbox
  157. checked = { startVideoMuted }
  158. className = { classes.checkbox }
  159. label = { t('settings.startVideoMuted') }
  160. name = 'start-video-muted'
  161. onChange = { this._onStartVideoMutedChanged } />
  162. <Checkbox
  163. checked = { followMeEnabled && !followMeActive }
  164. className = { classes.checkbox }
  165. disabled = { followMeActive }
  166. label = { t('settings.followMe') }
  167. name = 'follow-me'
  168. onChange = { this._onFollowMeEnabledChanged } />
  169. { !disableReactionsModeration
  170. && <Checkbox
  171. checked = { startReactionsMuted }
  172. className = { classes.checkbox }
  173. label = { t('settings.startReactionsMuted') }
  174. name = 'start-reactions-muted'
  175. onChange = { this._onStartReactionsMutedChanged } /> }
  176. </div>
  177. );
  178. }
  179. }
  180. export default withStyles(styles)(translate(ModeratorTab));