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 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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 info fragment when we have all the required details of the user.
  58. *
  59. * @inheritdoc
  60. */
  61. _renderParticipantInfo() {
  62. const { displayName, email } = this.state;
  63. const { t } = this.props;
  64. return (
  65. <div className = 'participant-info'>
  66. <div className = 'form'>
  67. <InputField
  68. onChange = { this._onChangeDisplayName }
  69. placeHolder = { t('lobby.nameField') }
  70. value = { displayName } />
  71. <InputField
  72. onChange = { this._onChangeEmail }
  73. placeHolder = { t('lobby.emailField') }
  74. value = { email } />
  75. </div>
  76. </div>
  77. );
  78. }
  79. /**
  80. * Renders the password form to let the participant join by using a password instead of knocking.
  81. *
  82. * @inheritdoc
  83. */
  84. _renderPasswordForm() {
  85. const { _passwordJoinFailed, t } = this.props;
  86. return (
  87. <div className = 'form'>
  88. <InputField
  89. className = { _passwordJoinFailed ? 'error' : '' }
  90. onChange = { this._onChangePassword }
  91. placeHolder = { _passwordJoinFailed ? t('lobby.invalidPassword') : t('lobby.passwordField') }
  92. type = 'password'
  93. value = { this.state.password } />
  94. </div>
  95. );
  96. }
  97. /**
  98. * Renders the password join button (set).
  99. *
  100. * @inheritdoc
  101. */
  102. _renderPasswordJoinButtons() {
  103. const { t } = this.props;
  104. return (
  105. <>
  106. <ActionButton
  107. disabled = { !this.state.password }
  108. onClick = { this._onJoinWithPassword }
  109. type = 'primary'>
  110. { t('lobby.passwordJoinButton') }
  111. </ActionButton>
  112. <ActionButton
  113. onClick = { this._onSwitchToKnockMode }
  114. type = 'secondary'>
  115. { t('lobby.backToKnockModeButton') }
  116. </ActionButton>
  117. </>
  118. );
  119. }
  120. /**
  121. * Renders the standard button set.
  122. *
  123. * @inheritdoc
  124. */
  125. _renderStandardButtons() {
  126. const { _knocking, t } = this.props;
  127. return (
  128. <>
  129. { _knocking || <ActionButton
  130. disabled = { !this.state.displayName }
  131. onClick = { this._onAskToJoin }
  132. type = 'primary'>
  133. { t('lobby.knockButton') }
  134. </ActionButton> }
  135. <ActionButton
  136. onClick = { this._onSwitchToPasswordMode }
  137. type = 'secondary'>
  138. { t('lobby.enterPasswordButton') }
  139. </ActionButton>
  140. </>
  141. );
  142. }
  143. }
  144. export default translate(connect(_mapStateToProps)(LobbyScreen));