2020-04-15 13:13:43 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
|
|
|
|
import { translate } from '../../../base/i18n';
|
2022-11-08 10:24:32 +00:00
|
|
|
import { Icon, IconCloseLarge } from '../../../base/icons';
|
2022-10-13 10:42:39 +00:00
|
|
|
import { InputField, PreMeetingScreen } from '../../../base/premeeting';
|
2020-04-15 13:13:43 +00:00
|
|
|
import { LoadingIndicator } from '../../../base/react';
|
|
|
|
import { connect } from '../../../base/redux';
|
2022-10-13 10:42:39 +00:00
|
|
|
import Button from '../../../base/ui/components/web/Button';
|
2022-03-03 17:29:38 +00:00
|
|
|
import ChatInput from '../../../chat/components/web/ChatInput';
|
|
|
|
import MessageContainer from '../../../chat/components/web/MessageContainer';
|
2020-05-20 08:25:31 +00:00
|
|
|
import AbstractLobbyScreen, {
|
2022-09-27 07:10:28 +00:00
|
|
|
type Props,
|
|
|
|
_mapStateToProps
|
2020-05-20 08:25:31 +00:00
|
|
|
} from '../AbstractLobbyScreen';
|
2020-04-15 13:13:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements a waiting screen that represents the participant being in the lobby.
|
|
|
|
*/
|
2022-03-03 17:29:38 +00:00
|
|
|
class LobbyScreen extends AbstractLobbyScreen<Props> {
|
|
|
|
/**
|
|
|
|
* Reference to the React Component for displaying chat messages. Used for
|
|
|
|
* scrolling to the end of the chat messages.
|
|
|
|
*/
|
|
|
|
_messageContainerRef: Object;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes a new {@code LobbyScreen} instance.
|
|
|
|
*
|
|
|
|
* @param {Object} props - The read-only properties with which the new
|
|
|
|
* instance is to be initialized.
|
|
|
|
*/
|
|
|
|
constructor(props: Props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this._messageContainerRef = React.createRef();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements {@code Component#componentDidMount}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
componentDidMount() {
|
|
|
|
this._scrollMessageContainerToBottom(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements {@code Component#componentDidUpdate}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
componentDidUpdate(prevProps) {
|
|
|
|
if (this.props._lobbyChatMessages !== prevProps._lobbyChatMessages) {
|
|
|
|
this._scrollMessageContainerToBottom(true);
|
|
|
|
} else if (this.props._isLobbyChatActive && !prevProps._isLobbyChatActive) {
|
|
|
|
this._scrollMessageContainerToBottom(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-15 13:13:43 +00:00
|
|
|
/**
|
|
|
|
* Implements {@code PureComponent#render}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
render() {
|
2021-08-20 08:53:11 +00:00
|
|
|
const { _deviceStatusVisible, showCopyUrlButton, t } = this.props;
|
2021-06-22 17:07:57 +00:00
|
|
|
|
2020-04-15 13:13:43 +00:00
|
|
|
return (
|
2021-06-22 17:07:57 +00:00
|
|
|
<PreMeetingScreen
|
2021-08-20 08:53:11 +00:00
|
|
|
className = 'lobby-screen'
|
2021-06-22 17:07:57 +00:00
|
|
|
showCopyUrlButton = { showCopyUrlButton }
|
2021-08-20 08:53:11 +00:00
|
|
|
showDeviceStatus = { _deviceStatusVisible }
|
2022-03-03 17:29:38 +00:00
|
|
|
title = { t(this._getScreenTitleKey(), { moderator: this.props._lobbyMessageRecipient }) }>
|
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;
|
|
|
|
|
2022-03-03 17:29:38 +00:00
|
|
|
_onSendMessage: () => void;
|
|
|
|
|
2020-04-15 13:13:43 +00:00
|
|
|
_onSubmit: () => boolean;
|
|
|
|
|
|
|
|
_onSwitchToKnockMode: () => void;
|
|
|
|
|
|
|
|
_onSwitchToPasswordMode: () => void;
|
|
|
|
|
2022-03-03 17:29:38 +00:00
|
|
|
_onToggleChat: () => void;
|
|
|
|
|
2020-04-15 13:13:43 +00:00
|
|
|
_renderContent: () => React$Element<*>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders the joining (waiting) fragment of the screen.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2020-05-20 08:25:31 +00:00
|
|
|
_renderJoining() {
|
2022-03-03 17:29:38 +00:00
|
|
|
const { _isLobbyChatActive } = this.props;
|
|
|
|
|
2020-04-15 13:13:43 +00:00
|
|
|
return (
|
2021-08-20 08:53:11 +00:00
|
|
|
<div className = 'lobby-screen-content'>
|
2022-03-03 17:29:38 +00:00
|
|
|
{_isLobbyChatActive
|
|
|
|
? this._renderLobbyChat()
|
|
|
|
: (
|
|
|
|
<>
|
|
|
|
<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() }
|
2020-04-15 13:13:43 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-03-03 17:29:38 +00:00
|
|
|
/**
|
|
|
|
* Renders the widget to chat with the moderator before allowed in.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
_renderLobbyChat() {
|
|
|
|
const { _lobbyChatMessages, t } = this.props;
|
|
|
|
const { isChatOpen } = this.state;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className = { `lobby-chat-container ${isChatOpen ? 'hidden' : ''}` }>
|
|
|
|
<div className = 'lobby-chat-header'>
|
|
|
|
<h1 className = 'title'>
|
|
|
|
{ t(this._getScreenTitleKey(), { moderator: this.props._lobbyMessageRecipient }) }
|
|
|
|
</h1>
|
|
|
|
<Icon
|
|
|
|
ariaLabel = { t('toolbar.closeChat') }
|
|
|
|
onClick = { this._onToggleChat }
|
|
|
|
role = 'button'
|
2022-11-08 10:24:32 +00:00
|
|
|
src = { IconCloseLarge } />
|
2022-03-03 17:29:38 +00:00
|
|
|
</div>
|
|
|
|
<MessageContainer
|
|
|
|
messages = { _lobbyChatMessages }
|
|
|
|
ref = { this._messageContainerRef } />
|
|
|
|
<ChatInput onSend = { this._onSendMessage } />
|
|
|
|
</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 (
|
2021-08-20 08:53:11 +00:00
|
|
|
<>
|
|
|
|
<InputField
|
|
|
|
className = { _passwordJoinFailed ? 'error' : '' }
|
|
|
|
onChange = { this._onChangePassword }
|
|
|
|
placeHolder = { t('lobby.passwordField') }
|
|
|
|
testId = 'lobby.password'
|
|
|
|
type = 'password'
|
|
|
|
value = { this.state.password } />
|
|
|
|
|
|
|
|
{_passwordJoinFailed && <div
|
|
|
|
className = 'prejoin-error'
|
|
|
|
data-testid = 'lobby.errorMessage'>{t('lobby.invalidPassword')}</div>}
|
|
|
|
</>
|
2020-04-15 13:13:43 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders the password join button (set).
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
_renderPasswordJoinButtons() {
|
|
|
|
return (
|
|
|
|
<>
|
2022-10-13 10:42:39 +00:00
|
|
|
<Button
|
|
|
|
className = 'lobby-button-margin'
|
|
|
|
fullWidth = { true }
|
|
|
|
labelKey = 'prejoin.joinMeeting'
|
2020-05-20 08:25:31 +00:00
|
|
|
onClick = { this._onJoinWithPassword }
|
2020-07-10 15:28:57 +00:00
|
|
|
testId = 'lobby.passwordJoinButton'
|
2022-10-13 10:42:39 +00:00
|
|
|
type = 'primary' />
|
|
|
|
<Button
|
|
|
|
className = 'lobby-button-margin'
|
|
|
|
fullWidth = { true }
|
|
|
|
labelKey = 'lobby.backToKnockModeButton'
|
2020-04-15 13:13:43 +00:00
|
|
|
onClick = { this._onSwitchToKnockMode }
|
2020-07-10 15:28:57 +00:00
|
|
|
testId = 'lobby.backToKnockModeButton'
|
2022-10-13 10:42:39 +00:00
|
|
|
type = 'secondary' />
|
2020-04-15 13:13:43 +00:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders the standard button set.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
_renderStandardButtons() {
|
2022-10-13 10:42:39 +00:00
|
|
|
const { _knocking, _isLobbyChatActive, _renderPassword } = this.props;
|
2020-04-15 13:13:43 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2022-10-13 10:42:39 +00:00
|
|
|
{_knocking || <Button
|
|
|
|
className = 'lobby-button-margin'
|
2020-04-15 13:13:43 +00:00
|
|
|
disabled = { !this.state.displayName }
|
2022-10-13 10:42:39 +00:00
|
|
|
fullWidth = { true }
|
|
|
|
labelKey = 'lobby.knockButton'
|
2020-04-15 13:13:43 +00:00
|
|
|
onClick = { this._onAskToJoin }
|
2020-07-10 15:28:57 +00:00
|
|
|
testId = 'lobby.knockButton'
|
2022-10-13 10:42:39 +00:00
|
|
|
type = 'primary' />
|
|
|
|
}
|
|
|
|
{(_knocking && _isLobbyChatActive) && <Button
|
|
|
|
className = 'lobby-button-margin open-chat-button'
|
|
|
|
fullWidth = { true }
|
|
|
|
labelKey = 'toolbar.openChat'
|
2022-03-03 17:29:38 +00:00
|
|
|
onClick = { this._onToggleChat }
|
|
|
|
testId = 'toolbar.openChat'
|
2022-10-13 10:42:39 +00:00
|
|
|
type = 'primary' />
|
|
|
|
}
|
|
|
|
{_renderPassword && <Button
|
|
|
|
className = 'lobby-button-margin'
|
|
|
|
fullWidth = { true }
|
|
|
|
labelKey = 'lobby.enterPasswordButton'
|
2020-04-15 13:13:43 +00:00
|
|
|
onClick = { this._onSwitchToPasswordMode }
|
2020-07-10 15:28:57 +00:00
|
|
|
testId = 'lobby.enterPasswordButton'
|
2022-10-13 10:42:39 +00:00
|
|
|
type = 'secondary' />
|
|
|
|
}
|
2020-04-15 13:13:43 +00:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
2022-03-03 17:29:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Scrolls the chat messages so the latest message is visible.
|
|
|
|
*
|
|
|
|
* @param {boolean} withAnimation - Whether or not to show a scrolling
|
|
|
|
* animation.
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_scrollMessageContainerToBottom(withAnimation) {
|
|
|
|
if (this._messageContainerRef.current) {
|
2022-09-01 18:05:35 +00:00
|
|
|
this._messageContainerRef.current.scrollToElement(withAnimation);
|
2022-03-03 17:29:38 +00:00
|
|
|
}
|
|
|
|
}
|
2020-04-15 13:13:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default translate(connect(_mapStateToProps)(LobbyScreen));
|