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.

ShareAudioDialog.js 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. // @flow
  2. import { Checkbox } from '@atlaskit/checkbox';
  3. import React, { Component } from 'react';
  4. import type { Dispatch } from 'redux';
  5. import { Dialog } from '../../base/dialog';
  6. import { translate } from '../../base/i18n';
  7. import { connect } from '../../base/redux';
  8. import {
  9. updateSettings,
  10. shouldHideShareAudioHelper
  11. } from '../../base/settings';
  12. import { toggleScreensharing } from '../../base/tracks';
  13. /**
  14. * The type of the React {@code Component} props of {@link ShareAudioDialog}.
  15. */
  16. export type Props = {
  17. /**
  18. * The redux {@code dispatch} function.
  19. */
  20. dispatch: Dispatch<any>,
  21. /**
  22. * Boolean stored in local storage that determines whether or not the dialog will be displayed again.
  23. */
  24. _shouldHideShareAudioHelper: boolean,
  25. /**
  26. * Invoked to obtain translated strings.
  27. */
  28. t: Function
  29. };
  30. /**
  31. * Component that displays the audio screen share helper dialog.
  32. */
  33. class ShareAudioDialog extends Component<Props> {
  34. /**
  35. * Instantiates a new component.
  36. *
  37. * @inheritdoc
  38. */
  39. constructor(props) {
  40. super(props);
  41. this._onContinue = this._onContinue.bind(this);
  42. this._onSelectHideShareAudioHelper = this._onSelectHideShareAudioHelper.bind(this);
  43. }
  44. _onContinue: () => boolean;
  45. /**
  46. * Continue the normal screen sharing flow when the user clicks continue.
  47. *
  48. * @returns {boolean}
  49. */
  50. _onContinue() {
  51. // Pass undefined as the first parameter so the underlying logic decides weather or not to stop screen sharing.
  52. this.props.dispatch(toggleScreensharing(undefined, true));
  53. return true;
  54. }
  55. _onSelectHideShareAudioHelper: (Object) => void;
  56. /**
  57. * Callback invoked when the hide audio helper checkbox has been selected. This setting will be persisted in
  58. * the local storage, thus the dialog won't be displayed again.
  59. *
  60. * @param {Object} e - The key event to handle.
  61. * @returns {void}
  62. */
  63. _onSelectHideShareAudioHelper({ target: { checked } }) {
  64. this.props.dispatch(updateSettings({ hideShareAudioHelper: checked }));
  65. }
  66. /**
  67. * Implements {@Component#render}.
  68. *
  69. * @inheritdoc
  70. */
  71. render() {
  72. const { t } = this.props;
  73. return (
  74. <Dialog
  75. hideCancelButton = { false }
  76. okKey = { t('dialog.shareAudio') }
  77. onSubmit = { this._onContinue }
  78. titleKey = { t('dialog.shareAudioTitle') }
  79. width = { 'medium' } >
  80. <div className = 'share-audio-dialog'>
  81. <img
  82. className = 'share-audio-animation'
  83. src = 'images/share-audio.gif' />
  84. <Checkbox
  85. isChecked = { this.props._shouldHideShareAudioHelper }
  86. label = { t('dialog.hideShareAudioHelper') }
  87. name = 'hide-share-audio-helper'
  88. // eslint-disable-next-line react/jsx-no-bind
  89. onChange = { this._onSelectHideShareAudioHelper } />
  90. </div>
  91. </Dialog>
  92. );
  93. }
  94. }
  95. /**
  96. * Maps part of the Redux state to the props of this component.
  97. *
  98. * @param {Object} state - The Redux state.
  99. * @private
  100. * @returns {Props}
  101. */
  102. function _mapStateToProps(state: Object): $Shape<Props> {
  103. return {
  104. _shouldHideShareAudioHelper: shouldHideShareAudioHelper(state)
  105. };
  106. }
  107. export default translate(connect(_mapStateToProps)(ShareAudioDialog));