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

ConferenceInfo.js 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. // @flow
  2. /* eslint-disable react/no-multi-comp */
  3. import React, { Component } from 'react';
  4. import { JitsiRecordingConstants } from '../../../base/lib-jitsi-meet';
  5. import { connect } from '../../../base/redux';
  6. import E2EELabel from '../../../e2ee/components/E2EELabel';
  7. import HighlightButton from '../../../recording/components/Recording/web/HighlightButton';
  8. import RecordingLabel from '../../../recording/components/web/RecordingLabel';
  9. import { showToolbox } from '../../../toolbox/actions';
  10. import { isToolboxVisible } from '../../../toolbox/functions.web';
  11. import TranscribingLabel from '../../../transcribing/components/TranscribingLabel.web';
  12. import VideoQualityLabel from '../../../video-quality/components/VideoQualityLabel.web';
  13. import VisitorsCountLabel from '../../../visitors/components/web/VisitorsCountLabel';
  14. import ConferenceTimer from '../ConferenceTimer';
  15. import { getConferenceInfo } from '../functions';
  16. import ConferenceInfoContainer from './ConferenceInfoContainer';
  17. import InsecureRoomNameLabel from './InsecureRoomNameLabel';
  18. import RaisedHandsCountLabel from './RaisedHandsCountLabel';
  19. import SpeakerStatsLabel from './SpeakerStatsLabel';
  20. import SubjectText from './SubjectText';
  21. import ToggleTopPanelLabel from './ToggleTopPanelLabel';
  22. /**
  23. * The type of the React {@code Component} props of {@link Subject}.
  24. */
  25. type Props = {
  26. /**
  27. * The conference info labels to be shown in the conference header.
  28. */
  29. _conferenceInfo: Object,
  30. /**
  31. * Invoked to active other features of the app.
  32. */
  33. dispatch: Function;
  34. /**
  35. * Indicates whether the component should be visible or not.
  36. */
  37. _visible: boolean
  38. };
  39. const COMPONENTS = [
  40. {
  41. Component: HighlightButton,
  42. id: 'highlight-moment'
  43. },
  44. {
  45. Component: SubjectText,
  46. id: 'subject'
  47. },
  48. {
  49. Component: ConferenceTimer,
  50. id: 'conference-timer'
  51. },
  52. {
  53. Component: SpeakerStatsLabel,
  54. id: 'participants-count'
  55. },
  56. {
  57. Component: E2EELabel,
  58. id: 'e2ee'
  59. },
  60. {
  61. Component: () => (
  62. <>
  63. <RecordingLabel mode = { JitsiRecordingConstants.mode.FILE } />
  64. <RecordingLabel mode = { JitsiRecordingConstants.mode.STREAM } />
  65. </>
  66. ),
  67. id: 'recording'
  68. },
  69. {
  70. Component: RaisedHandsCountLabel,
  71. id: 'raised-hands-count'
  72. },
  73. {
  74. Component: TranscribingLabel,
  75. id: 'transcribing'
  76. },
  77. {
  78. Component: VideoQualityLabel,
  79. id: 'video-quality'
  80. },
  81. {
  82. Component: VisitorsCountLabel,
  83. id: 'visitors-count'
  84. },
  85. {
  86. Component: InsecureRoomNameLabel,
  87. id: 'insecure-room'
  88. },
  89. {
  90. Component: ToggleTopPanelLabel,
  91. id: 'top-panel-toggle'
  92. }
  93. ];
  94. /**
  95. * The upper band of the meeing containing the conference name, timer and labels.
  96. *
  97. * @param {Object} props - The props of the component.
  98. * @returns {React$None}
  99. */
  100. class ConferenceInfo extends Component<Props> {
  101. /**
  102. * Initializes a new {@code ConferenceInfo} instance.
  103. *
  104. * @param {Props} props - The read-only React {@code Component} props with
  105. * which the new instance is to be initialized.
  106. */
  107. constructor(props: Props) {
  108. super(props);
  109. this._renderAutoHide = this._renderAutoHide.bind(this);
  110. this._renderAlwaysVisible = this._renderAlwaysVisible.bind(this);
  111. this._onTabIn = this._onTabIn.bind(this);
  112. }
  113. _onTabIn: () => void;
  114. /**
  115. * Callback invoked when the component is focused to show the conference
  116. * info if necessary.
  117. *
  118. * @returns {void}
  119. */
  120. _onTabIn() {
  121. if (this.props._conferenceInfo.autoHide?.length && !this.props._visible) {
  122. this.props.dispatch(showToolbox());
  123. }
  124. }
  125. _renderAutoHide: () => void;
  126. /**
  127. * Renders auto-hidden info header labels.
  128. *
  129. * @returns {void}
  130. */
  131. _renderAutoHide() {
  132. const { autoHide } = this.props._conferenceInfo;
  133. if (!autoHide || !autoHide.length) {
  134. return null;
  135. }
  136. return (
  137. <ConferenceInfoContainer
  138. id = 'autoHide'
  139. visible = { this.props._visible }>
  140. {
  141. COMPONENTS
  142. .filter(comp => autoHide.includes(comp.id))
  143. .map(c =>
  144. <c.Component key = { c.id } />
  145. )
  146. }
  147. </ConferenceInfoContainer>
  148. );
  149. }
  150. _renderAlwaysVisible: () => void;
  151. /**
  152. * Renders the always visible info header labels.
  153. *
  154. * @returns {void}
  155. */
  156. _renderAlwaysVisible() {
  157. const { alwaysVisible } = this.props._conferenceInfo;
  158. if (!alwaysVisible || !alwaysVisible.length) {
  159. return null;
  160. }
  161. return (
  162. <ConferenceInfoContainer
  163. id = 'alwaysVisible'
  164. visible = { true } >
  165. {
  166. COMPONENTS
  167. .filter(comp => alwaysVisible.includes(comp.id))
  168. .map(c =>
  169. <c.Component key = { c.id } />
  170. )
  171. }
  172. </ConferenceInfoContainer>
  173. );
  174. }
  175. /**
  176. * Implements React's {@link Component#render()}.
  177. *
  178. * @inheritdoc
  179. * @returns {ReactElement}
  180. */
  181. render() {
  182. return (
  183. <div
  184. className = 'details-container'
  185. onFocus = { this._onTabIn }>
  186. { this._renderAlwaysVisible() }
  187. { this._renderAutoHide() }
  188. </div>
  189. );
  190. }
  191. }
  192. /**
  193. * Maps (parts of) the Redux state to the associated
  194. * {@code Subject}'s props.
  195. *
  196. * @param {Object} state - The Redux state.
  197. * @private
  198. * @returns {{
  199. * _visible: boolean,
  200. * _conferenceInfo: Object
  201. * }}
  202. */
  203. function _mapStateToProps(state) {
  204. return {
  205. _visible: isToolboxVisible(state),
  206. _conferenceInfo: getConferenceInfo(state)
  207. };
  208. }
  209. export default connect(_mapStateToProps)(ConferenceInfo);