2020-04-15 13:13:43 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
|
|
|
|
import { translate } from '../../../base/i18n';
|
2020-05-20 08:25:31 +00:00
|
|
|
import { ActionButton, InputField, PreMeetingScreen } from '../../../base/premeeting';
|
2020-04-15 13:13:43 +00:00
|
|
|
import { LoadingIndicator } from '../../../base/react';
|
|
|
|
import { connect } from '../../../base/redux';
|
2020-05-20 08:25:31 +00:00
|
|
|
import AbstractLobbyScreen, {
|
|
|
|
_mapStateToProps
|
|
|
|
} from '../AbstractLobbyScreen';
|
2020-04-15 13:13:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements a waiting screen that represents the participant being in the lobby.
|
|
|
|
*/
|
|
|
|
class LobbyScreen extends AbstractLobbyScreen {
|
|
|
|
/**
|
|
|
|
* Implements {@code PureComponent#render}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
render() {
|
2021-06-22 17:07:57 +00:00
|
|
|
const { showCopyUrlButton, t } = this.props;
|
|
|
|
|
2020-04-15 13:13:43 +00:00
|
|
|
return (
|
2021-06-22 17:07:57 +00:00
|
|
|
<PreMeetingScreen
|
|
|
|
showCopyUrlButton = { showCopyUrlButton }
|
|
|
|
title = { t(this._getScreenTitleKey()) }>
|
2020-05-20 08:25:31 +00:00
|
|
|
{ this._renderContent() }
|
|
|
|
</PreMeetingScreen>
|
2020-04-15 13:13:43 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
_getScreenTitleKey: () => string;
|
|
|
|
|
|
|
|
_onAskToJoin: () => boolean;
|
|
|
|
|
|
|
|
_onCancel: () => boolean;
|
|
|
|
|
|
|
|
_onChangeDisplayName: Object => void;
|
|
|
|
|
|
|
|
_onChangeEmail: Object => void;
|
|
|
|
|
|
|
|
_onChangePassword: Object => void;
|
|
|
|
|
|
|
|
_onEnableEdit: () => void;
|
|
|
|
|
2020-05-20 08:25:31 +00:00
|
|
|
_onJoinWithPassword: () => void;
|
|
|
|
|
2020-04-15 13:13:43 +00:00
|
|
|
_onSubmit: () => boolean;
|
|
|
|
|
|
|
|
_onSwitchToKnockMode: () => void;
|
|
|
|
|
|
|
|
_onSwitchToPasswordMode: () => void;
|
|
|
|
|
|
|
|
_renderContent: () => React$Element<*>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders the joining (waiting) fragment of the screen.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2020-05-20 08:25:31 +00:00
|
|
|
_renderJoining() {
|
2020-04-15 13:13:43 +00:00
|
|
|
return (
|
2020-05-20 08:25:31 +00:00
|
|
|
<div className = 'container'>
|
|
|
|
<div className = 'spinner'>
|
|
|
|
<LoadingIndicator size = 'large' />
|
|
|
|
</div>
|
|
|
|
<span className = 'joining-message'>
|
|
|
|
{ this.props.t('lobby.joiningMessage') }
|
2020-04-15 13:13:43 +00:00
|
|
|
</span>
|
2020-05-20 08:25:31 +00:00
|
|
|
{ this._renderStandardButtons() }
|
2020-04-15 13:13:43 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-06-17 09:37:27 +00:00
|
|
|
/**
|
|
|
|
* Renders the participant form to let the knocking participant enter its details.
|
|
|
|
*
|
|
|
|
* NOTE: We don't use edit action on web since the prejoin functionality got merged.
|
|
|
|
* Mobile won't use it either once prejoin gets implemented there too.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
_renderParticipantForm() {
|
|
|
|
return this._renderParticipantInfo();
|
|
|
|
}
|
|
|
|
|
2020-04-15 13:13:43 +00:00
|
|
|
/**
|
|
|
|
* Renders the participant info fragment when we have all the required details of the user.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
_renderParticipantInfo() {
|
2020-06-17 09:37:27 +00:00
|
|
|
const { displayName } = this.state;
|
2020-05-20 08:25:31 +00:00
|
|
|
const { t } = this.props;
|
2020-04-15 13:13:43 +00:00
|
|
|
|
|
|
|
return (
|
2020-09-29 11:00:30 +00:00
|
|
|
<InputField
|
|
|
|
onChange = { this._onChangeDisplayName }
|
|
|
|
placeHolder = { t('lobby.nameField') }
|
|
|
|
testId = 'lobby.nameField'
|
|
|
|
value = { displayName } />
|
2020-04-15 13:13:43 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders the password form to let the participant join by using a password instead of knocking.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
_renderPasswordForm() {
|
2020-05-20 08:25:31 +00:00
|
|
|
const { _passwordJoinFailed, t } = this.props;
|
|
|
|
|
2020-04-15 13:13:43 +00:00
|
|
|
return (
|
2020-09-29 11:00:30 +00:00
|
|
|
<InputField
|
|
|
|
className = { _passwordJoinFailed ? 'error' : '' }
|
|
|
|
onChange = { this._onChangePassword }
|
|
|
|
placeHolder = { _passwordJoinFailed ? t('lobby.invalidPassword') : t('lobby.passwordField') }
|
|
|
|
testId = 'lobby.password'
|
|
|
|
type = 'password'
|
|
|
|
value = { this.state.password } />
|
2020-04-15 13:13:43 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders the password join button (set).
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
_renderPasswordJoinButtons() {
|
|
|
|
const { t } = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2020-05-20 08:25:31 +00:00
|
|
|
<ActionButton
|
2020-04-15 13:13:43 +00:00
|
|
|
disabled = { !this.state.password }
|
2020-05-20 08:25:31 +00:00
|
|
|
onClick = { this._onJoinWithPassword }
|
2020-07-10 15:28:57 +00:00
|
|
|
testId = 'lobby.passwordJoinButton'
|
2020-05-20 08:25:31 +00:00
|
|
|
type = 'primary'>
|
2020-04-15 13:13:43 +00:00
|
|
|
{ t('lobby.passwordJoinButton') }
|
2020-05-20 08:25:31 +00:00
|
|
|
</ActionButton>
|
|
|
|
<ActionButton
|
2020-04-15 13:13:43 +00:00
|
|
|
onClick = { this._onSwitchToKnockMode }
|
2020-07-10 15:28:57 +00:00
|
|
|
testId = 'lobby.backToKnockModeButton'
|
2020-05-20 08:25:31 +00:00
|
|
|
type = 'secondary'>
|
2020-04-15 13:13:43 +00:00
|
|
|
{ t('lobby.backToKnockModeButton') }
|
2020-05-20 08:25:31 +00:00
|
|
|
</ActionButton>
|
2020-04-15 13:13:43 +00:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders the standard button set.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
_renderStandardButtons() {
|
2021-05-12 13:21:22 +00:00
|
|
|
const { _knocking, _renderPassword, t } = this.props;
|
2020-04-15 13:13:43 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2020-05-20 08:25:31 +00:00
|
|
|
{ _knocking || <ActionButton
|
2020-04-15 13:13:43 +00:00
|
|
|
disabled = { !this.state.displayName }
|
|
|
|
onClick = { this._onAskToJoin }
|
2020-07-10 15:28:57 +00:00
|
|
|
testId = 'lobby.knockButton'
|
2020-05-20 08:25:31 +00:00
|
|
|
type = 'primary'>
|
2020-04-15 13:13:43 +00:00
|
|
|
{ t('lobby.knockButton') }
|
2020-05-20 08:25:31 +00:00
|
|
|
</ActionButton> }
|
2021-05-12 13:21:22 +00:00
|
|
|
{_renderPassword && <ActionButton
|
2020-04-15 13:13:43 +00:00
|
|
|
onClick = { this._onSwitchToPasswordMode }
|
2020-07-10 15:28:57 +00:00
|
|
|
testId = 'lobby.enterPasswordButton'
|
2020-05-20 08:25:31 +00:00
|
|
|
type = 'secondary'>
|
2020-04-15 13:13:43 +00:00
|
|
|
{ t('lobby.enterPasswordButton') }
|
2021-05-12 13:21:22 +00:00
|
|
|
</ActionButton> }
|
2020-04-15 13:13:43 +00:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default translate(connect(_mapStateToProps)(LobbyScreen));
|