feat(invite): Add conference id to dial-in numbers display
DialInNumbersForm has been modified to display a conference id to be used for dialing into the conference. The changes include: - Requesting the conference id and adding the conference id to the redux store - Displaying the conference id in DialInNumbersForm - Modifying the copy behavior to support copying the new message to clipboard - DialInNumbersForm does not display until all ajax requests have completed successfully. This eliminates the need for the REQUESTING state.
This commit is contained in:
parent
896dcde2b2
commit
47c07c2e76
|
@ -8,6 +8,19 @@
|
|||
|
||||
.invite-dialog {
|
||||
.dial-in-numbers {
|
||||
.dial-in-numbers-copy {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
position: fixed;
|
||||
user-select: text;
|
||||
-webkit-user-select: text;
|
||||
}
|
||||
|
||||
.dial-in-numbers-conference-id {
|
||||
color: orange;
|
||||
margin-left: 3px;
|
||||
}
|
||||
|
||||
.dial-in-numbers-trigger {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
|
|
|
@ -437,14 +437,13 @@
|
|||
},
|
||||
"invite": {
|
||||
"addPassword": "Add password",
|
||||
"dialInNumbers": "Dial-in telephone numbers",
|
||||
"errorFetchingNumbers": "Failed to obtain dial-in numbers",
|
||||
"callNumber": "Call __number__",
|
||||
"enterId": "Enter Meeting ID: __meetingId__ following by # to dial in from a phone",
|
||||
"howToDialIn": "To dial in, use one of the following numbers and meeting ID",
|
||||
"hidePassword": "Hide password",
|
||||
"inviteTo": "Invite people to __conferenceName__",
|
||||
"loadingNumbers": "Loading...",
|
||||
"invitedYouTo": "__userName__ has invited you to the __meetingUrl__ conference",
|
||||
"locked": "This call is locked. New callers must have the link and enter the password to join.",
|
||||
"noNumbers": "No numbers available",
|
||||
"numbersDisabled": "Dialing in has been disabled",
|
||||
"showPassword": "Show password",
|
||||
"unlocked": "This call is unlocked. Any new caller with the link may join the call."
|
||||
}
|
||||
|
|
|
@ -12,17 +12,6 @@ import { Symbol } from '../base/react';
|
|||
export const UPDATE_DIAL_IN_NUMBERS_FAILED
|
||||
= Symbol('UPDATE_DIAL_IN_NUMBERS_FAILED');
|
||||
|
||||
/**
|
||||
* The type of the action which signals a request for dial-in numbers has been
|
||||
* started.
|
||||
*
|
||||
* {
|
||||
* type: UPDATE_DIAL_IN_NUMBERS_REQUEST
|
||||
* }
|
||||
*/
|
||||
export const UPDATE_DIAL_IN_NUMBERS_REQUEST
|
||||
= Symbol('UPDATE_DIAL_IN_NUMBERS_REQUEST');
|
||||
|
||||
/**
|
||||
* The type of the action which signals a request for dial-in numbers has
|
||||
* succeeded.
|
||||
|
|
|
@ -2,7 +2,6 @@ import { openDialog } from '../../features/base/dialog';
|
|||
|
||||
import {
|
||||
UPDATE_DIAL_IN_NUMBERS_FAILED,
|
||||
UPDATE_DIAL_IN_NUMBERS_REQUEST,
|
||||
UPDATE_DIAL_IN_NUMBERS_SUCCESS
|
||||
} from './actionTypes';
|
||||
import { InviteDialog } from './components';
|
||||
|
@ -11,6 +10,10 @@ declare var $: Function;
|
|||
declare var APP: Object;
|
||||
declare var config: Object;
|
||||
|
||||
const CONFERENCE_ID_ENDPOINT = config.conferenceMapperUrl;
|
||||
const DIAL_IN_NUMBERS_ENDPOINT = config.dialInNumbersUrl;
|
||||
const MUC_URL = config && config.hosts && config.hosts.muc;
|
||||
|
||||
/**
|
||||
* Opens the Invite Dialog.
|
||||
*
|
||||
|
@ -18,34 +21,46 @@ declare var config: Object;
|
|||
*/
|
||||
export function openInviteDialog() {
|
||||
return openDialog(InviteDialog, {
|
||||
conferenceUrl: encodeURI(APP.ConferenceUrl.getInviteUrl()),
|
||||
dialInNumbersUrl: config.dialInNumbersUrl
|
||||
conferenceUrl: encodeURI(APP.ConferenceUrl.getInviteUrl())
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends an ajax request for dial-in numbers.
|
||||
* Sends an ajax requests for dial-in numbers and conference id.
|
||||
*
|
||||
* @param {string} dialInNumbersUrl - The endpoint for retrieving json that
|
||||
* includes numbers for dialing in to a conference.
|
||||
* @returns {Function}
|
||||
*/
|
||||
export function updateDialInNumbers(dialInNumbersUrl) {
|
||||
return dispatch => {
|
||||
dispatch({
|
||||
type: UPDATE_DIAL_IN_NUMBERS_REQUEST
|
||||
export function updateDialInNumbers() {
|
||||
return (dispatch, getState) => {
|
||||
|
||||
if (!CONFERENCE_ID_ENDPOINT || !DIAL_IN_NUMBERS_ENDPOINT || !MUC_URL) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { room } = getState()['features/base/conference'];
|
||||
const conferenceIdUrl
|
||||
= `${CONFERENCE_ID_ENDPOINT}?conference=${room}@${MUC_URL}`;
|
||||
|
||||
Promise.all([
|
||||
$.getJSON(DIAL_IN_NUMBERS_ENDPOINT),
|
||||
$.getJSON(conferenceIdUrl)
|
||||
]).then(([ numbersResponse, idResponse ]) => {
|
||||
if (!idResponse.conference || !idResponse.id) {
|
||||
return Promise.reject(idResponse.message);
|
||||
}
|
||||
|
||||
dispatch({
|
||||
type: UPDATE_DIAL_IN_NUMBERS_SUCCESS,
|
||||
conferenceId: idResponse,
|
||||
dialInNumbers: numbersResponse
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
dispatch({
|
||||
type: UPDATE_DIAL_IN_NUMBERS_FAILED,
|
||||
error
|
||||
});
|
||||
});
|
||||
|
||||
$.getJSON(dialInNumbersUrl)
|
||||
.success(response =>
|
||||
dispatch({
|
||||
type: UPDATE_DIAL_IN_NUMBERS_SUCCESS,
|
||||
response
|
||||
}))
|
||||
.error(error =>
|
||||
dispatch({
|
||||
type: UPDATE_DIAL_IN_NUMBERS_FAILED,
|
||||
error
|
||||
}));
|
||||
};
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import React, { Component } from 'react';
|
|||
import { connect } from 'react-redux';
|
||||
|
||||
import { translate } from '../../base/i18n';
|
||||
import { getLocalParticipant } from '../../base/participants';
|
||||
|
||||
import { updateDialInNumbers } from '../actions';
|
||||
|
||||
|
@ -25,15 +26,20 @@ class DialInNumbersForm extends Component {
|
|||
* @static
|
||||
*/
|
||||
static propTypes = {
|
||||
/**
|
||||
* The name of the current user.
|
||||
*/
|
||||
_currentUserName: React.PropTypes.string,
|
||||
|
||||
/**
|
||||
* The redux state representing the dial-in numbers feature.
|
||||
*/
|
||||
_dialIn: React.PropTypes.object,
|
||||
|
||||
/**
|
||||
* The url for retrieving dial-in numbers.
|
||||
* The url for the JitsiConference.
|
||||
*/
|
||||
dialInNumbersUrl: React.PropTypes.string,
|
||||
conferenceUrl: React.PropTypes.string,
|
||||
|
||||
/**
|
||||
* Invoked to send an ajax request for dial-in numbers.
|
||||
|
@ -77,35 +83,32 @@ class DialInNumbersForm extends Component {
|
|||
|
||||
/**
|
||||
* The internal reference to the DOM/HTML element backing the React
|
||||
* {@code Component} input. It is necessary for the implementation of
|
||||
* copying to the clipboard.
|
||||
* {@code Component} text area. It is necessary for the implementation
|
||||
* of copying to the clipboard.
|
||||
*
|
||||
* @private
|
||||
* @type {HTMLInputElement}
|
||||
* @type {HTMLTextAreaElement}
|
||||
*/
|
||||
this._inputElement = null;
|
||||
this._copyElement = null;
|
||||
|
||||
// Bind event handlers so they are only bound once for every instance.
|
||||
this._onClick = this._onClick.bind(this);
|
||||
this._onCopyClick = this._onCopyClick.bind(this);
|
||||
this._onOpenChange = this._onOpenChange.bind(this);
|
||||
this._onSelect = this._onSelect.bind(this);
|
||||
this._setInput = this._setInput.bind(this);
|
||||
this._setCopyElement = this._setCopyElement.bind(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatches a request for numbers if not already present in the redux
|
||||
* store. If numbers are present, sets a default number to display in the
|
||||
* dropdown trigger.
|
||||
* Sets a default number to display in the dropdown trigger.
|
||||
*
|
||||
* @inheritdoc
|
||||
* returns {void}
|
||||
*/
|
||||
componentDidMount() {
|
||||
componentWillMount() {
|
||||
if (this.props._dialIn.numbers) {
|
||||
this._setDefaultNumber(this.props._dialIn.numbers);
|
||||
} else {
|
||||
this.props.dispatch(
|
||||
updateDialInNumbers(this.props.dialInNumbersUrl));
|
||||
this.props.dispatch(updateDialInNumbers());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,52 +126,46 @@ class DialInNumbersForm extends Component {
|
|||
}
|
||||
|
||||
/**
|
||||
* Implements React's {@link Component#render()}.
|
||||
* Implements React's {@link Component#render()}. Returns null if the
|
||||
* component is not ready for display.
|
||||
*
|
||||
* @inheritdoc
|
||||
* @returns {ReactElement}
|
||||
* @returns {ReactElement|null}
|
||||
*/
|
||||
render() {
|
||||
const { t, _dialIn } = this.props;
|
||||
const { _dialIn, t } = this.props;
|
||||
const { conferenceId, numbers, numbersEnabled } = _dialIn;
|
||||
const { selectedNumber } = this.state;
|
||||
|
||||
const numbers = _dialIn.numbers;
|
||||
const items = numbers ? this._formatNumbers(numbers) : [];
|
||||
|
||||
const isEnabled = this._isDropdownEnabled();
|
||||
const inputWrapperClassNames
|
||||
= `form-control__container ${isEnabled ? '' : 'is-disabled'}
|
||||
${_dialIn.loading ? 'is-loading' : ''}`;
|
||||
|
||||
let triggerText = '';
|
||||
|
||||
if (!_dialIn.numbersEnabled) {
|
||||
triggerText = t('invite.numbersDisabled');
|
||||
} else if (this.state.selectedNumber
|
||||
&& this.state.selectedNumber.content) {
|
||||
triggerText = this.state.selectedNumber.content;
|
||||
} else if (!numbers && _dialIn.loading) {
|
||||
triggerText = t('invite.loadingNumbers');
|
||||
} else if (_dialIn.error) {
|
||||
triggerText = t('invite.errorFetchingNumbers');
|
||||
} else {
|
||||
triggerText = t('invite.noNumbers');
|
||||
if (!conferenceId || !numbers || !numbersEnabled || !selectedNumber) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const items = numbers ? this._formatNumbers(numbers) : [];
|
||||
|
||||
return (
|
||||
<div className = 'form-control dial-in-numbers'>
|
||||
<label className = 'form-control__label'>
|
||||
{ t('invite.dialInNumbers') }
|
||||
{ t('invite.howToDialIn') }
|
||||
<span className = 'dial-in-numbers-conference-id'>
|
||||
{ conferenceId }
|
||||
</span>
|
||||
</label>
|
||||
<div className = { inputWrapperClassNames }>
|
||||
{ this._createDropdownMenu(items, triggerText) }
|
||||
<div className = 'form-control__container'>
|
||||
{ this._createDropdownMenu(items, selectedNumber.content) }
|
||||
<button
|
||||
className = 'button-control button-control_light'
|
||||
disabled = { !isEnabled }
|
||||
onClick = { this._onClick }
|
||||
onClick = { this._onCopyClick }
|
||||
type = 'button'>
|
||||
Copy
|
||||
</button>
|
||||
</div>
|
||||
<textarea
|
||||
className = 'dial-in-numbers-copy'
|
||||
readOnly = { true }
|
||||
ref = { this._setCopyElement }
|
||||
tabIndex = '-1'
|
||||
value = { this._generateCopyText() } />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -209,7 +206,6 @@ class DialInNumbersForm extends Component {
|
|||
<input
|
||||
className = 'input-control'
|
||||
readOnly = { true }
|
||||
ref = { this._setInput }
|
||||
type = 'text'
|
||||
value = { triggerText || '' } />
|
||||
<span className = 'dial-in-numbers-trigger-icon'>
|
||||
|
@ -288,19 +284,26 @@ class DialInNumbersForm extends Component {
|
|||
}
|
||||
|
||||
/**
|
||||
* Determines if the dropdown can be opened.
|
||||
* Creates a message describing how to dial in to the conference.
|
||||
*
|
||||
* @private
|
||||
* @returns {boolean} True if the dropdown can be opened.
|
||||
* @returns {string}
|
||||
*/
|
||||
_isDropdownEnabled() {
|
||||
const { selectedNumber } = this.state;
|
||||
_generateCopyText() {
|
||||
const welcome = this.props.t('invite.invitedYouTo', {
|
||||
meetingUrl: this.props.conferenceUrl,
|
||||
userName: this.props._currentUserName
|
||||
});
|
||||
|
||||
return Boolean(
|
||||
this.props._dialIn.numbersEnabled
|
||||
&& selectedNumber
|
||||
&& selectedNumber.content
|
||||
);
|
||||
const callNumber = this.props.t('invite.callNumber',
|
||||
{ number: this.state.selectedNumber.number });
|
||||
const stepOne = `1) ${callNumber}`;
|
||||
|
||||
const enterId = this.props.t('invite.enterId',
|
||||
{ meetingId: this.props._dialIn.conferenceId });
|
||||
const stepTwo = `2) ${enterId}`;
|
||||
|
||||
return `${welcome}\n${stepOne}\n${stepTwo}`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -311,16 +314,11 @@ class DialInNumbersForm extends Component {
|
|||
* @private
|
||||
* @returns {void}
|
||||
*/
|
||||
_onClick() {
|
||||
const displayedValue = this.state.selectedNumber.content;
|
||||
const desiredNumber = this.state.selectedNumber.number;
|
||||
const startIndex = displayedValue.indexOf(desiredNumber);
|
||||
|
||||
_onCopyClick() {
|
||||
try {
|
||||
this._input.focus();
|
||||
this._input.setSelectionRange(startIndex, displayedValue.length);
|
||||
this._copyElement.select();
|
||||
document.execCommand('copy');
|
||||
this._input.blur();
|
||||
this._copyElement.blur();
|
||||
} catch (err) {
|
||||
logger.error('error when copying the text', err);
|
||||
}
|
||||
|
@ -337,7 +335,7 @@ class DialInNumbersForm extends Component {
|
|||
*/
|
||||
_onOpenChange(dropdownEvent) {
|
||||
this.setState({
|
||||
isDropdownOpen: this._isDropdownEnabled() && dropdownEvent.isOpen
|
||||
isDropdownOpen: dropdownEvent.isOpen
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -355,6 +353,19 @@ class DialInNumbersForm extends Component {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the internal reference to the DOM/HTML element backing the React
|
||||
* {@code Component} text area.
|
||||
*
|
||||
* @param {HTMLTextAreaElement} element - The DOM/HTML element for this
|
||||
* {@code Component}'s text area.
|
||||
* @private
|
||||
* @returns {void}
|
||||
*/
|
||||
_setCopyElement(element) {
|
||||
this._copyElement = element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the internal state of the currently selected number by defaulting
|
||||
* to the first available number.
|
||||
|
@ -370,19 +381,6 @@ class DialInNumbersForm extends Component {
|
|||
selectedNumber: numbers[0]
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the internal reference to the DOM/HTML element backing the React
|
||||
* {@code Component} input.
|
||||
*
|
||||
* @param {HTMLInputElement} element - The DOM/HTML element for this
|
||||
* {@code Component}'s input.
|
||||
* @private
|
||||
* @returns {void}
|
||||
*/
|
||||
_setInput(element) {
|
||||
this._input = element;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -392,11 +390,16 @@ class DialInNumbersForm extends Component {
|
|||
* @param {Object} state - The Redux state.
|
||||
* @private
|
||||
* @returns {{
|
||||
* _currentUserName: React.PropTypes.string,
|
||||
* _dialIn: React.PropTypes.object
|
||||
* }}
|
||||
*/
|
||||
function _mapStateToProps(state) {
|
||||
const { name }
|
||||
= getLocalParticipant(state['features/base/participants']);
|
||||
|
||||
return {
|
||||
_currentUserName: name,
|
||||
_dialIn: state['features/invite/dial-in']
|
||||
};
|
||||
}
|
||||
|
|
|
@ -41,11 +41,6 @@ class InviteDialog extends Component {
|
|||
*/
|
||||
conferenceUrl: React.PropTypes.string,
|
||||
|
||||
/**
|
||||
* The url for retrieving dial-in numbers.
|
||||
*/
|
||||
dialInNumbersUrl: React.PropTypes.string,
|
||||
|
||||
/**
|
||||
* Invoked to obtain translated strings.
|
||||
*/
|
||||
|
@ -68,7 +63,7 @@ class InviteDialog extends Component {
|
|||
* @returns {ReactElement}
|
||||
*/
|
||||
render() {
|
||||
const { _conference } = this.props;
|
||||
const { _conference, conferenceUrl } = this.props;
|
||||
const titleString
|
||||
= this.props.t(
|
||||
'invite.inviteTo',
|
||||
|
@ -80,8 +75,8 @@ class InviteDialog extends Component {
|
|||
okTitleKey = 'dialog.done'
|
||||
titleString = { titleString }>
|
||||
<div className = 'invite-dialog'>
|
||||
<ShareLinkForm toCopy = { this.props.conferenceUrl } />
|
||||
{ this._renderDialInNumbersForm() }
|
||||
<ShareLinkForm toCopy = { conferenceUrl } />
|
||||
<DialInNumbersForm conferenceUrl = { conferenceUrl } />
|
||||
<PasswordContainer
|
||||
conference = { _conference.conference }
|
||||
locked = { _conference.locked }
|
||||
|
@ -91,22 +86,6 @@ class InviteDialog extends Component {
|
|||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a React {@code Component} for displaying and copying to clipboard
|
||||
* telephone numbers for dialing in to the conference.
|
||||
*
|
||||
* @private
|
||||
* @returns {ReactElement|null}
|
||||
*/
|
||||
_renderDialInNumbersForm() {
|
||||
return (
|
||||
this.props.dialInNumbersUrl
|
||||
? <DialInNumbersForm
|
||||
dialInNumbersUrl = { this.props.dialInNumbersUrl } />
|
||||
: null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,7 +4,6 @@ import {
|
|||
|
||||
import {
|
||||
UPDATE_DIAL_IN_NUMBERS_FAILED,
|
||||
UPDATE_DIAL_IN_NUMBERS_REQUEST,
|
||||
UPDATE_DIAL_IN_NUMBERS_SUCCESS
|
||||
} from './actionTypes';
|
||||
|
||||
|
@ -19,24 +18,16 @@ ReducerRegistry.register(
|
|||
case UPDATE_DIAL_IN_NUMBERS_FAILED: {
|
||||
return {
|
||||
...state,
|
||||
error: action.error,
|
||||
loading: false
|
||||
error: action.error
|
||||
};
|
||||
}
|
||||
|
||||
case UPDATE_DIAL_IN_NUMBERS_REQUEST: {
|
||||
return {
|
||||
...state,
|
||||
error: null,
|
||||
loading: true
|
||||
};
|
||||
}
|
||||
case UPDATE_DIAL_IN_NUMBERS_SUCCESS: {
|
||||
const { numbers, numbersEnabled } = action.response;
|
||||
const { numbers, numbersEnabled } = action.dialInNumbers;
|
||||
|
||||
return {
|
||||
conferenceId: action.conferenceId.id,
|
||||
error: null,
|
||||
loading: false,
|
||||
numbers,
|
||||
numbersEnabled
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue