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.

RecordingLabel.web.js 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. import PropTypes from 'prop-types';
  2. import React, { Component } from 'react';
  3. import { connect } from 'react-redux';
  4. import { translate } from '../../base/i18n';
  5. /**
  6. * Implements a React {@link Component} which displays the current state of
  7. * conference recording. Currently it uses CSS to display itself automatically
  8. * when there is a recording state update.
  9. *
  10. * @extends {Component}
  11. */
  12. class RecordingLabel extends Component {
  13. /**
  14. * {@code RecordingLabel} component's property types.
  15. *
  16. * @static
  17. */
  18. static propTypes = {
  19. /**
  20. * Whether or not the filmstrip is currently visible or toggled to
  21. * hidden. Depending on the filmstrip state, different CSS classes will
  22. * be set to allow for adjusting of {@code RecordingLabel} positioning.
  23. */
  24. _filmstripVisible: PropTypes.bool,
  25. /**
  26. * An object to describe the {@code RecordingLabel} content. If no
  27. * translation key to display is specified, the label will apply CSS to
  28. * itself so it can be made invisible.
  29. * {{
  30. * centered: boolean,
  31. * key: string,
  32. * showSpinner: boolean
  33. * }}
  34. */
  35. _labelDisplayConfiguration: PropTypes.object,
  36. /**
  37. * Invoked to obtain translated string.
  38. */
  39. t: PropTypes.func
  40. };
  41. /**
  42. * Initializes a new {@code RecordingLabel} instance.
  43. *
  44. * @param {Object} props - The read-only properties with which the new
  45. * instance is to be initialized.
  46. */
  47. constructor(props) {
  48. super(props);
  49. this.state = {
  50. /**
  51. * Whether or not the filmstrip was not visible but has transitioned
  52. * in the latest component update to visible. This boolean is used
  53. * to set a class for position animations.
  54. *
  55. * @type {boolean}
  56. */
  57. filmstripBecomingVisible: false
  58. };
  59. }
  60. /**
  61. * Updates the state for whether or not the filmstrip is being toggled to
  62. * display after having being hidden.
  63. *
  64. * @inheritdoc
  65. * @param {Object} nextProps - The read-only props which this Component will
  66. * receive.
  67. * @returns {void}
  68. */
  69. componentWillReceiveProps(nextProps) {
  70. this.setState({
  71. filmstripBecomingVisible: nextProps._filmstripVisible
  72. && !this.props._filmstripVisible
  73. });
  74. }
  75. /**
  76. * Implements React's {@link Component#render()}.
  77. *
  78. * @inheritdoc
  79. * @returns {ReactElement}
  80. */
  81. render() {
  82. const { _labelDisplayConfiguration } = this.props;
  83. const { centered, key, showSpinner } = _labelDisplayConfiguration || {};
  84. const isVisible = Boolean(key);
  85. const rootClassName = [
  86. 'video-state-indicator centeredVideoLabel',
  87. isVisible ? 'show-inline' : '',
  88. centered ? '' : 'moveToCorner',
  89. this.state.filmstripBecomingVisible ? 'opening' : '',
  90. this.props._filmstripVisible
  91. ? 'with-filmstrip' : 'without-filmstrip'
  92. ].join(' ');
  93. return (
  94. <span
  95. className = { rootClassName }
  96. id = 'recordingLabel'>
  97. <span id = 'recordingLabelText'>
  98. { this.props.t(key) }
  99. </span>
  100. { showSpinner
  101. ? <img
  102. className = 'recordingSpinner'
  103. id = 'recordingSpinner'
  104. src = 'images/spin.svg' />
  105. : null }
  106. </span>
  107. );
  108. }
  109. }
  110. /**
  111. * Maps (parts of) the Redux state to the associated {@code RecordingLabel}
  112. * component's props.
  113. *
  114. * @param {Object} state - The Redux state.
  115. * @private
  116. * @returns {{
  117. * _filmstripVisible: boolean,
  118. * _labelDisplayConfiguration: Object
  119. * }}
  120. */
  121. function _mapStateToProps(state) {
  122. const { visible } = state['features/filmstrip'];
  123. const { labelDisplayConfiguration } = state['features/recording'];
  124. return {
  125. /**
  126. * Whether or not the filmstrip is currently set to be displayed.
  127. *
  128. * @type {boolean}
  129. */
  130. _filmstripVisible: visible,
  131. /**
  132. * An object describing how {@code RecordingLabel} should display its
  133. * contents.
  134. *
  135. * @type {Object}
  136. */
  137. _labelDisplayConfiguration: labelDisplayConfiguration
  138. };
  139. }
  140. export default translate(connect(_mapStateToProps)(RecordingLabel));