jiti-meet/react/features/lobby/components/web/LobbyScreen.js

182 lines
5.1 KiB
JavaScript
Raw Normal View History

// @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';
import { LoadingIndicator } from '../../../base/react';
import { connect } from '../../../base/redux';
2020-05-20 08:25:31 +00:00
import AbstractLobbyScreen, {
_mapStateToProps
} from '../AbstractLobbyScreen';
/**
* Implements a waiting screen that represents the participant being in the lobby.
*/
class LobbyScreen extends AbstractLobbyScreen {
/**
* Implements {@code PureComponent#render}.
*
* @inheritdoc
*/
render() {
const { showCopyUrlButton, t } = this.props;
return (
<PreMeetingScreen
showCopyUrlButton = { showCopyUrlButton }
title = { t(this._getScreenTitleKey()) }>
2020-05-20 08:25:31 +00:00
{ this._renderContent() }
</PreMeetingScreen>
);
}
_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;
_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() {
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') }
</span>
2020-05-20 08:25:31 +00:00
{ this._renderStandardButtons() }
</div>
);
}
/**
* 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();
}
/**
* Renders the participant info fragment when we have all the required details of the user.
*
* @inheritdoc
*/
_renderParticipantInfo() {
const { displayName } = this.state;
2020-05-20 08:25:31 +00:00
const { t } = this.props;
return (
2020-09-29 11:00:30 +00:00
<InputField
onChange = { this._onChangeDisplayName }
placeHolder = { t('lobby.nameField') }
testId = 'lobby.nameField'
value = { displayName } />
);
}
/**
* 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;
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 } />
);
}
/**
* Renders the password join button (set).
*
* @inheritdoc
*/
_renderPasswordJoinButtons() {
const { t } = this.props;
return (
<>
2020-05-20 08:25:31 +00:00
<ActionButton
disabled = { !this.state.password }
2020-05-20 08:25:31 +00:00
onClick = { this._onJoinWithPassword }
testId = 'lobby.passwordJoinButton'
2020-05-20 08:25:31 +00:00
type = 'primary'>
{ t('lobby.passwordJoinButton') }
2020-05-20 08:25:31 +00:00
</ActionButton>
<ActionButton
onClick = { this._onSwitchToKnockMode }
testId = 'lobby.backToKnockModeButton'
2020-05-20 08:25:31 +00:00
type = 'secondary'>
{ t('lobby.backToKnockModeButton') }
2020-05-20 08:25:31 +00:00
</ActionButton>
</>
);
}
/**
* Renders the standard button set.
*
* @inheritdoc
*/
_renderStandardButtons() {
const { _knocking, _renderPassword, t } = this.props;
return (
<>
2020-05-20 08:25:31 +00:00
{ _knocking || <ActionButton
disabled = { !this.state.displayName }
onClick = { this._onAskToJoin }
testId = 'lobby.knockButton'
2020-05-20 08:25:31 +00:00
type = 'primary'>
{ t('lobby.knockButton') }
2020-05-20 08:25:31 +00:00
</ActionButton> }
{_renderPassword && <ActionButton
onClick = { this._onSwitchToPasswordMode }
testId = 'lobby.enterPasswordButton'
2020-05-20 08:25:31 +00:00
type = 'secondary'>
{ t('lobby.enterPasswordButton') }
</ActionButton> }
</>
);
}
}
export default translate(connect(_mapStateToProps)(LobbyScreen));