import React, { Component } from 'react'; import { connect } from 'react-redux'; import { translate } from '../../base/i18n'; import { Dialog } from '../../base/dialog'; import { cancel, checkDialNumber, dial } from '../actions'; import DialOutNumbersForm from './DialOutNumbersForm'; /** * Implements a React Component which allows the user to dial out from the * conference. */ class DialOutDialog extends Component { /** * {@code DialOutDialog} component's property types. * * @static */ static propTypes = { /** * Property indicating if a dial number is allowed. */ _isDialNumberAllowed: React.PropTypes.bool, /** * The function performing the cancel action. */ cancel: React.PropTypes.func, /** * The function performing the phone number validity check. */ checkDialNumber: React.PropTypes.func, /** * The function performing the dial action. */ dial: React.PropTypes.func, /** * Invoked to obtain translated strings. */ t: React.PropTypes.func }; /** * Initializes a new {@code DialOutNumbersForm} instance. * * @param {Object} props - The read-only properties with which the new * instance is to be initialized. */ constructor(props) { super(props); this.state = { /** * The number to dial. */ dialNumber: '', /** * Indicates if the dial input is currently empty. */ isDialInputEmpty: true }; // Bind event handlers so they are only bound once for every instance. this._onDialNumberChange = this._onDialNumberChange.bind(this); this._onCancel = this._onCancel.bind(this); this._onSubmit = this._onSubmit.bind(this); } /** * Implements React's {@link Component#render()}. * * @inheritdoc * @returns {ReactElement} */ render() { const { _isDialNumberAllowed } = this.props; return ( ); } /** * Formats the dial number in a way to remove all non digital characters * from it (including spaces, brackets, dash, dot, etc.). * * @param {string} dialNumber - The phone number to format. * @private * @returns {string} - The formatted phone number. */ _formatDialNumber(dialNumber) { return dialNumber.replace(/\D/g, ''); } /** * Renders the dialog content. * * @returns {XML} * @private */ _renderContent() { const { _isDialNumberAllowed } = this.props; return (