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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. import React from 'react';
  2. import { WithTranslation } from 'react-i18next';
  3. // @ts-ignore
  4. import { AbstractDialogTab } from '../../../base/dialog';
  5. // eslint-disable-next-line lines-around-comment
  6. // @ts-ignore
  7. import type { Props as AbstractDialogTabProps } from '../../../base/dialog';
  8. import { translate } from '../../../base/i18n/functions';
  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 type Props = AbstractDialogTabProps & WithTranslation & {
  14. /**
  15. * If set hides the reactions moderation setting.
  16. */
  17. disableReactionsModeration: boolean;
  18. /**
  19. * Whether or not follow me is currently active (enabled by some other participant).
  20. */
  21. followMeActive: boolean;
  22. /**
  23. * Whether or not the user has selected the Follow Me feature to be enabled.
  24. */
  25. followMeEnabled: boolean;
  26. /**
  27. * Whether or not the user has selected the Start Audio Muted feature to be
  28. * enabled.
  29. */
  30. startAudioMuted: boolean;
  31. /**
  32. * Whether or not the user has selected the Start Reactions Muted feature to be
  33. * enabled.
  34. */
  35. startReactionsMuted: boolean;
  36. /**
  37. * Whether or not the user has selected the Start Video Muted feature to be
  38. * enabled.
  39. */
  40. startVideoMuted: boolean;
  41. /**
  42. * Invoked to obtain translated strings.
  43. */
  44. t: Function;
  45. };
  46. /**
  47. * React {@code Component} for modifying language and moderator settings.
  48. *
  49. * @augments Component
  50. */
  51. class ModeratorTab extends AbstractDialogTab<Props> {
  52. /**
  53. * Initializes a new {@code ModeratorTab} instance.
  54. *
  55. * @param {Object} props - The read-only properties with which the new
  56. * instance is to be initialized.
  57. */
  58. constructor(props: Props) {
  59. super(props);
  60. // Bind event handler so it is only bound once for every instance.
  61. this._onStartAudioMutedChanged = this._onStartAudioMutedChanged.bind(this);
  62. this._onStartVideoMutedChanged = this._onStartVideoMutedChanged.bind(this);
  63. this._onStartReactionsMutedChanged = this._onStartReactionsMutedChanged.bind(this);
  64. this._onFollowMeEnabledChanged = this._onFollowMeEnabledChanged.bind(this);
  65. }
  66. /**
  67. * Implements React's {@link Component#render()}.
  68. *
  69. * @inheritdoc
  70. * @returns {ReactElement}
  71. */
  72. render() {
  73. return <div className = 'moderator-tab box'>{ this._renderModeratorSettings() }</div>;
  74. }
  75. /**
  76. * Callback invoked to select if conferences should start
  77. * with audio muted.
  78. *
  79. * @param {Object} e - The key event to handle.
  80. *
  81. * @returns {void}
  82. */
  83. _onStartAudioMutedChanged({ target: { checked } }: React.ChangeEvent<HTMLInputElement>) {
  84. super._onChange({ startAudioMuted: checked });
  85. }
  86. /**
  87. * Callback invoked to select if conferences should start
  88. * with video disabled.
  89. *
  90. * @param {Object} e - The key event to handle.
  91. *
  92. * @returns {void}
  93. */
  94. _onStartVideoMutedChanged({ target: { checked } }: React.ChangeEvent<HTMLInputElement>) {
  95. super._onChange({ startVideoMuted: checked });
  96. }
  97. /**
  98. * Callback invoked to select if conferences should start
  99. * with reactions muted.
  100. *
  101. * @param {Object} e - The key event to handle.
  102. *
  103. * @returns {void}
  104. */
  105. _onStartReactionsMutedChanged({ target: { checked } }: React.ChangeEvent<HTMLInputElement>) {
  106. super._onChange({ startReactionsMuted: checked });
  107. }
  108. /**
  109. * Callback invoked to select if follow-me mode
  110. * should be activated.
  111. *
  112. * @param {Object} e - The key event to handle.
  113. *
  114. * @returns {void}
  115. */
  116. _onFollowMeEnabledChanged({ target: { checked } }: React.ChangeEvent<HTMLInputElement>) {
  117. super._onChange({ followMeEnabled: checked });
  118. }
  119. /**
  120. * Returns the React Element for modifying conference-wide settings.
  121. *
  122. * @private
  123. * @returns {ReactElement}
  124. */
  125. _renderModeratorSettings() {
  126. const {
  127. disableReactionsModeration,
  128. followMeActive,
  129. followMeEnabled,
  130. startAudioMuted,
  131. startVideoMuted,
  132. startReactionsMuted,
  133. t // @ts-ignore
  134. } = this.props;
  135. return (
  136. <div
  137. className = 'settings-sub-pane-element'
  138. key = 'moderator'>
  139. <div className = 'moderator-settings-wrapper'>
  140. <Checkbox
  141. checked = { startAudioMuted }
  142. className = 'settings-checkbox'
  143. label = { t('settings.startAudioMuted') }
  144. name = 'start-audio-muted'
  145. onChange = { this._onStartAudioMutedChanged } />
  146. <Checkbox
  147. checked = { startVideoMuted }
  148. className = 'settings-checkbox'
  149. label = { t('settings.startVideoMuted') }
  150. name = 'start-video-muted'
  151. onChange = { this._onStartVideoMutedChanged } />
  152. <Checkbox
  153. checked = { followMeEnabled && !followMeActive }
  154. className = 'settings-checkbox'
  155. disabled = { followMeActive }
  156. label = { t('settings.followMe') }
  157. name = 'follow-me'
  158. onChange = { this._onFollowMeEnabledChanged } />
  159. { !disableReactionsModeration
  160. && <Checkbox
  161. checked = { startReactionsMuted }
  162. className = 'settings-checkbox'
  163. label = { t('settings.startReactionsMuted') }
  164. name = 'start-reactions-muted'
  165. onChange = { this._onStartReactionsMutedChanged } /> }
  166. </div>
  167. </div>
  168. );
  169. }
  170. }
  171. // @ts-ignore
  172. export default translate(ModeratorTab);