Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

ShareDesktopButton.js 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // @flow
  2. import { translate } from '../../../base/i18n';
  3. import { IconScreenshare, IconStopScreenshare } from '../../../base/icons';
  4. import JitsiMeetJS from '../../../base/lib-jitsi-meet/_';
  5. import { connect } from '../../../base/redux';
  6. import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
  7. import { isScreenVideoShared } from '../../../screen-share/functions';
  8. import { isDesktopShareButtonDisabled } from '../../functions';
  9. type Props = AbstractButtonProps & {
  10. /**
  11. * Whether or not screensharing is initialized.
  12. */
  13. _desktopSharingEnabled: boolean,
  14. /**
  15. * Whether or not the local participant is screensharing.
  16. */
  17. _screensharing: boolean,
  18. /**
  19. * The redux {@code dispatch} function.
  20. */
  21. dispatch: Function,
  22. };
  23. /**
  24. * Implementation of a button for sharing desktop / windows.
  25. */
  26. class ShareDesktopButton extends AbstractButton<Props, *> {
  27. accessibilityLabel = 'toolbar.accessibilityLabel.shareYourScreen';
  28. toggledAccessibilityLabel = 'toolbar.accessibilityLabel.stopScreenSharing';
  29. label = 'toolbar.startScreenSharing';
  30. icon = IconScreenshare;
  31. toggledIcon = IconStopScreenshare;
  32. toggledLabel = 'toolbar.stopScreenSharing';
  33. /**
  34. * Retrieves tooltip dynamically.
  35. */
  36. get tooltip() {
  37. const { _desktopSharingEnabled, _screensharing } = this.props;
  38. if (_desktopSharingEnabled) {
  39. if (_screensharing) {
  40. return 'toolbar.stopScreenSharing';
  41. }
  42. return 'toolbar.startScreenSharing';
  43. }
  44. return 'dialog.shareYourScreenDisabled';
  45. }
  46. /**
  47. * Required by linter due to AbstractButton overwritten prop being writable.
  48. *
  49. * @param {string} _value - The icon value.
  50. */
  51. set tooltip(_value) {
  52. // Unused.
  53. }
  54. /**
  55. * Indicates whether this button is in toggled state or not.
  56. *
  57. * @override
  58. * @protected
  59. * @returns {boolean}
  60. */
  61. _isToggled() {
  62. return this.props._screensharing;
  63. }
  64. /**
  65. * Indicates whether this button is in disabled state or not.
  66. *
  67. * @override
  68. * @protected
  69. * @returns {boolean}
  70. */
  71. _isDisabled() {
  72. return !this.props._desktopSharingEnabled;
  73. }
  74. }
  75. /**
  76. * Function that maps parts of Redux state tree into component props.
  77. *
  78. * @param {Object} state - Redux state.
  79. * @returns {Object}
  80. */
  81. const mapStateToProps = state => {
  82. // Disable the screenshare button if the video sender limit is reached and there is no video or media share in
  83. // progress.
  84. const desktopSharingEnabled
  85. = JitsiMeetJS.isDesktopSharingEnabled() && !isDesktopShareButtonDisabled(state);
  86. return {
  87. _desktopSharingEnabled: desktopSharingEnabled,
  88. _screensharing: isScreenVideoShared(state)
  89. };
  90. };
  91. export default translate(connect(mapStateToProps)(ShareDesktopButton));