// @flow import React, { Component } from 'react'; import type { Dispatch } from 'redux'; import { setPassword } from '../../../../base/conference'; import { getInviteURL } from '../../../../base/connection'; import { Dialog } from '../../../../base/dialog'; import { translate } from '../../../../base/i18n'; import { connect } from '../../../../base/redux'; import { isLocalParticipantModerator, getLocalParticipant } from '../../../../base/participants'; import { _getDefaultPhoneNumber, getDialInfoPageURL } from '../../../functions'; import DialInNumber from './DialInNumber'; import PasswordForm from './PasswordForm'; const logger = require('jitsi-meet-logger').getLogger(__filename); /** * The type of the React {@code Component} props of {@link InfoDialog}. */ type Props = { /** * Whether or not the current user can modify the current password. */ _canEditPassword: boolean, /** * The JitsiConference for which to display a lock state and change the * password. */ _conference: Object, /** * The name of the current conference. Used as part of inviting users. */ _conferenceName: string, /** * The number of digits to be used in the password. */ _passwordNumberOfDigits: ?number, /** * The current url of the conference to be copied onto the clipboard. */ _inviteURL: string, /** * The redux representation of the local participant. */ _localParticipant: Object, /** * The current location url of the conference. */ _locationURL: Object, /** * The value for how the conference is locked (or undefined if not locked) * as defined by room-lock constants. */ _locked: string, /** * The current known password for the JitsiConference. */ _password: string, /** * The object representing the dialIn feature. */ dialIn: Object, /** * Invoked to open a dialog for adding participants to the conference. */ dispatch: Dispatch, /** * Whether is Atlaskit InlineDialog or a normal dialog. */ isInlineDialog: boolean, /** * The current known URL for a live stream in progress. */ liveStreamViewURL: string, /** * Callback invoked when the dialog should be closed. */ onClose: Function, /** * Callback invoked when a mouse-related event has been detected. */ onMouseOver: Function, /** * Invoked to obtain translated strings. */ t: Function }; /** * The type of the React {@code Component} state of {@link InfoDialog}. */ type State = { /** * Whether or not to show the password in editing mode. */ passwordEditEnabled: boolean, /** * The conference dial-in number to display. */ phoneNumber: ?string }; /** * A React Component with the contents for a dialog that shows information about * the current conference. * * @extends Component */ class InfoDialog extends Component { _copyElement: ?Object; /** * Implements React's {@link Component#getDerivedStateFromProps()}. * * @inheritdoc */ static getDerivedStateFromProps(props, state) { let phoneNumber = state.phoneNumber; if (!state.phoneNumber && props.dialIn.numbers) { phoneNumber = _getDefaultPhoneNumber(props.dialIn.numbers); } return { // Exit edit mode when a password is set locally or remotely. passwordEditEnabled: state.passwordEditEnabled && props._password ? false : state.passwordEditEnabled, phoneNumber }; } /** * {@code InfoDialog} component's local state. * * @type {Object} * @property {boolean} passwordEditEnabled - Whether or not to show the * {@code PasswordForm} in its editing state. * @property {string} phoneNumber - The number to display for dialing into * the conference. */ state = { passwordEditEnabled: false, phoneNumber: undefined }; /** * Initializes new {@code InfoDialog} instance. * * @param {Object} props - The read-only properties with which the new * instance is to be initialized. */ constructor(props: Props) { super(props); if (props.dialIn && props.dialIn.numbers) { this.state.phoneNumber = _getDefaultPhoneNumber(props.dialIn.numbers); } /** * The internal reference to the DOM/HTML element backing the React * {@code Component} text area. It is necessary for the implementation * of copying to the clipboard. * * @private * @type {HTMLTextAreaElement} */ this._copyElement = null; // Bind event handlers so they are only bound once for every instance. this._onClickURLText = this._onClickURLText.bind(this); this._onCopyInviteURL = this._onCopyInviteURL.bind(this); this._onPasswordRemove = this._onPasswordRemove.bind(this); this._onPasswordSubmit = this._onPasswordSubmit.bind(this); this._onTogglePasswordEditState = this._onTogglePasswordEditState.bind(this); this._setCopyElement = this._setCopyElement.bind(this); } /** * Implements React's {@link Component#render()}. * * @inheritdoc * @returns {ReactElement} */ render() { const { isInlineDialog, liveStreamViewURL, onMouseOver, t } = this.props; const inlineDialog = (

{ t('info.title') }
{ t('info.conferenceURL') }   { this._getURLToDisplay() }
{ this._renderDialInDisplay() }
{ liveStreamViewURL && this._renderLiveStreamURL() }
{ this._renderPasswordAction() }