您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

LobbyScreen.js 4.9KB

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