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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. * Invoked to obtain translated strings.
  31. */
  32. t: Function
  33. }
  34. /**
  35. * React {@code Component} for modifying the local user's sound settings.
  36. *
  37. * @extends Component
  38. */
  39. class SoundsTab extends AbstractDialogTab<Props> {
  40. /**
  41. * Initializes a new {@code SoundsTab} instance.
  42. *
  43. * @param {Props} props - The React {@code Component} props to initialize
  44. * the new {@code SoundsTab} instance with.
  45. */
  46. constructor(props: Props) {
  47. super(props);
  48. // Bind event handlers so they are only bound once for every instance.
  49. this._onChange = this._onChange.bind(this);
  50. }
  51. _onChange: (Object) => void;
  52. /**
  53. * Changes a sound setting state.
  54. *
  55. * @param {Object} e - The key event to handle.
  56. *
  57. * @returns {void}
  58. */
  59. _onChange({ target }) {
  60. super._onChange({ [target.name]: target.checked });
  61. }
  62. /**
  63. * Implements React's {@link Component#render()}.
  64. *
  65. * @inheritdoc
  66. * @returns {ReactElement}
  67. */
  68. render() {
  69. const {
  70. soundsIncomingMessage,
  71. soundsParticipantJoined,
  72. soundsParticipantLeft,
  73. soundsTalkWhileMuted,
  74. t
  75. } = this.props;
  76. return (
  77. <div
  78. className = 'settings-sub-pane-element'
  79. key = 'sounds'>
  80. <h2 className = 'mock-atlaskit-label'>
  81. {t('settings.playSounds')}
  82. </h2>
  83. <Checkbox
  84. isChecked = { soundsIncomingMessage }
  85. label = { t('settings.incomingMessage') }
  86. name = 'soundsIncomingMessage'
  87. onChange = { this._onChange } />
  88. <Checkbox
  89. isChecked = { soundsParticipantJoined }
  90. label = { t('settings.participantJoined') }
  91. name = 'soundsParticipantJoined'
  92. onChange = { this._onChange } />
  93. <Checkbox
  94. isChecked = { soundsParticipantLeft }
  95. label = { t('settings.participantLeft') }
  96. name = 'soundsParticipantLeft'
  97. onChange = { this._onChange } />
  98. <Checkbox
  99. isChecked = { soundsTalkWhileMuted }
  100. label = { t('settings.talkWhileMuted') }
  101. name = 'soundsTalkWhileMuted'
  102. onChange = { this._onChange } />
  103. </div>
  104. );
  105. }
  106. }
  107. export default translate(SoundsTab);