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 { PARTICIPANT_ROLE, getLocalParticipant } from '../../../base/participants'; import { updateDialInNumbers } from '../../actions'; 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 { /** * Default values for {@code InfoDialog} component's properties. * * @static */ static defaultProps = { autoUpdateNumbers: true }; /** * {@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 redux state representing the dial-in numbers feature. */ _dialIn: PropTypes.object, /** * 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, /** * Whether or not this component should make a request for dial-in * numbers. If false, this component will rely on an outside source * updating and passing in numbers through the _dialIn prop. */ autoUpdateNumbers: PropTypes.bool, /** * Invoked to open a dialog for adding participants to the conference. */ dispatch: PropTypes.func, /** * 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._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 {@link Component#componentDidMount()}. Invoked immediately * after this component is mounted. Requests dial-in numbers if not * already known. * * @inheritdoc * @returns {void} */ componentDidMount() { if (!this.state.phoneNumber && this.props.autoUpdateNumbers) { this.props.dispatch(updateDialInNumbers()); } } /** * 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 { onMouseOver, t } = this.props; return (

{ t('info.title') }
{ t('info.conferenceURL', { url: this._getURLToDisplay() }) }