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.

LobbyScreen.js 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. // @flow
  2. import React from 'react';
  3. import { translate } from '../../../base/i18n';
  4. import { ActionButton, InputField, PreMeetingScreen } from '../../../base/premeeting';
  5. import { LoadingIndicator } from '../../../base/react';
  6. import { connect } from '../../../base/redux';
  7. import AbstractLobbyScreen, {
  8. _mapStateToProps
  9. } from '../AbstractLobbyScreen';
  10. /**
  11. * Implements a waiting screen that represents the participant being in the lobby.
  12. */
  13. class LobbyScreen extends AbstractLobbyScreen {
  14. /**
  15. * Implements {@code PureComponent#render}.
  16. *
  17. * @inheritdoc
  18. */
  19. render() {
  20. const { _deviceStatusVisible, showCopyUrlButton, t } = this.props;
  21. return (
  22. <PreMeetingScreen
  23. className = 'lobby-screen'
  24. showCopyUrlButton = { showCopyUrlButton }
  25. showDeviceStatus = { _deviceStatusVisible }
  26. title = { t(this._getScreenTitleKey()) }>
  27. { this._renderContent() }
  28. </PreMeetingScreen>
  29. );
  30. }
  31. _getScreenTitleKey: () => string;
  32. _onAskToJoin: () => boolean;
  33. _onCancel: () => boolean;
  34. _onChangeDisplayName: Object => void;
  35. _onChangeEmail: Object => void;
  36. _onChangePassword: Object => void;
  37. _onEnableEdit: () => void;
  38. _onJoinWithPassword: () => void;
  39. _onSubmit: () => boolean;
  40. _onSwitchToKnockMode: () => void;
  41. _onSwitchToPasswordMode: () => void;
  42. _renderContent: () => React$Element<*>;
  43. /**
  44. * Renders the joining (waiting) fragment of the screen.
  45. *
  46. * @inheritdoc
  47. */
  48. _renderJoining() {
  49. return (
  50. <div className = 'lobby-screen-content'>
  51. <div className = 'spinner'>
  52. <LoadingIndicator size = 'large' />
  53. </div>
  54. <span className = 'joining-message'>
  55. { this.props.t('lobby.joiningMessage') }
  56. </span>
  57. { this._renderStandardButtons() }
  58. </div>
  59. );
  60. }
  61. /**
  62. * Renders the participant form to let the knocking participant enter its details.
  63. *
  64. * NOTE: We don't use edit action on web since the prejoin functionality got merged.
  65. * Mobile won't use it either once prejoin gets implemented there too.
  66. *
  67. * @inheritdoc
  68. */
  69. _renderParticipantForm() {
  70. return this._renderParticipantInfo();
  71. }
  72. /**
  73. * Renders the participant info fragment when we have all the required details of the user.
  74. *
  75. * @inheritdoc
  76. */
  77. _renderParticipantInfo() {
  78. const { displayName } = this.state;
  79. const { t } = this.props;
  80. return (
  81. <InputField
  82. onChange = { this._onChangeDisplayName }
  83. placeHolder = { t('lobby.nameField') }
  84. testId = 'lobby.nameField'
  85. value = { displayName } />
  86. );
  87. }
  88. /**
  89. * Renders the password form to let the participant join by using a password instead of knocking.
  90. *
  91. * @inheritdoc
  92. */
  93. _renderPasswordForm() {
  94. const { _passwordJoinFailed, t } = this.props;
  95. return (
  96. <>
  97. <InputField
  98. className = { _passwordJoinFailed ? 'error' : '' }
  99. onChange = { this._onChangePassword }
  100. placeHolder = { t('lobby.passwordField') }
  101. testId = 'lobby.password'
  102. type = 'password'
  103. value = { this.state.password } />
  104. {_passwordJoinFailed && <div
  105. className = 'prejoin-error'
  106. data-testid = 'lobby.errorMessage'>{t('lobby.invalidPassword')}</div>}
  107. </>
  108. );
  109. }
  110. /**
  111. * Renders the password join button (set).
  112. *
  113. * @inheritdoc
  114. */
  115. _renderPasswordJoinButtons() {
  116. const { t } = this.props;
  117. return (
  118. <>
  119. <ActionButton
  120. onClick = { this._onJoinWithPassword }
  121. testId = 'lobby.passwordJoinButton'
  122. type = 'primary'>
  123. { t('prejoin.joinMeeting') }
  124. </ActionButton>
  125. <ActionButton
  126. onClick = { this._onSwitchToKnockMode }
  127. testId = 'lobby.backToKnockModeButton'
  128. type = 'secondary'>
  129. { t('lobby.backToKnockModeButton') }
  130. </ActionButton>
  131. </>
  132. );
  133. }
  134. /**
  135. * Renders the standard button set.
  136. *
  137. * @inheritdoc
  138. */
  139. _renderStandardButtons() {
  140. const { _knocking, _renderPassword, t } = this.props;
  141. return (
  142. <>
  143. { _knocking || <ActionButton
  144. disabled = { !this.state.displayName }
  145. onClick = { this._onAskToJoin }
  146. testId = 'lobby.knockButton'
  147. type = 'primary'>
  148. { t('lobby.knockButton') }
  149. </ActionButton> }
  150. {_renderPassword && <ActionButton
  151. onClick = { this._onSwitchToPasswordMode }
  152. testId = 'lobby.enterPasswordButton'
  153. type = 'secondary'>
  154. { t('lobby.enterPasswordButton') }
  155. </ActionButton> }
  156. </>
  157. );
  158. }
  159. }
  160. export default translate(connect(_mapStateToProps)(LobbyScreen));