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.

PreMeetingScreen.js 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. // @flow
  2. import { withStyles } from '@material-ui/styles';
  3. import React, { PureComponent } from 'react';
  4. import { connect } from '../../../../base/redux';
  5. import DeviceStatus from '../../../../prejoin/components/preview/DeviceStatus';
  6. import { Toolbox } from '../../../../toolbox/components/web';
  7. import { getConferenceName } from '../../../conference/functions';
  8. import { PREMEETING_BUTTONS, THIRD_PARTY_PREJOIN_BUTTONS } from '../../../config/constants';
  9. import { getToolbarButtons, isToolbarButtonEnabled } from '../../../config/functions.web';
  10. import { withPixelLineHeight } from '../../../styles/functions.web';
  11. import ConnectionStatus from './ConnectionStatus';
  12. import Preview from './Preview';
  13. type Props = {
  14. /**
  15. * The list of toolbar buttons to render.
  16. */
  17. _buttons: Array<string>,
  18. /**
  19. * The branding background of the premeeting screen(lobby/prejoin).
  20. */
  21. _premeetingBackground: string,
  22. /**
  23. * The name of the meeting that is about to be joined.
  24. */
  25. _roomName: string,
  26. /**
  27. * Children component(s) to be rendered on the screen.
  28. */
  29. children?: React$Node,
  30. /**
  31. * Classes prop injected by withStyles.
  32. */
  33. classes: Object,
  34. /**
  35. * Additional CSS class names to set on the icon container.
  36. */
  37. className?: string,
  38. /**
  39. * The name of the participant.
  40. */
  41. name?: string,
  42. /**
  43. * Indicates whether the copy url button should be shown.
  44. */
  45. showCopyUrlButton: boolean,
  46. /**
  47. * Indicates whether the device status should be shown.
  48. */
  49. showDeviceStatus: boolean,
  50. /**
  51. * The 'Skip prejoin' button to be rendered (if any).
  52. */
  53. skipPrejoinButton?: React$Node,
  54. /**
  55. * Title of the screen.
  56. */
  57. title?: string,
  58. /**
  59. * Whether it's used in the 3rdParty prejoin screen or not.
  60. */
  61. thirdParty?: boolean,
  62. /**
  63. * True if the preview overlay should be muted, false otherwise.
  64. */
  65. videoMuted?: boolean,
  66. /**
  67. * The video track to render as preview (if omitted, the default local track will be rendered).
  68. */
  69. videoTrack?: Object
  70. }
  71. /**
  72. * Creates the styles for the component.
  73. *
  74. * @param {Object} theme - The current UI theme.
  75. *
  76. * @returns {Object}
  77. */
  78. const styles = theme => {
  79. return {
  80. subtitle: {
  81. ...withPixelLineHeight(theme.typography.heading5),
  82. color: theme.palette.text01,
  83. marginBottom: theme.spacing(4),
  84. overflow: 'hidden',
  85. textAlign: 'center',
  86. textOverflow: 'ellipsis',
  87. whiteSpace: 'nowrap',
  88. width: '100%'
  89. }
  90. };
  91. };
  92. /**
  93. * Implements a pre-meeting screen that can be used at various pre-meeting phases, for example
  94. * on the prejoin screen (pre-connection) or lobby (post-connection).
  95. */
  96. class PreMeetingScreen extends PureComponent<Props> {
  97. /**
  98. * Default values for {@code Prejoin} component's properties.
  99. *
  100. * @static
  101. */
  102. static defaultProps = {
  103. showCopyUrlButton: true,
  104. showToolbox: true
  105. };
  106. /**
  107. * Implements {@code PureComponent#render}.
  108. *
  109. * @inheritdoc
  110. */
  111. render() {
  112. const {
  113. _buttons,
  114. _premeetingBackground,
  115. _roomName,
  116. children,
  117. classes,
  118. className,
  119. showDeviceStatus,
  120. skipPrejoinButton,
  121. title,
  122. videoMuted,
  123. videoTrack
  124. } = this.props;
  125. const containerClassName = `premeeting-screen ${className ? className : ''}`;
  126. const style = _premeetingBackground ? {
  127. background: _premeetingBackground,
  128. backgroundPosition: 'center',
  129. backgroundSize: 'cover'
  130. } : {};
  131. return (
  132. <div className = { containerClassName }>
  133. <div style = { style }>
  134. <div className = 'content'>
  135. <ConnectionStatus />
  136. <div className = 'content-controls'>
  137. <h1 className = 'title'>
  138. { title }
  139. </h1>
  140. { _roomName && (
  141. <span className = { classes.subtitle }>
  142. {_roomName}
  143. </span>
  144. )}
  145. { children }
  146. { _buttons.length && <Toolbox toolbarButtons = { _buttons } /> }
  147. { skipPrejoinButton }
  148. { showDeviceStatus && <DeviceStatus /> }
  149. </div>
  150. </div>
  151. </div>
  152. <Preview
  153. videoMuted = { videoMuted }
  154. videoTrack = { videoTrack } />
  155. </div>
  156. );
  157. }
  158. }
  159. /**
  160. * Maps (parts of) the redux state to the React {@code Component} props.
  161. *
  162. * @param {Object} state - The redux state.
  163. * @param {Object} ownProps - The props passed to the component.
  164. * @returns {Object}
  165. */
  166. function mapStateToProps(state, ownProps): Object {
  167. const { hiddenPremeetingButtons, hideConferenceSubject } = state['features/base/config'];
  168. const toolbarButtons = getToolbarButtons(state);
  169. const premeetingButtons = (ownProps.thirdParty
  170. ? THIRD_PARTY_PREJOIN_BUTTONS
  171. : PREMEETING_BUTTONS).filter(b => !(hiddenPremeetingButtons || []).includes(b));
  172. const { premeetingBackground } = state['features/dynamic-branding'];
  173. return {
  174. // For keeping backwards compat.: if we pass an empty hiddenPremeetingButtons
  175. // array through external api, we have all prejoin buttons present on premeeting
  176. // screen regardless of passed values into toolbarButtons config overwrite.
  177. // If hiddenPremeetingButtons is missing, we hide the buttons according to
  178. // toolbarButtons config overwrite.
  179. _buttons: hiddenPremeetingButtons
  180. ? premeetingButtons
  181. : premeetingButtons.filter(b => isToolbarButtonEnabled(b, toolbarButtons)),
  182. _premeetingBackground: premeetingBackground,
  183. _roomName: hideConferenceSubject ? undefined : getConferenceName(state)
  184. };
  185. }
  186. export default connect(mapStateToProps)(withStyles(styles)(PreMeetingScreen));