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.

InviteDialog.js 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. import React, { Component } from 'react';
  2. import { connect } from 'react-redux';
  3. import { Dialog } from '../../base/dialog';
  4. import { translate } from '../../base/i18n';
  5. import JitsiMeetJS from '../../base/lib-jitsi-meet';
  6. import {
  7. getLocalParticipant,
  8. PARTICIPANT_ROLE
  9. } from '../../base/participants';
  10. import PasswordContainer from './PasswordContainer';
  11. import ShareLinkForm from './ShareLinkForm';
  12. import DialInNumbersForm from './DialInNumbersForm';
  13. /**
  14. * A React {@code Component} for displaying other components responsible for
  15. * copying the current conference url and for setting or removing a conference
  16. * password.
  17. */
  18. class InviteDialog extends Component {
  19. /**
  20. * {@code InviteDialog} component's property types.
  21. *
  22. * @static
  23. */
  24. static propTypes = {
  25. /**
  26. * The redux store representation of the JitsiConference.
  27. *
  28. */
  29. _conference: React.PropTypes.object,
  30. /**
  31. * Whether or not the current user is a conference moderator.
  32. */
  33. _isModerator: React.PropTypes.bool,
  34. /**
  35. * The url for the JitsiConference.
  36. */
  37. conferenceUrl: React.PropTypes.string,
  38. /**
  39. * The url for retrieving dial-in numbers.
  40. */
  41. dialInNumbersUrl: React.PropTypes.string,
  42. /**
  43. * Invoked to obtain translated strings.
  44. */
  45. t: React.PropTypes.func
  46. }
  47. /**
  48. * Reports an analytics event for the invite modal being closed.
  49. *
  50. * @inheritdoc
  51. */
  52. componentWillUnmount() {
  53. JitsiMeetJS.analytics.sendEvent('toolbar.invite.close');
  54. }
  55. /**
  56. * Implements React's {@link Component#render()}.
  57. *
  58. * @inheritdoc
  59. * @returns {ReactElement}
  60. */
  61. render() {
  62. const { _conference } = this.props;
  63. const titleString
  64. = this.props.t(
  65. 'invite.inviteTo',
  66. { conferenceName: _conference.room });
  67. return (
  68. <Dialog
  69. cancelDisabled = { true }
  70. okTitleKey = 'dialog.done'
  71. titleString = { titleString }>
  72. <div className = 'invite-dialog'>
  73. <ShareLinkForm toCopy = { this.props.conferenceUrl } />
  74. { this._renderDialInNumbersForm() }
  75. <PasswordContainer
  76. conference = { _conference.conference }
  77. locked = { _conference.locked }
  78. password = { _conference.password }
  79. showPasswordEdit = { this.props._isModerator } />
  80. </div>
  81. </Dialog>
  82. );
  83. }
  84. /**
  85. * Creates a React {@code Component} for displaying and copying to clipboard
  86. * telephone numbers for dialing in to the conference.
  87. *
  88. * @private
  89. * @returns {ReactElement|null}
  90. */
  91. _renderDialInNumbersForm() {
  92. return (
  93. this.props.dialInNumbersUrl
  94. ? <DialInNumbersForm
  95. dialInNumbersUrl = { this.props.dialInNumbersUrl } />
  96. : null
  97. );
  98. }
  99. }
  100. /**
  101. * Maps (parts of) the Redux state to the associated {@code InviteDialog}'s
  102. * props.
  103. *
  104. * @param {Object} state - The Redux state.
  105. * @private
  106. * @returns {{
  107. * _conference: Object,
  108. * _isModerator: boolean
  109. * }}
  110. */
  111. function _mapStateToProps(state) {
  112. const { role }
  113. = getLocalParticipant(state['features/base/participants']);
  114. return {
  115. _conference: state['features/base/conference'],
  116. _isModerator: role === PARTICIPANT_ROLE.MODERATOR
  117. };
  118. }
  119. export default translate(connect(_mapStateToProps)(InviteDialog));