123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- // @flow
-
- import React, { useEffect } from 'react';
-
- import { createInviteDialogEvent, sendAnalytics } from '../../../../analytics';
- import { getInviteURL } from '../../../../base/connection';
- import { Dialog } from '../../../../base/dialog';
- import { translate } from '../../../../base/i18n';
- import { JitsiRecordingConstants } from '../../../../base/lib-jitsi-meet';
- import { connect } from '../../../../base/redux';
- import { isDynamicBrandingDataLoaded } from '../../../../dynamic-branding/functions';
- import EmbedMeetingTrigger from '../../../../embed-meeting/components/EmbedMeetingTrigger';
- import { isVpaasMeeting } from '../../../../jaas/functions';
- import { getActiveSession } from '../../../../recording';
- import { updateDialInNumbers } from '../../../actions';
- import {
- _getDefaultPhoneNumber,
- getInviteText,
- getInviteTextiOS,
- isAddPeopleEnabled,
- isDialOutEnabled,
- sharingFeatures,
- isSharingEnabled
- } from '../../../functions';
-
- import CopyMeetingLinkSection from './CopyMeetingLinkSection';
- import DialInSection from './DialInSection';
- import InviteByEmailSection from './InviteByEmailSection';
- import InviteContactsSection from './InviteContactsSection';
- import LiveStreamSection from './LiveStreamSection';
-
- declare var interfaceConfig: Object;
-
- type Props = {
-
- /**
- * The object representing the dialIn feature.
- */
- _dialIn: Object,
-
- /**
- * Whether or not embed meeting should be visible.
- */
- _embedMeetingVisible: boolean,
-
- /**
- * Whether or not dial in number should be visible.
- */
- _dialInVisible: boolean,
-
- /**
- * Whether or not url sharing button should be visible.
- */
- _urlSharingVisible: boolean,
-
- /**
- * Whether or not email sharing features should be visible.
- */
- _emailSharingVisible: boolean,
-
- /**
- * The meeting invitation text.
- */
- _invitationText: string,
-
- /**
- * The custom no new-lines meeting invitation text for iOS default email.
- * Needed because of this mailto: iOS issue: https://developer.apple.com/forums/thread/681023
- */
- _invitationTextiOS: string,
-
- /**
- * An alternate app name to be displayed in the email subject.
- */
- _inviteAppName: ?string,
-
- /**
- * Whether or not invite contacts should be visible.
- */
- _inviteContactsVisible: boolean,
-
- /**
- * The current url of the conference to be copied onto the clipboard.
- */
- _inviteUrl: string,
-
- /**
- * The current known URL for a live stream in progress.
- */
- _liveStreamViewURL: string,
-
- /**
- * The default phone number.
- */
- _phoneNumber: ?string,
-
- /**
- * Invoked to obtain translated strings.
- */
- t: Function,
-
- /**
- * Method to update the dial in numbers.
- */
- updateNumbers: Function
- };
-
- /**
- * Invite More component.
- *
- * @returns {React$Element<any>}
- */
- function AddPeopleDialog({
- _dialIn,
- _embedMeetingVisible,
- _dialInVisible,
- _urlSharingVisible,
- _emailSharingVisible,
- _invitationText,
- _invitationTextiOS,
- _inviteAppName,
- _inviteContactsVisible,
- _inviteUrl,
- _liveStreamViewURL,
- _phoneNumber,
- t,
- updateNumbers }: Props) {
-
- /**
- * Updates the dial-in numbers.
- */
- useEffect(() => {
- if (!_dialIn.numbers) {
- updateNumbers();
- }
- }, []);
-
- /**
- * Sends analytics events when the dialog opens/closes.
- *
- * @returns {void}
- */
- useEffect(() => {
- sendAnalytics(createInviteDialogEvent(
- 'invite.dialog.opened', 'dialog'));
-
- return () => {
- sendAnalytics(createInviteDialogEvent(
- 'invite.dialog.closed', 'dialog'));
- };
- }, []);
-
- const inviteSubject = t('addPeople.inviteMoreMailSubject', {
- appName: _inviteAppName ?? interfaceConfig.APP_NAME
- });
-
- return (
- <Dialog
- cancelKey = { 'dialog.close' }
- hideCancelButton = { true }
- submitDisabled = { true }
- titleKey = 'addPeople.inviteMorePrompt'
- width = { 'small' }>
- <div className = 'invite-more-dialog'>
- { _inviteContactsVisible && <InviteContactsSection /> }
- {_urlSharingVisible ? <CopyMeetingLinkSection url = { _inviteUrl } /> : null}
- {
- _emailSharingVisible
- ? <InviteByEmailSection
- inviteSubject = { inviteSubject }
- inviteText = { _invitationText }
- inviteTextiOS = { _invitationTextiOS } />
- : null
- }
- { _embedMeetingVisible && <EmbedMeetingTrigger /> }
- <div className = 'invite-more-dialog separator' />
- {
- _liveStreamViewURL
- && <LiveStreamSection liveStreamViewURL = { _liveStreamViewURL } />
- }
- {
- _phoneNumber
- && _dialInVisible
- && <DialInSection phoneNumber = { _phoneNumber } />
- }
- </div>
- </Dialog>
- );
- }
-
- /**
- * Maps (parts of) the Redux state to the associated props for the
- * {@code AddPeopleDialog} component.
- *
- * @param {Object} state - The Redux state.
- * @param {Object} ownProps - The properties explicitly passed to the component.
- * @private
- * @returns {Props}
- */
- function mapStateToProps(state, ownProps) {
- const currentLiveStreamingSession
- = getActiveSession(state, JitsiRecordingConstants.mode.STREAM);
- const { iAmRecorder, inviteAppName } = state['features/base/config'];
- const addPeopleEnabled = isAddPeopleEnabled(state);
- const dialOutEnabled = isDialOutEnabled(state);
- const hideInviteContacts = iAmRecorder || (!addPeopleEnabled && !dialOutEnabled);
- const dialIn = state['features/invite'];
- const phoneNumber = dialIn && dialIn.numbers ? _getDefaultPhoneNumber(dialIn.numbers) : undefined;
-
- return {
- _dialIn: dialIn,
- _embedMeetingVisible: !isVpaasMeeting(state) && isSharingEnabled(sharingFeatures.embed),
- _dialInVisible: isSharingEnabled(sharingFeatures.dialIn),
- _urlSharingVisible: isDynamicBrandingDataLoaded(state) && isSharingEnabled(sharingFeatures.url),
- _emailSharingVisible: isSharingEnabled(sharingFeatures.email),
- _invitationText: getInviteText({ state,
- phoneNumber,
- t: ownProps.t }),
- _invitationTextiOS: getInviteTextiOS({ state,
- phoneNumber,
- t: ownProps.t }),
- _inviteAppName: inviteAppName,
- _inviteContactsVisible: interfaceConfig.ENABLE_DIAL_OUT && !hideInviteContacts,
- _inviteUrl: getInviteURL(state),
- _liveStreamViewURL:
- currentLiveStreamingSession
- && currentLiveStreamingSession.liveStreamViewURL,
- _phoneNumber: phoneNumber
- };
- }
-
- /**
- * Maps dispatching of some action to React component props.
- *
- * @param {Function} dispatch - Redux action dispatcher.
- * @returns {Props}
- */
- const mapDispatchToProps = {
- updateNumbers: () => updateDialInNumbers()
- };
-
- export default translate(
- connect(mapStateToProps, mapDispatchToProps)(AddPeopleDialog)
- );
|