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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. value = { displayName } />
  82. </div>
  83. </div>
  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. <div className = 'form'>
  95. <InputField
  96. className = { _passwordJoinFailed ? 'error' : '' }
  97. onChange = { this._onChangePassword }
  98. placeHolder = { _passwordJoinFailed ? t('lobby.invalidPassword') : t('lobby.passwordField') }
  99. type = 'password'
  100. value = { this.state.password } />
  101. </div>
  102. );
  103. }
  104. /**
  105. * Renders the password join button (set).
  106. *
  107. * @inheritdoc
  108. */
  109. _renderPasswordJoinButtons() {
  110. const { t } = this.props;
  111. return (
  112. <>
  113. <ActionButton
  114. disabled = { !this.state.password }
  115. onClick = { this._onJoinWithPassword }
  116. type = 'primary'>
  117. { t('lobby.passwordJoinButton') }
  118. </ActionButton>
  119. <ActionButton
  120. onClick = { this._onSwitchToKnockMode }
  121. type = 'secondary'>
  122. { t('lobby.backToKnockModeButton') }
  123. </ActionButton>
  124. </>
  125. );
  126. }
  127. /**
  128. * Renders the standard button set.
  129. *
  130. * @inheritdoc
  131. */
  132. _renderStandardButtons() {
  133. const { _knocking, t } = this.props;
  134. return (
  135. <>
  136. { _knocking || <ActionButton
  137. disabled = { !this.state.displayName }
  138. onClick = { this._onAskToJoin }
  139. type = 'primary'>
  140. { t('lobby.knockButton') }
  141. </ActionButton> }
  142. <ActionButton
  143. onClick = { this._onSwitchToPasswordMode }
  144. type = 'secondary'>
  145. { t('lobby.enterPasswordButton') }
  146. </ActionButton>
  147. </>
  148. );
  149. }
  150. }
  151. export default translate(connect(_mapStateToProps)(LobbyScreen));