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.web.js 3.1KB

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