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.1KB

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