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 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. /**
  13. * A React {@code Component} for displaying other components responsible for
  14. * copying the current conference url and for setting or removing a conference
  15. * password.
  16. */
  17. class InviteDialog extends Component {
  18. /**
  19. * {@code InviteDialog} component's property types.
  20. *
  21. * @static
  22. */
  23. static propTypes = {
  24. /**
  25. * The redux store representation of the JitsiConference.
  26. *
  27. */
  28. _conference: React.PropTypes.object,
  29. /**
  30. * Whether or not the current user is a conference moderator.
  31. */
  32. _isModerator: React.PropTypes.bool,
  33. /**
  34. * The url for the JitsiConference.
  35. */
  36. conferenceUrl: React.PropTypes.string,
  37. /**
  38. * Invoked to obtain translated strings.
  39. */
  40. t: React.PropTypes.func
  41. }
  42. /**
  43. * Reports an analytics event for the invite modal being closed.
  44. *
  45. * @inheritdoc
  46. */
  47. componentWillUnmount() {
  48. JitsiMeetJS.analytics.sendEvent('toolbar.invite.close');
  49. }
  50. /**
  51. * Implements React's {@link Component#render()}.
  52. *
  53. * @inheritdoc
  54. * @returns {ReactElement}
  55. */
  56. render() {
  57. const { _conference } = this.props;
  58. const titleString
  59. = this.props.t(
  60. 'invite.inviteTo',
  61. { 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 = { this.props.conferenceUrl } />
  69. <PasswordContainer
  70. conference = { _conference.conference }
  71. locked = { _conference.locked }
  72. password = { _conference.password }
  73. showPasswordEdit = { this.props._isModerator } />
  74. </div>
  75. </Dialog>
  76. );
  77. }
  78. }
  79. /**
  80. * Maps (parts of) the Redux state to the associated {@code InviteDialog}'s
  81. * props.
  82. *
  83. * @param {Object} state - The Redux state.
  84. * @private
  85. * @returns {{
  86. * _conference: Object,
  87. * _isModerator: boolean
  88. * }}
  89. */
  90. function _mapStateToProps(state) {
  91. const { role }
  92. = getLocalParticipant(state['features/base/participants']);
  93. return {
  94. _conference: state['features/base/conference'],
  95. _isModerator: role === PARTICIPANT_ROLE.MODERATOR
  96. };
  97. }
  98. export default translate(connect(_mapStateToProps)(InviteDialog));