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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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 SoundsTab}.
  12. */
  13. export type Props = AbstractDialogTabProps & WithTranslation & {
  14. /**
  15. * Whether or not the reactions feature is enabled.
  16. */
  17. enableReactions: Boolean;
  18. /**
  19. * Whether or not moderator muted the sounds.
  20. */
  21. moderatorMutedSoundsReactions: Boolean;
  22. /**
  23. * Whether or not the sound for the incoming message should play.
  24. */
  25. soundsIncomingMessage: Boolean;
  26. /**
  27. * Whether or not the sound for the participant joined should play.
  28. */
  29. soundsParticipantJoined: Boolean;
  30. /**
  31. * Whether or not the sound for the participant entering the lobby should play.
  32. */
  33. soundsParticipantKnocking: Boolean;
  34. /**
  35. * Whether or not the sound for the participant left should play.
  36. */
  37. soundsParticipantLeft: Boolean;
  38. /**
  39. * Whether or not the sound for reactions should play.
  40. */
  41. soundsReactions: Boolean;
  42. /**
  43. * Whether or not the sound for the talk while muted notification should play.
  44. */
  45. soundsTalkWhileMuted: Boolean;
  46. /**
  47. * Invoked to obtain translated strings.
  48. */
  49. t: Function;
  50. };
  51. /**
  52. * React {@code Component} for modifying the local user's sound settings.
  53. *
  54. * @augments Component
  55. */
  56. class SoundsTab extends AbstractDialogTab<Props> {
  57. /**
  58. * Initializes a new {@code SoundsTab} instance.
  59. *
  60. * @param {Props} props - The React {@code Component} props to initialize
  61. * the new {@code SoundsTab} instance with.
  62. */
  63. constructor(props: Props) {
  64. super(props);
  65. // Bind event handlers so they are only bound once for every instance.
  66. this._onChange = this._onChange.bind(this);
  67. }
  68. /**
  69. * Changes a sound setting state.
  70. *
  71. * @param {Object} e - The key event to handle.
  72. *
  73. * @returns {void}
  74. */
  75. _onChange({ target }: React.ChangeEvent<HTMLInputElement>) {
  76. super._onChange({ [target.name]: target.checked });
  77. }
  78. /**
  79. * Implements React's {@link Component#render()}.
  80. *
  81. * @inheritdoc
  82. * @returns {ReactElement}
  83. */
  84. render() {
  85. const {
  86. disabledSounds,
  87. soundsIncomingMessage,
  88. soundsParticipantJoined,
  89. soundsParticipantKnocking,
  90. soundsParticipantLeft,
  91. soundsTalkWhileMuted,
  92. soundsReactions,
  93. enableReactions,
  94. moderatorMutedSoundsReactions,
  95. t // @ts-ignore
  96. } = this.props;
  97. return (
  98. <div
  99. className = 'settings-sub-pane-element'
  100. key = 'sounds'>
  101. <h2 className = 'mock-atlaskit-label'>
  102. {t('settings.playSounds')}
  103. </h2>
  104. {enableReactions && <Checkbox
  105. checked = { soundsReactions && !disabledSounds.includes('REACTION_SOUND') }
  106. className = 'settings-checkbox'
  107. disabled = { moderatorMutedSoundsReactions || disabledSounds.includes('REACTION_SOUND') }
  108. label = { t('settings.reactions') }
  109. name = 'soundsReactions'
  110. onChange = { this._onChange } />
  111. }
  112. <Checkbox
  113. checked = { soundsIncomingMessage && !disabledSounds.includes('INCOMING_MSG_SOUND') }
  114. className = 'settings-checkbox'
  115. disabled = { disabledSounds.includes('INCOMING_MSG_SOUND') }
  116. label = { t('settings.incomingMessage') }
  117. name = 'soundsIncomingMessage'
  118. onChange = { this._onChange } />
  119. <Checkbox
  120. checked = { soundsParticipantJoined && !disabledSounds.includes('PARTICIPANT_JOINED_SOUND') }
  121. className = 'settings-checkbox'
  122. disabled = { disabledSounds.includes('PARTICIPANT_JOINED_SOUND') }
  123. label = { t('settings.participantJoined') }
  124. name = 'soundsParticipantJoined'
  125. onChange = { this._onChange } />
  126. <Checkbox
  127. checked = { soundsParticipantLeft && !disabledSounds.includes('PARTICIPANT_LEFT_SOUND') }
  128. className = 'settings-checkbox'
  129. disabled = { disabledSounds.includes('PARTICIPANT_LEFT_SOUND') }
  130. label = { t('settings.participantLeft') }
  131. name = 'soundsParticipantLeft'
  132. onChange = { this._onChange } />
  133. <Checkbox
  134. checked = { soundsTalkWhileMuted && !disabledSounds.includes('TALK_WHILE_MUTED_SOUND') }
  135. className = 'settings-checkbox'
  136. disabled = { disabledSounds.includes('TALK_WHILE_MUTED_SOUND') }
  137. label = { t('settings.talkWhileMuted') }
  138. name = 'soundsTalkWhileMuted'
  139. onChange = { this._onChange } />
  140. <Checkbox
  141. checked = { soundsParticipantKnocking && !disabledSounds.includes('KNOCKING_PARTICIPANT_SOUND') }
  142. className = 'settings-checkbox'
  143. disabled = { disabledSounds.includes('KNOCKING_PARTICIPANT_SOUND') }
  144. label = { t('settings.participantKnocking') }
  145. name = 'soundsParticipantKnocking'
  146. onChange = { this._onChange } />
  147. </div>
  148. );
  149. }
  150. }
  151. // @ts-ignore
  152. export default translate(SoundsTab);