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

LiveStreamButton.web.js 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. // @flow
  2. import React from 'react';
  3. import { connect } from 'react-redux';
  4. import { translate } from '../../../base/i18n';
  5. import { getLocalParticipant } from '../../../base/participants';
  6. import AbstractLiveStreamButton, {
  7. _mapStateToProps as _abstractMapStateToProps,
  8. type Props as AbstractProps
  9. } from './AbstractLiveStreamButton';
  10. declare var interfaceConfig: Object;
  11. type Props = AbstractProps & {
  12. /**
  13. * True if the button should be disabled, false otherwise.
  14. *
  15. * NOTE: On web, if the feature is not disabled on purpose, then we still
  16. * show the button but disabled and with a tooltip rendered on it,
  17. * explaining why it's not available.
  18. */
  19. _disabled: boolean,
  20. /**
  21. * Tooltip for the button when it's disabled in a certain way.
  22. */
  23. _liveStreamDisabledTooltipKey: ?string
  24. }
  25. /**
  26. * An implementation of a button for starting and stopping live streaming.
  27. */
  28. class LiveStreamButton extends AbstractLiveStreamButton<Props> {
  29. iconName = 'icon-public';
  30. toggledIconName = 'icon-public';
  31. /**
  32. * Constructor of the component.
  33. *
  34. * @inheritdoc
  35. */
  36. constructor(props: Props) {
  37. super(props);
  38. this.tooltip = props._liveStreamDisabledTooltipKey;
  39. }
  40. /**
  41. * Implements {@code Component}'s componentWillReceiveProps.
  42. *
  43. * @inheritdoc
  44. */
  45. componentWillReceiveProps(newProps: Props) {
  46. this.tooltip = newProps._liveStreamDisabledTooltipKey;
  47. }
  48. /**
  49. * Helper function to be implemented by subclasses, which returns
  50. * a React Element to display (a beta tag) at the end of the button.
  51. *
  52. * @override
  53. * @protected
  54. * @returns {boolean}
  55. */
  56. _getElementAfter() {
  57. return (
  58. <span className = 'beta-tag'>
  59. { this.props.t('recording.beta') }
  60. </span>
  61. );
  62. }
  63. /**
  64. * Helper function to be implemented by subclasses, which must return a
  65. * boolean value indicating if this button is disabled or not.
  66. *
  67. * @override
  68. * @protected
  69. * @returns {boolean}
  70. */
  71. _isDisabled() {
  72. return this.props._disabled;
  73. }
  74. }
  75. /**
  76. * Maps (parts of) the redux state to the associated props for the
  77. * {@code LiveStreamButton} component.
  78. *
  79. * @param {Object} state - The Redux state.
  80. * @param {Props} ownProps - The own props of the Component.
  81. * @private
  82. * @returns {{
  83. * _conference: Object,
  84. * _isLiveStreamRunning: boolean,
  85. * _disabled: boolean,
  86. * visible: boolean
  87. * }}
  88. */
  89. function _mapStateToProps(state: Object, ownProps: Props) {
  90. const abstractProps = _abstractMapStateToProps(state, ownProps);
  91. const localParticipant = getLocalParticipant(state);
  92. const { features = {} } = localParticipant;
  93. let { visible } = ownProps;
  94. let _disabled = false;
  95. let _liveStreamDisabledTooltipKey;
  96. if (!abstractProps.visible
  97. && String(features.livestreaming) !== 'disabled') {
  98. _disabled = true;
  99. // button and tooltip
  100. if (state['features/base/jwt'].isGuest) {
  101. _liveStreamDisabledTooltipKey
  102. = 'dialog.liveStreamingDisabledForGuestTooltip';
  103. } else {
  104. _liveStreamDisabledTooltipKey
  105. = 'dialog.liveStreamingDisabledTooltip';
  106. }
  107. }
  108. if (typeof visible === 'undefined') {
  109. visible = interfaceConfig.TOOLBAR_BUTTONS.includes('livestreaming')
  110. && (abstractProps.visible || _liveStreamDisabledTooltipKey);
  111. }
  112. return {
  113. ...abstractProps,
  114. _disabled,
  115. _liveStreamDisabledTooltipKey,
  116. visible
  117. };
  118. }
  119. export default translate(connect(_mapStateToProps)(LiveStreamButton));