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.

ModeratorCheckboxes.web.js 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. import PropTypes from 'prop-types';
  2. import React, { Component } from 'react';
  3. import { connect } from 'react-redux';
  4. import { setFollowMe, setStartMutedPolicy } from '../../base/conference';
  5. import { translate } from '../../base/i18n';
  6. /**
  7. * Implements a React {@link Component} which displays checkboxes for enabling
  8. * and disabling moderator-only conference features.
  9. *
  10. * @extends Component
  11. */
  12. class ModeratorCheckboxes extends Component {
  13. /**
  14. * {@code ModeratorCheckboxes} component's property types.
  15. *
  16. * @static
  17. */
  18. static propTypes = {
  19. /**
  20. * Whether or not the Follow Me feature is currently enabled.
  21. */
  22. _followMeEnabled: PropTypes.bool,
  23. /**
  24. * Whether or not new members will join the conference as audio muted.
  25. */
  26. _startAudioMutedPolicy: PropTypes.bool,
  27. /**
  28. * Whether or note new member will join the conference as video muted.
  29. */
  30. _startVideoMutedPolicy: PropTypes.bool,
  31. /**
  32. * Invoked to enable and disable moderator-only conference features.
  33. */
  34. dispatch: PropTypes.func,
  35. /**
  36. * Whether or not the title should be displayed.
  37. */
  38. showTitle: PropTypes.bool,
  39. /**
  40. * Invokted to obtain translated strings.
  41. */
  42. t: PropTypes.func
  43. };
  44. /**
  45. * Initializes a new {@code ModeratorCheckboxes} instance.
  46. *
  47. * @param {Object} props - The read-only properties with which the new
  48. * instance is to be initialized.
  49. */
  50. constructor(props) {
  51. super(props);
  52. // Bind event handlers so they are only bound once for every instance.
  53. this._onSetFollowMeSetting
  54. = this._onSetFollowMeSetting.bind(this);
  55. this._onSetStartAudioMutedPolicy
  56. = this._onSetStartAudioMutedPolicy.bind(this);
  57. this._onSetStartVideoMutedPolicy
  58. = this._onSetStartVideoMutedPolicy.bind(this);
  59. }
  60. /**
  61. * Implements React's {@link Component#render()}.
  62. *
  63. * @inheritdoc
  64. * @returns {ReactElement}
  65. */
  66. render() {
  67. const {
  68. _followMeEnabled,
  69. _startAudioMutedPolicy,
  70. _startVideoMutedPolicy,
  71. showTitle,
  72. t
  73. } = this.props;
  74. return (
  75. <div>
  76. { showTitle
  77. ? <div className = 'subTitle'>
  78. { t('settings.moderator') }
  79. </div>
  80. : null }
  81. <div className = 'moderator-option'>
  82. <input
  83. checked = { _startAudioMutedPolicy }
  84. className = 'moderator-checkbox'
  85. id = 'startAudioMuted'
  86. onChange = { this._onSetStartAudioMutedPolicy }
  87. type = 'checkbox' />
  88. <label
  89. className = 'moderator-checkbox-label'
  90. htmlFor = 'startAudioMuted'>
  91. { t('settings.startAudioMuted') }
  92. </label>
  93. </div>
  94. <div className = 'moderator-option'>
  95. <input
  96. checked = { _startVideoMutedPolicy }
  97. className = 'moderator-checkbox'
  98. id = 'startVideoMuted'
  99. onChange = { this._onSetStartVideoMutedPolicy }
  100. type = 'checkbox' />
  101. <label
  102. className = 'moderator-checkbox-label'
  103. htmlFor = 'startVideoMuted'>
  104. { t('settings.startVideoMuted') }
  105. </label>
  106. </div>
  107. <div className = 'moderator-option'>
  108. <input
  109. checked = { _followMeEnabled }
  110. className = 'moderator-checkbox'
  111. id = 'followMeCheckBox'
  112. onChange = { this._onSetFollowMeSetting }
  113. type = 'checkbox' />
  114. <label
  115. className = 'moderator-checkbox-label'
  116. htmlFor = 'followMeCheckBox'>
  117. { t('settings.followMe') }
  118. </label>
  119. </div>
  120. </div>
  121. );
  122. }
  123. /**
  124. * Toggles the Follow Me feature.
  125. *
  126. * @param {Object} event - The dom event returned from changes the checkbox.
  127. * @private
  128. * @returns {void}
  129. */
  130. _onSetFollowMeSetting(event) {
  131. this.props.dispatch(setFollowMe(event.target.checked));
  132. }
  133. /**
  134. * Toggles whether or not new members should join the conference as audio
  135. * muted.
  136. *
  137. * @param {Object} event - The dom event returned from changes the checkbox.
  138. * @private
  139. * @returns {void}
  140. */
  141. _onSetStartAudioMutedPolicy(event) {
  142. this.props.dispatch(setStartMutedPolicy(
  143. event.target.checked, this.props._startVideoMutedPolicy));
  144. }
  145. /**
  146. * Toggles whether or not new members should join the conference as video
  147. * muted.
  148. *
  149. * @param {Object} event - The dom event returned from changes the checkbox.
  150. * @private
  151. * @returns {void}
  152. */
  153. _onSetStartVideoMutedPolicy(event) {
  154. this.props.dispatch(setStartMutedPolicy(
  155. this.props._startAudioMutedPolicy, event.target.checked));
  156. }
  157. }
  158. /**
  159. * Maps (parts of) the Redux state to the associated props for the
  160. * {@code ModeratorCheckboxes} component.
  161. *
  162. * @param {Object} state - The Redux state.
  163. * @private
  164. * @returns {{
  165. * _followMeEnabled: boolean,
  166. * _startAudioMutedPolicy: boolean,
  167. * _startVideoMutedPolicy: boolean
  168. * }}
  169. */
  170. function _mapStateToProps(state) {
  171. const {
  172. followMeEnabled,
  173. startAudioMutedPolicy,
  174. startVideoMutedPolicy
  175. } = state['features/base/conference'];
  176. return {
  177. _followMeEnabled: Boolean(followMeEnabled),
  178. _startAudioMutedPolicy: Boolean(startAudioMutedPolicy),
  179. _startVideoMutedPolicy: Boolean(startVideoMutedPolicy)
  180. };
  181. }
  182. export default translate(connect(_mapStateToProps)(ModeratorCheckboxes));