Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

AddPeopleDialog.js 6.4KB

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