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.

AddPeopleDialog.js 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. // @flow
  2. import React, { useEffect } from 'react';
  3. import { createInviteDialogEvent, sendAnalytics } from '../../../../analytics';
  4. import { getInviteURL } from '../../../../base/connection';
  5. import { Dialog } from '../../../../base/dialog';
  6. import { translate } from '../../../../base/i18n';
  7. import { JitsiRecordingConstants } from '../../../../base/lib-jitsi-meet';
  8. import { connect } from '../../../../base/redux';
  9. import { isVpaasMeeting } from '../../../../billing-counter/functions';
  10. import EmbedMeetingTrigger from '../../../../embed-meeting/components/EmbedMeetingTrigger';
  11. import { getActiveSession } from '../../../../recording';
  12. import { updateDialInNumbers } from '../../../actions';
  13. import { _getDefaultPhoneNumber, getInviteText, isAddPeopleEnabled, isDialOutEnabled } from '../../../functions';
  14. import CopyMeetingLinkSection from './CopyMeetingLinkSection';
  15. import DialInSection from './DialInSection';
  16. import InviteByEmailSection from './InviteByEmailSection';
  17. import InviteContactsSection from './InviteContactsSection';
  18. import LiveStreamSection from './LiveStreamSection';
  19. declare var interfaceConfig: Object;
  20. type Props = {
  21. /**
  22. * The object representing the dialIn feature.
  23. */
  24. _dialIn: Object,
  25. /**
  26. * Whether or not embed meeting should be visible.
  27. */
  28. _embedMeetingVisible: boolean,
  29. /**
  30. * The meeting invitation text.
  31. */
  32. _invitationText: string,
  33. /**
  34. * Whether or not invite contacts should be visible.
  35. */
  36. _inviteContactsVisible: boolean,
  37. /**
  38. * The current url of the conference to be copied onto the clipboard.
  39. */
  40. _inviteUrl: string,
  41. /**
  42. * The current known URL for a live stream in progress.
  43. */
  44. _liveStreamViewURL: string,
  45. /**
  46. * The default phone number.
  47. */
  48. _phoneNumber: ?string,
  49. /**
  50. * Invoked to obtain translated strings.
  51. */
  52. t: Function,
  53. /**
  54. * Method to update the dial in numbers.
  55. */
  56. updateNumbers: Function
  57. };
  58. /**
  59. * Invite More component.
  60. *
  61. * @returns {React$Element<any>}
  62. */
  63. function AddPeopleDialog({
  64. _dialIn,
  65. _embedMeetingVisible,
  66. _invitationText,
  67. _inviteContactsVisible,
  68. _inviteUrl,
  69. _liveStreamViewURL,
  70. _phoneNumber,
  71. t,
  72. updateNumbers }: Props) {
  73. /**
  74. * Updates the dial-in numbers.
  75. */
  76. useEffect(() => {
  77. if (!_dialIn.numbers) {
  78. updateNumbers();
  79. }
  80. }, []);
  81. /**
  82. * Sends analytics events when the dialog opens/closes.
  83. *
  84. * @returns {void}
  85. */
  86. useEffect(() => {
  87. sendAnalytics(createInviteDialogEvent(
  88. 'invite.dialog.opened', 'dialog'));
  89. return () => {
  90. sendAnalytics(createInviteDialogEvent(
  91. 'invite.dialog.closed', 'dialog'));
  92. };
  93. }, []);
  94. const inviteSubject = t('addPeople.inviteMoreMailSubject', {
  95. appName: interfaceConfig.APP_NAME
  96. });
  97. return (
  98. <Dialog
  99. cancelKey = { 'dialog.close' }
  100. hideCancelButton = { true }
  101. submitDisabled = { true }
  102. titleKey = 'addPeople.inviteMorePrompt'
  103. width = { 'small' }>
  104. <div className = 'invite-more-dialog'>
  105. { _inviteContactsVisible && <InviteContactsSection /> }
  106. <CopyMeetingLinkSection url = { _inviteUrl } />
  107. <InviteByEmailSection
  108. inviteSubject = { inviteSubject }
  109. inviteText = { _invitationText } />
  110. { _embedMeetingVisible && <EmbedMeetingTrigger /> }
  111. <div className = 'invite-more-dialog separator' />
  112. {
  113. _liveStreamViewURL
  114. && <LiveStreamSection liveStreamViewURL = { _liveStreamViewURL } />
  115. }
  116. {
  117. _dialIn.numbers
  118. && <DialInSection phoneNumber = { _phoneNumber } />
  119. }
  120. </div>
  121. </Dialog>
  122. );
  123. }
  124. /**
  125. * Maps (parts of) the Redux state to the associated props for the
  126. * {@code AddPeopleDialog} component.
  127. *
  128. * @param {Object} state - The Redux state.
  129. * @param {Object} ownProps - The properties explicitly passed to the component.
  130. * @private
  131. * @returns {Props}
  132. */
  133. function mapStateToProps(state, ownProps) {
  134. const currentLiveStreamingSession
  135. = getActiveSession(state, JitsiRecordingConstants.mode.STREAM);
  136. const { iAmRecorder } = state['features/base/config'];
  137. const addPeopleEnabled = isAddPeopleEnabled(state);
  138. const dialOutEnabled = isDialOutEnabled(state);
  139. const hideInviteContacts = iAmRecorder || (!addPeopleEnabled && !dialOutEnabled);
  140. const dialIn = state['features/invite'];
  141. const phoneNumber = dialIn && dialIn.numbers ? _getDefaultPhoneNumber(dialIn.numbers) : undefined;
  142. return {
  143. _dialIn: dialIn,
  144. _embedMeetingVisible: !isVpaasMeeting(state),
  145. _invitationText: getInviteText({ state,
  146. phoneNumber,
  147. t: ownProps.t }),
  148. _inviteContactsVisible: interfaceConfig.ENABLE_DIAL_OUT && !hideInviteContacts,
  149. _inviteUrl: getInviteURL(state),
  150. _liveStreamViewURL:
  151. currentLiveStreamingSession
  152. && currentLiveStreamingSession.liveStreamViewURL,
  153. _phoneNumber: phoneNumber
  154. };
  155. }
  156. /**
  157. * Maps dispatching of some action to React component props.
  158. *
  159. * @param {Function} dispatch - Redux action dispatcher.
  160. * @returns {Props}
  161. */
  162. const mapDispatchToProps = {
  163. updateNumbers: () => updateDialInNumbers()
  164. };
  165. export default translate(
  166. connect(mapStateToProps, mapDispatchToProps)(AddPeopleDialog)
  167. );