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

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