2019-04-02 13:16:52 +00:00
|
|
|
// @flow
|
2018-10-30 05:02:23 +00:00
|
|
|
|
2018-02-13 19:46:47 +00:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
|
2019-04-02 13:16:52 +00:00
|
|
|
import { translate } from '../../../../base/i18n';
|
2020-04-01 07:47:51 +00:00
|
|
|
import { Icon, IconCopy } from '../../../../base/icons';
|
2022-10-06 08:11:06 +00:00
|
|
|
import { copyText } from '../../../../base/util/copyText.web';
|
2019-07-02 13:14:58 +00:00
|
|
|
import { _formatConferenceIDPin } from '../../../_utils';
|
|
|
|
|
2018-02-13 19:46:47 +00:00
|
|
|
/**
|
2018-10-30 05:02:23 +00:00
|
|
|
* The type of the React {@code Component} props of {@link DialInNumber}.
|
2018-02-13 19:46:47 +00:00
|
|
|
*/
|
2018-10-30 05:02:23 +00:00
|
|
|
type Props = {
|
|
|
|
|
2018-02-13 19:46:47 +00:00
|
|
|
/**
|
2021-03-16 15:59:33 +00:00
|
|
|
* The numeric identifier for the current conference, used after dialing a
|
2018-10-30 05:02:23 +00:00
|
|
|
* the number to join the conference.
|
2018-02-13 19:46:47 +00:00
|
|
|
*/
|
2018-10-30 05:02:23 +00:00
|
|
|
conferenceID: number,
|
2018-02-13 19:46:47 +00:00
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
/**
|
|
|
|
* The phone number to dial to begin the process of dialing into a
|
|
|
|
* conference.
|
|
|
|
*/
|
|
|
|
phoneNumber: string,
|
2018-02-13 19:46:47 +00:00
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
/**
|
|
|
|
* Invoked to obtain translated strings.
|
|
|
|
*/
|
|
|
|
t: Function
|
|
|
|
};
|
2018-02-13 19:46:47 +00:00
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
/**
|
|
|
|
* React {@code Component} responsible for displaying a telephone number and
|
|
|
|
* conference ID for dialing into a conference.
|
|
|
|
*
|
2021-11-04 21:10:43 +00:00
|
|
|
* @augments Component
|
2018-10-30 05:02:23 +00:00
|
|
|
*/
|
|
|
|
class DialInNumber extends Component<Props> {
|
2020-04-01 07:47:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes a new DialInNumber instance.
|
|
|
|
*
|
|
|
|
* @param {Object} props - The read-only properties with which the new
|
|
|
|
* instance is to be initialized.
|
|
|
|
*/
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
// Bind event handler so it is only bound once for every instance.
|
|
|
|
this._onCopyText = this._onCopyText.bind(this);
|
2021-06-10 12:48:44 +00:00
|
|
|
this._onCopyTextKeyPress = this._onCopyTextKeyPress.bind(this);
|
2020-04-01 07:47:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_onCopyText: () => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Copies the dial-in information to the clipboard.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onCopyText() {
|
|
|
|
const { conferenceID, phoneNumber, t } = this.props;
|
|
|
|
const dialInLabel = t('info.dialInNumber');
|
|
|
|
const passcode = t('info.dialInConferenceID');
|
|
|
|
const conferenceIDPin = `${_formatConferenceIDPin(conferenceID)}#`;
|
|
|
|
const textToCopy = `${dialInLabel} ${phoneNumber} ${passcode} ${conferenceIDPin}`;
|
|
|
|
|
|
|
|
copyText(textToCopy);
|
|
|
|
}
|
|
|
|
|
2021-06-10 12:48:44 +00:00
|
|
|
_onCopyTextKeyPress: (Object) => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* KeyPress handler for accessibility.
|
|
|
|
*
|
|
|
|
* @param {Object} e - The key event to handle.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onCopyTextKeyPress(e) {
|
|
|
|
if (e.key === ' ' || e.key === 'Enter') {
|
|
|
|
e.preventDefault();
|
|
|
|
this._onCopyText();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-13 19:46:47 +00:00
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
2018-04-04 15:58:54 +00:00
|
|
|
const { conferenceID, phoneNumber, t } = this.props;
|
2018-02-13 19:46:47 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className = 'dial-in-number'>
|
2021-01-04 13:30:23 +00:00
|
|
|
<div>
|
|
|
|
<span className = 'phone-number'>
|
|
|
|
<span className = 'info-label'>
|
|
|
|
{ t('info.dialInNumber') }
|
|
|
|
</span>
|
|
|
|
<span className = 'spacer'> </span>
|
|
|
|
<span className = 'info-value'>
|
|
|
|
{ phoneNumber }
|
|
|
|
</span>
|
2018-04-04 15:58:54 +00:00
|
|
|
</span>
|
|
|
|
<span className = 'spacer'> </span>
|
2021-01-04 13:30:23 +00:00
|
|
|
<span className = 'conference-id'>
|
|
|
|
<span className = 'info-label'>
|
|
|
|
{ t('info.dialInConferenceID') }
|
|
|
|
</span>
|
|
|
|
<span className = 'spacer'> </span>
|
|
|
|
<span className = 'info-value'>
|
|
|
|
{ `${_formatConferenceIDPin(conferenceID)}#` }
|
|
|
|
</span>
|
2018-04-04 15:58:54 +00:00
|
|
|
</span>
|
2021-01-04 13:30:23 +00:00
|
|
|
</div>
|
2020-04-01 07:47:51 +00:00
|
|
|
<a
|
2021-06-10 12:48:44 +00:00
|
|
|
aria-label = { t('info.copyNumber') }
|
2020-04-01 07:47:51 +00:00
|
|
|
className = 'dial-in-copy'
|
2021-06-10 12:48:44 +00:00
|
|
|
onClick = { this._onCopyText }
|
|
|
|
onKeyPress = { this._onCopyTextKeyPress }
|
|
|
|
role = 'button'
|
|
|
|
tabIndex = { 0 }>
|
2020-04-01 07:47:51 +00:00
|
|
|
<Icon src = { IconCopy } />
|
|
|
|
</a>
|
2018-02-13 19:46:47 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default translate(DialInNumber);
|