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.js 3.3KB

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