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

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