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.

SharedVideoButton.js 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // @flow
  2. import type { Dispatch } from 'redux';
  3. import { translate } from '../../../base/i18n';
  4. import { IconShareVideo } from '../../../base/icons';
  5. import { connect } from '../../../base/redux';
  6. import {
  7. AbstractButton,
  8. type AbstractButtonProps
  9. } from '../../../base/toolbox/components';
  10. import { toggleSharedVideo } from '../../actions.any';
  11. import { isSharingStatus } from '../../functions';
  12. type Props = AbstractButtonProps & {
  13. /**
  14. * The redux {@code dispatch} function.
  15. */
  16. dispatch: Dispatch<any>,
  17. /**
  18. * Whether or not the button is disabled.
  19. */
  20. _isDisabled: boolean,
  21. /**
  22. * Whether or not the local participant is sharing a video.
  23. */
  24. _sharingVideo: boolean
  25. };
  26. /**
  27. * Implements an {@link AbstractButton} to open the user documentation in a new window.
  28. */
  29. class SharedVideoButton extends AbstractButton<Props, *> {
  30. accessibilityLabel = 'toolbar.accessibilityLabel.sharedvideo';
  31. icon = IconShareVideo;
  32. label = 'toolbar.sharedvideo';
  33. toggledLabel = 'toolbar.stopSharedVideo';
  34. /**
  35. * Dynamically retrieves tooltip based on sharing state.
  36. */
  37. get tooltip() {
  38. if (this._isToggled()) {
  39. return 'toolbar.stopSharedVideo';
  40. }
  41. return 'toolbar.sharedvideo';
  42. }
  43. /**
  44. * Required by linter due to AbstractButton overwritten prop being writable.
  45. *
  46. * @param {string} value - The value.
  47. */
  48. set tooltip(value) {
  49. return value;
  50. }
  51. /**
  52. * Handles clicking / pressing the button, and opens a new dialog.
  53. *
  54. * @private
  55. * @returns {void}
  56. */
  57. _handleClick() {
  58. this._doToggleSharedVideo();
  59. }
  60. /**
  61. * Indicates whether this button is in toggled state or not.
  62. *
  63. * @override
  64. * @protected
  65. * @returns {boolean}
  66. */
  67. _isToggled() {
  68. return this.props._sharingVideo;
  69. }
  70. /**
  71. * Indicates whether this button is disabled or not.
  72. *
  73. * @override
  74. * @protected
  75. * @returns {boolean}
  76. */
  77. _isDisabled() {
  78. return this.props._isDisabled;
  79. }
  80. /**
  81. * Dispatches an action to toggle video sharing.
  82. *
  83. * @private
  84. * @returns {void}
  85. */
  86. _doToggleSharedVideo() {
  87. this.props.dispatch(toggleSharedVideo());
  88. }
  89. }
  90. /**
  91. * Maps part of the Redux state to the props of this component.
  92. *
  93. * @param {Object} state - The Redux state.
  94. * @private
  95. * @returns {Props}
  96. */
  97. function _mapStateToProps(state): Object {
  98. const {
  99. disabled: sharedVideoBtnDisabled,
  100. status: sharedVideoStatus
  101. } = state['features/shared-video'];
  102. return {
  103. _isDisabled: sharedVideoBtnDisabled,
  104. _sharingVideo: isSharingStatus(sharedVideoStatus)
  105. };
  106. }
  107. export default translate(connect(_mapStateToProps)(SharedVideoButton));