You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DialInNumber.tsx 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import React, { Component } from 'react';
  2. import { WithTranslation } from 'react-i18next';
  3. import { translate } from '../../../../base/i18n/functions';
  4. import Icon from '../../../../base/icons/components/Icon';
  5. import { IconCopy } from '../../../../base/icons/svg';
  6. import { copyText } from '../../../../base/util/copyText.web';
  7. import { _formatConferenceIDPin } from '../../../_utils';
  8. /**
  9. * The type of the React {@code Component} props of {@link DialInNumber}.
  10. */
  11. interface IProps extends WithTranslation {
  12. /**
  13. * The numeric identifier for the current conference, used after dialing a
  14. * the number to join the conference.
  15. */
  16. conferenceID: string | number;
  17. /**
  18. * The phone number to dial to begin the process of dialing into a
  19. * conference.
  20. */
  21. phoneNumber: string;
  22. }
  23. /**
  24. * React {@code Component} responsible for displaying a telephone number and
  25. * conference ID for dialing into a conference.
  26. *
  27. * @augments Component
  28. */
  29. class DialInNumber extends Component<IProps> {
  30. /**
  31. * Initializes a new DialInNumber instance.
  32. *
  33. * @param {Object} props - The read-only properties with which the new
  34. * instance is to be initialized.
  35. */
  36. constructor(props: IProps) {
  37. super(props);
  38. // Bind event handler so it is only bound once for every instance.
  39. this._onCopyText = this._onCopyText.bind(this);
  40. }
  41. /**
  42. * Copies the dial-in information to the clipboard.
  43. *
  44. * @returns {void}
  45. */
  46. _onCopyText() {
  47. const { conferenceID, phoneNumber, t } = this.props;
  48. const dialInLabel = t('info.dialInNumber');
  49. const passcode = t('info.dialInConferenceID');
  50. const conferenceIDPin = `${_formatConferenceIDPin(conferenceID)}#`;
  51. const textToCopy = `${dialInLabel} ${phoneNumber} ${passcode} ${conferenceIDPin}`;
  52. copyText(textToCopy);
  53. }
  54. /**
  55. * Implements React's {@link Component#render()}.
  56. *
  57. * @inheritdoc
  58. * @returns {ReactElement}
  59. */
  60. render() {
  61. const { conferenceID, phoneNumber, t } = this.props;
  62. return (
  63. <div className = 'dial-in-number'>
  64. <p>
  65. <span className = 'phone-number'>
  66. <span className = 'info-label'>
  67. { t('info.dialInNumber') }
  68. </span>
  69. <span className = 'spacer'>&nbsp;</span>
  70. <span className = 'info-value'>
  71. { phoneNumber }
  72. </span>
  73. </span>
  74. <br />
  75. <span className = 'conference-id'>
  76. <span className = 'info-label'>
  77. { t('info.dialInConferenceID') }
  78. </span>
  79. <span className = 'spacer'>&nbsp;</span>
  80. <span className = 'info-value'>
  81. { `${_formatConferenceIDPin(conferenceID)}#` }
  82. </span>
  83. </span>
  84. </p>
  85. <button
  86. aria-label = { t('info.copyNumber') }
  87. className = 'dial-in-copy invisible-button'
  88. onClick = { this._onCopyText }>
  89. <Icon src = { IconCopy } />
  90. </button>
  91. </div>
  92. );
  93. }
  94. }
  95. export default translate(DialInNumber);