import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { setPassword } from '../../../base/conference'; import { getInviteURL } from '../../../base/connection'; import { translate } from '../../../base/i18n'; import { isLocalParticipantModerator } from '../../../base/participants'; import DialInNumber from './DialInNumber'; import PasswordForm from './PasswordForm'; const logger = require('jitsi-meet-logger').getLogger(__filename); /** * A React Component with the contents for a dialog that shows information about * the current conference. * * @extends Component */ class InfoDialog extends Component { /** * {@code InfoDialog} component's property types. * * @static */ static propTypes = { /** * Whether or not the current user can modify the current password. */ _canEditPassword: PropTypes.bool, /** * The JitsiConference for which to display a lock state and change the * password. * * @type {JitsiConference} */ _conference: PropTypes.object, /** * The name of the current conference. Used as part of inviting users. */ _conferenceName: PropTypes.string, /** * The current url of the conference to be copied onto the clipboard. */ _inviteURL: PropTypes.string, /** * The value for how the conference is locked (or undefined if not * locked) as defined by room-lock constants. */ _locked: PropTypes.string, /** * The current known password for the JitsiConference. */ _password: PropTypes.string, /** * The object representing the dialIn feature. */ dialIn: PropTypes.object, /** * Invoked to open a dialog for adding participants to the conference. */ dispatch: PropTypes.func, /** * The current known URL for a live stream in progress. */ liveStreamViewURL: PropTypes.string, /** * Callback invoked when the dialog should be closed. */ onClose: PropTypes.func, /** * Callback invoked when a mouse-related event has been detected. */ onMouseOver: PropTypes.func, /** * Invoked to obtain translated strings. */ t: PropTypes.func }; /** * {@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: '' }; /** * Initializes new {@code InfoDialog} instance. * * @param {Object} props - The read-only properties with which the new * instance is to be initialized. */ constructor(props) { super(props); const { defaultCountry, numbers } = props.dialIn; if (numbers) { this.state.phoneNumber = this._getDefaultPhoneNumber(numbers, defaultCountry); } /** * 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#componentWillReceiveProps()}. Invoked * before this mounted component receives new props. * * @inheritdoc * @param {Props} nextProps - New props component will receive. */ componentWillReceiveProps(nextProps) { if (!this.props._password && nextProps._password) { this.setState({ passwordEditEnabled: false }); } if (!this.state.phoneNumber && nextProps.dialIn.numbers) { const { defaultCountry, numbers } = nextProps.dialIn; this.setState({ phoneNumber: this._getDefaultPhoneNumber(numbers, defaultCountry) }); } } /** * Implements React's {@link Component#render()}. * * @inheritdoc * @returns {ReactElement} */ render() { const { liveStreamViewURL, onMouseOver, t } = this.props; return (

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