2020-04-16 10:47:10 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import React, { Component } from 'react';
|
|
|
|
import { translate } from '../../../base/i18n';
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Flag signaling if the name is ediable or not.
|
|
|
|
*/
|
|
|
|
isEditable: boolean,
|
|
|
|
|
2020-05-07 07:42:55 +00:00
|
|
|
/**
|
|
|
|
* Joins the current meeting.
|
|
|
|
*/
|
|
|
|
joinConference: Function,
|
|
|
|
|
2020-04-16 10:47:10 +00:00
|
|
|
/**
|
|
|
|
* Sets the name for the joining user.
|
|
|
|
*/
|
|
|
|
setName: Function,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Used to obtain translations.
|
|
|
|
*/
|
|
|
|
t: Function,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The text to be displayed.
|
|
|
|
*/
|
|
|
|
value: string,
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Participant name - can be an editable input or just the text name.
|
|
|
|
*
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
class ParticipantName extends Component<Props> {
|
2020-05-07 07:42:55 +00:00
|
|
|
|
2020-04-16 10:47:10 +00:00
|
|
|
/**
|
|
|
|
* Initializes a new {@code ParticipantName} instance.
|
|
|
|
*
|
|
|
|
* @param {Props} props - The props of the component.
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
2020-05-07 07:42:55 +00:00
|
|
|
this._onKeyDown = this._onKeyDown.bind(this);
|
2020-04-16 10:47:10 +00:00
|
|
|
this._onNameChange = this._onNameChange.bind(this);
|
|
|
|
}
|
|
|
|
|
2020-05-07 07:42:55 +00:00
|
|
|
_onKeyDown: () => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Joins the conference on 'Enter'.
|
|
|
|
*
|
|
|
|
* @param {Event} event - Key down event object.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onKeyDown(event) {
|
|
|
|
if (event.key === 'Enter') {
|
|
|
|
this.props.joinConference();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-16 10:47:10 +00:00
|
|
|
_onNameChange: () => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handler used for changing the guest user name.
|
|
|
|
*
|
|
|
|
* @returns {undefined}
|
|
|
|
*/
|
|
|
|
_onNameChange({ target: { value } }) {
|
|
|
|
this.props.setName(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
const { value, isEditable, t } = this.props;
|
2020-05-07 07:42:55 +00:00
|
|
|
const { _onKeyDown, _onNameChange } = this;
|
2020-04-16 10:47:10 +00:00
|
|
|
|
|
|
|
return isEditable ? (
|
|
|
|
<input
|
2020-05-07 07:42:55 +00:00
|
|
|
autoFocus = { true }
|
2020-04-16 10:47:10 +00:00
|
|
|
className = 'prejoin-preview-name prejoin-preview-name--editable'
|
2020-05-07 07:42:55 +00:00
|
|
|
onChange = { _onNameChange }
|
|
|
|
onKeyDown = { _onKeyDown }
|
2020-04-16 10:47:10 +00:00
|
|
|
placeholder = { t('dialog.enterDisplayName') }
|
|
|
|
value = { value } />
|
|
|
|
)
|
2020-05-07 07:42:55 +00:00
|
|
|
: <div
|
|
|
|
className = 'prejoin-preview-name'
|
|
|
|
onKeyDown = { _onKeyDown }
|
|
|
|
tabIndex = '0' >
|
|
|
|
{value}
|
|
|
|
</div>
|
2020-04-16 10:47:10 +00:00
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default translate(ParticipantName);
|