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.

SoundsTab.js 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. // @flow
  2. import Checkbox from '@atlaskit/checkbox';
  3. import React from 'react';
  4. import { AbstractDialogTab } from '../../../base/dialog';
  5. import type { Props as AbstractDialogTabProps } from '../../../base/dialog';
  6. import { translate } from '../../../base/i18n';
  7. declare var APP: Object;
  8. /**
  9. * The type of the React {@code Component} props of {@link SoundsTab}.
  10. */
  11. export type Props = {
  12. ...$Exact<AbstractDialogTabProps>,
  13. /**
  14. * Whether or not the sound for the incoming message should play.
  15. */
  16. soundsIncomingMessage: Boolean,
  17. /**
  18. * Whether or not the sound for the participant joined should play.
  19. */
  20. soundsParticipantJoined: Boolean,
  21. /**
  22. * Whether or not the sound for the participant left should play.
  23. */
  24. soundsParticipantLeft: Boolean,
  25. /**
  26. * Whether or not the sound for the talk while muted notification should play.
  27. */
  28. soundsTalkWhileMuted: Boolean,
  29. /**
  30. * Whether or not the sound for reactions should play.
  31. */
  32. soundsReactions: Boolean,
  33. /**
  34. * Whether or not the reactions feature is enabled.
  35. */
  36. enableReactions: Boolean,
  37. /**
  38. * Invoked to obtain translated strings.
  39. */
  40. t: Function
  41. }
  42. /**
  43. * React {@code Component} for modifying the local user's sound settings.
  44. *
  45. * @extends Component
  46. */
  47. class SoundsTab extends AbstractDialogTab<Props> {
  48. /**
  49. * Initializes a new {@code SoundsTab} instance.
  50. *
  51. * @param {Props} props - The React {@code Component} props to initialize
  52. * the new {@code SoundsTab} instance with.
  53. */
  54. constructor(props: Props) {
  55. super(props);
  56. // Bind event handlers so they are only bound once for every instance.
  57. this._onChange = this._onChange.bind(this);
  58. }
  59. _onChange: (Object) => void;
  60. /**
  61. * Changes a sound setting state.
  62. *
  63. * @param {Object} e - The key event to handle.
  64. *
  65. * @returns {void}
  66. */
  67. _onChange({ target }) {
  68. super._onChange({ [target.name]: target.checked });
  69. }
  70. /**
  71. * Implements React's {@link Component#render()}.
  72. *
  73. * @inheritdoc
  74. * @returns {ReactElement}
  75. */
  76. render() {
  77. const {
  78. soundsIncomingMessage,
  79. soundsParticipantJoined,
  80. soundsParticipantLeft,
  81. soundsTalkWhileMuted,
  82. soundsReactions,
  83. enableReactions,
  84. t
  85. } = this.props;
  86. return (
  87. <div
  88. className = 'settings-sub-pane-element'
  89. key = 'sounds'>
  90. <h2 className = 'mock-atlaskit-label'>
  91. {t('settings.playSounds')}
  92. </h2>
  93. {enableReactions && <Checkbox
  94. isChecked = { soundsReactions }
  95. label = { t('settings.reactions') }
  96. name = 'soundsReactions'
  97. onChange = { this._onChange } />
  98. }
  99. <Checkbox
  100. isChecked = { soundsIncomingMessage }
  101. label = { t('settings.incomingMessage') }
  102. name = 'soundsIncomingMessage'
  103. onChange = { this._onChange } />
  104. <Checkbox
  105. isChecked = { soundsParticipantJoined }
  106. label = { t('settings.participantJoined') }
  107. name = 'soundsParticipantJoined'
  108. onChange = { this._onChange } />
  109. <Checkbox
  110. isChecked = { soundsParticipantLeft }
  111. label = { t('settings.participantLeft') }
  112. name = 'soundsParticipantLeft'
  113. onChange = { this._onChange } />
  114. <Checkbox
  115. isChecked = { soundsTalkWhileMuted }
  116. label = { t('settings.talkWhileMuted') }
  117. name = 'soundsTalkWhileMuted'
  118. onChange = { this._onChange } />
  119. </div>
  120. );
  121. }
  122. }
  123. export default translate(SoundsTab);