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

AddPeopleDialog.js 6.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. // @flow
  2. import React, { useState, useEffect } from 'react';
  3. import { createInviteDialogEvent, sendAnalytics } from '../../../../analytics';
  4. import { getRoomName } from '../../../../base/conference';
  5. import { getInviteURL } from '../../../../base/connection';
  6. import { Dialog } from '../../../../base/dialog';
  7. import { translate } from '../../../../base/i18n';
  8. import { JitsiRecordingConstants } from '../../../../base/lib-jitsi-meet';
  9. import { getLocalParticipant } from '../../../../base/participants';
  10. import { connect } from '../../../../base/redux';
  11. import { isVpaasMeeting } from '../../../../billing-counter/functions';
  12. import EmbedMeetingTrigger from '../../../../embed-meeting/components/EmbedMeetingTrigger';
  13. import { getActiveSession } from '../../../../recording';
  14. import { updateDialInNumbers } from '../../../actions';
  15. import { _getDefaultPhoneNumber, getInviteText, isAddPeopleEnabled, isDialOutEnabled } from '../../../functions';
  16. import CopyMeetingLinkSection from './CopyMeetingLinkSection';
  17. import DialInSection from './DialInSection';
  18. import Header from './Header';
  19. import InviteByEmailSection from './InviteByEmailSection';
  20. import InviteContactsSection from './InviteContactsSection';
  21. import LiveStreamSection from './LiveStreamSection';
  22. declare var interfaceConfig: Object;
  23. type Props = {
  24. /**
  25. * The name of the current conference. Used as part of inviting users.
  26. */
  27. _conferenceName: string,
  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 invite contacts should be visible.
  38. */
  39. _inviteContactsVisible: boolean,
  40. /**
  41. * The current url of the conference to be copied onto the clipboard.
  42. */
  43. _inviteUrl: string,
  44. /**
  45. * The current known URL for a live stream in progress.
  46. */
  47. _liveStreamViewURL: string,
  48. /**
  49. * The redux representation of the local participant.
  50. */
  51. _localParticipantName: ?string,
  52. /**
  53. * The current location url of the conference.
  54. */
  55. _locationUrl: Object,
  56. /**
  57. * Invoked to obtain translated strings.
  58. */
  59. t: Function,
  60. /**
  61. * Method to update the dial in numbers.
  62. */
  63. updateNumbers: Function
  64. };
  65. /**
  66. * Invite More component.
  67. *
  68. * @returns {React$Element<any>}
  69. */
  70. function AddPeopleDialog({
  71. _conferenceName,
  72. _dialIn,
  73. _embedMeetingVisible,
  74. _inviteContactsVisible,
  75. _inviteUrl,
  76. _liveStreamViewURL,
  77. _localParticipantName,
  78. _locationUrl,
  79. t,
  80. updateNumbers }: Props) {
  81. const [ phoneNumber, setPhoneNumber ] = useState(undefined);
  82. /**
  83. * Updates the dial-in numbers.
  84. */
  85. useEffect(() => {
  86. if (!_dialIn.numbers) {
  87. updateNumbers();
  88. }
  89. }, []);
  90. /**
  91. * Sends analytics events when the dialog opens/closes.
  92. *
  93. * @returns {void}
  94. */
  95. useEffect(() => {
  96. sendAnalytics(createInviteDialogEvent(
  97. 'invite.dialog.opened', 'dialog'));
  98. return () => {
  99. sendAnalytics(createInviteDialogEvent(
  100. 'invite.dialog.closed', 'dialog'));
  101. };
  102. }, []);
  103. /**
  104. * Updates the phone number in the state once the dial-in numbers are fetched.
  105. *
  106. * @returns {void}
  107. */
  108. useEffect(() => {
  109. if (!phoneNumber && _dialIn && _dialIn.numbers) {
  110. setPhoneNumber(_getDefaultPhoneNumber(_dialIn.numbers));
  111. }
  112. }, [ _dialIn ]);
  113. const invite = getInviteText({
  114. _conferenceName,
  115. _localParticipantName,
  116. _inviteUrl,
  117. _locationUrl,
  118. _dialIn,
  119. _liveStreamViewURL,
  120. phoneNumber,
  121. t
  122. });
  123. const inviteSubject = t('addPeople.inviteMoreMailSubject', {
  124. appName: interfaceConfig.APP_NAME
  125. });
  126. return (
  127. <Dialog
  128. cancelKey = { 'dialog.close' }
  129. customHeader = { Header }
  130. hideCancelButton = { true }
  131. submitDisabled = { true }
  132. titleKey = 'addPeople.inviteMorePrompt'
  133. width = { 'small' }>
  134. <div className = 'invite-more-dialog'>
  135. { _inviteContactsVisible && <InviteContactsSection /> }
  136. <CopyMeetingLinkSection url = { _inviteUrl } />
  137. <InviteByEmailSection
  138. inviteSubject = { inviteSubject }
  139. inviteText = { invite } />
  140. { _embedMeetingVisible && <EmbedMeetingTrigger /> }
  141. <div className = 'invite-more-dialog separator' />
  142. {
  143. _liveStreamViewURL
  144. && <LiveStreamSection liveStreamViewURL = { _liveStreamViewURL } />
  145. }
  146. {
  147. _dialIn.numbers
  148. && <DialInSection
  149. conferenceName = { _conferenceName }
  150. dialIn = { _dialIn }
  151. locationUrl = { _locationUrl }
  152. phoneNumber = { phoneNumber } />
  153. }
  154. </div>
  155. </Dialog>
  156. );
  157. }
  158. /**
  159. * Maps (parts of) the Redux state to the associated props for the
  160. * {@code AddPeopleDialog} component.
  161. *
  162. * @param {Object} state - The Redux state.
  163. * @private
  164. * @returns {Props}
  165. */
  166. function mapStateToProps(state) {
  167. const localParticipant = getLocalParticipant(state);
  168. const currentLiveStreamingSession
  169. = getActiveSession(state, JitsiRecordingConstants.mode.STREAM);
  170. const { iAmRecorder } = state['features/base/config'];
  171. const addPeopleEnabled = isAddPeopleEnabled(state);
  172. const dialOutEnabled = isDialOutEnabled(state);
  173. const hideInviteContacts = iAmRecorder || (!addPeopleEnabled && !dialOutEnabled);
  174. return {
  175. _conferenceName: getRoomName(state),
  176. _dialIn: state['features/invite'],
  177. _embedMeetingVisible: !isVpaasMeeting(state),
  178. _inviteContactsVisible: interfaceConfig.ENABLE_DIAL_OUT && !hideInviteContacts,
  179. _inviteUrl: getInviteURL(state),
  180. _liveStreamViewURL:
  181. currentLiveStreamingSession
  182. && currentLiveStreamingSession.liveStreamViewURL,
  183. _localParticipantName: localParticipant?.name,
  184. _locationUrl: state['features/base/connection'].locationURL
  185. };
  186. }
  187. /**
  188. * Maps dispatching of some action to React component props.
  189. *
  190. * @param {Function} dispatch - Redux action dispatcher.
  191. * @returns {Props}
  192. */
  193. const mapDispatchToProps = {
  194. updateNumbers: () => updateDialInNumbers()
  195. };
  196. export default translate(
  197. connect(mapStateToProps, mapDispatchToProps)(AddPeopleDialog)
  198. );