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

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