您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

AddPeopleDialog.js 6.7KB

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