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

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