您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

SharedVideoButton.js 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. tooltip = 'toolbar.sharedvideo';
  34. toggledLabel = 'toolbar.stopSharedVideo';
  35. /**
  36. * Handles clicking / pressing the button, and opens a new dialog.
  37. *
  38. * @private
  39. * @returns {void}
  40. */
  41. _handleClick() {
  42. this._doToggleSharedVideo();
  43. }
  44. /**
  45. * Indicates whether this button is in toggled state or not.
  46. *
  47. * @override
  48. * @protected
  49. * @returns {boolean}
  50. */
  51. _isToggled() {
  52. return this.props._sharingVideo;
  53. }
  54. /**
  55. * Indicates whether this button is disabled or not.
  56. *
  57. * @override
  58. * @protected
  59. * @returns {boolean}
  60. */
  61. _isDisabled() {
  62. return this.props._isDisabled;
  63. }
  64. /**
  65. * Dispatches an action to toggle video sharing.
  66. *
  67. * @private
  68. * @returns {void}
  69. */
  70. _doToggleSharedVideo() {
  71. this.props.dispatch(toggleSharedVideo());
  72. }
  73. }
  74. /**
  75. * Maps part of the Redux state to the props of this component.
  76. *
  77. * @param {Object} state - The Redux state.
  78. * @private
  79. * @returns {Props}
  80. */
  81. function _mapStateToProps(state): Object {
  82. const {
  83. disabled: sharedVideoBtnDisabled,
  84. status: sharedVideoStatus
  85. } = state['features/shared-video'];
  86. return {
  87. _isDisabled: sharedVideoBtnDisabled,
  88. _sharingVideo: isSharingStatus(sharedVideoStatus)
  89. };
  90. }
  91. export default translate(connect(_mapStateToProps)(SharedVideoButton));