2017-09-29 20:27:23 +00:00
|
|
|
import InlineDialog from '@atlaskit/inline-dialog';
|
|
|
|
import PropTypes from 'prop-types';
|
2017-09-20 20:38:07 +00:00
|
|
|
import React, { Component } from 'react';
|
2017-09-29 20:27:23 +00:00
|
|
|
import { connect } from 'react-redux';
|
2017-09-20 20:38:07 +00:00
|
|
|
|
2018-03-07 00:28:19 +00:00
|
|
|
import { createToolbarEvent, sendAnalytics } from '../../analytics';
|
|
|
|
import { translate } from '../../base/i18n';
|
2018-05-16 14:00:16 +00:00
|
|
|
import { JitsiRecordingConstants } from '../../base/lib-jitsi-meet';
|
2018-04-04 15:58:54 +00:00
|
|
|
import { getParticipantCount } from '../../base/participants';
|
2018-05-16 14:00:16 +00:00
|
|
|
import { getActiveSession } from '../../recording';
|
2018-04-10 03:27:19 +00:00
|
|
|
import { ToolbarButton } from '../../toolbox';
|
2017-09-29 20:27:23 +00:00
|
|
|
|
2018-04-04 15:58:54 +00:00
|
|
|
import { updateDialInNumbers } from '../actions';
|
2017-09-20 20:38:07 +00:00
|
|
|
|
2018-04-04 15:58:54 +00:00
|
|
|
import { InfoDialog } from './info-dialog';
|
2017-09-29 20:27:23 +00:00
|
|
|
|
2018-04-04 15:58:54 +00:00
|
|
|
/**
|
|
|
|
* The amount of time, in milliseconds, to wait until automatically showing
|
|
|
|
* the {@code InfoDialog}. This is essentially a hack as automatic showing
|
|
|
|
* should happen in a lonely call and some time is needed to populate
|
|
|
|
* participants already in the call.
|
|
|
|
*/
|
|
|
|
const INFO_DIALOG_AUTO_SHOW_TIMEOUT = 1500;
|
|
|
|
|
2017-09-20 20:38:07 +00:00
|
|
|
/**
|
|
|
|
* A React Component for displaying a button which opens a dialog with
|
|
|
|
* information about the conference and with ways to invite people.
|
|
|
|
*
|
|
|
|
* @extends Component
|
|
|
|
*/
|
|
|
|
class InfoDialogButton extends Component {
|
2017-09-29 20:27:23 +00:00
|
|
|
/**
|
|
|
|
* {@code InfoDialogButton} component's property types.
|
|
|
|
*
|
|
|
|
* @static
|
|
|
|
*/
|
|
|
|
static propTypes = {
|
2018-03-07 00:28:19 +00:00
|
|
|
|
|
|
|
/**
|
2018-04-20 17:28:16 +00:00
|
|
|
* The redux state representing the dial-in numbers feature.
|
2018-03-07 00:28:19 +00:00
|
|
|
*/
|
2018-04-20 17:28:16 +00:00
|
|
|
_dialIn: PropTypes.object,
|
2018-03-07 00:28:19 +00:00
|
|
|
|
2017-10-11 17:27:56 +00:00
|
|
|
/**
|
2018-04-04 15:58:54 +00:00
|
|
|
* Whether or not the {@code InfoDialog} should display automatically
|
|
|
|
* after {@link INFO_DIALOG_AUTO_SHOW_TIMEOUT}.
|
2017-10-11 17:27:56 +00:00
|
|
|
*/
|
2018-04-04 15:58:54 +00:00
|
|
|
_disableAutoShow: PropTypes.bool,
|
2017-10-11 17:27:56 +00:00
|
|
|
|
2018-04-20 17:28:16 +00:00
|
|
|
/**
|
|
|
|
* The URL for a currently active live broadcast
|
|
|
|
*/
|
|
|
|
_liveStreamViewURL: PropTypes.string,
|
|
|
|
|
2017-09-29 20:27:23 +00:00
|
|
|
/**
|
2018-04-04 15:58:54 +00:00
|
|
|
* The number of real participants in the call. If in a lonely call,
|
|
|
|
* the {@code InfoDialog} will be automatically shown.
|
2017-09-29 20:27:23 +00:00
|
|
|
*/
|
2018-04-04 15:58:54 +00:00
|
|
|
_participantCount: PropTypes.number,
|
2017-09-29 20:27:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not the toolbox, in which this component exists, are
|
|
|
|
* visible.
|
|
|
|
*/
|
|
|
|
_toolboxVisible: PropTypes.bool,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoked to toggle display of the info dialog
|
|
|
|
*/
|
|
|
|
dispatch: PropTypes.func,
|
|
|
|
|
2018-03-07 00:28:19 +00:00
|
|
|
/**
|
|
|
|
* Invoked to obtain translated strings.
|
|
|
|
*/
|
|
|
|
t: PropTypes.func,
|
|
|
|
|
2017-09-29 20:27:23 +00:00
|
|
|
/**
|
|
|
|
* From which side tooltips should display. Will be re-used for
|
|
|
|
* displaying the inline dialog for video quality adjustment.
|
|
|
|
*/
|
|
|
|
tooltipPosition: PropTypes.string
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2018-04-10 03:07:06 +00:00
|
|
|
* Initializes new {@code InfoDialogButton} instance.
|
2017-09-29 20:27:23 +00:00
|
|
|
*
|
|
|
|
* @param {Object} props - The read-only properties with which the new
|
|
|
|
* instance is to be initialized.
|
|
|
|
*/
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
/**
|
2018-04-04 15:58:54 +00:00
|
|
|
* The timeout to automatically show the {@code InfoDialog} if it has
|
|
|
|
* not been shown yet in a lonely call.
|
2017-09-29 20:27:23 +00:00
|
|
|
*
|
|
|
|
* @type {timeoutID}
|
|
|
|
*/
|
2018-04-04 15:58:54 +00:00
|
|
|
this._autoShowTimeout = null;
|
|
|
|
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
/**
|
|
|
|
* Whether or not {@code InfoDialog} should be visible.
|
|
|
|
*/
|
|
|
|
showDialog: false
|
|
|
|
};
|
2017-09-29 20:27:23 +00:00
|
|
|
|
|
|
|
// Bind event handlers so they are only bound once for every instance.
|
|
|
|
this._onDialogClose = this._onDialogClose.bind(this);
|
|
|
|
this._onDialogToggle = this._onDialogToggle.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a timeout to automatically hide the {@code InfoDialog}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
componentDidMount() {
|
2018-04-04 15:58:54 +00:00
|
|
|
this._autoShowTimeout = setTimeout(() => {
|
|
|
|
this._maybeAutoShowDialog();
|
|
|
|
}, INFO_DIALOG_AUTO_SHOW_TIMEOUT);
|
2018-03-07 00:28:19 +00:00
|
|
|
|
2018-04-20 17:28:16 +00:00
|
|
|
if (!this.props._dialIn.numbers) {
|
2018-03-07 00:28:19 +00:00
|
|
|
this.props.dispatch(updateDialInNumbers());
|
|
|
|
}
|
2017-09-29 20:27:23 +00:00
|
|
|
}
|
|
|
|
|
2017-10-11 17:27:56 +00:00
|
|
|
/**
|
|
|
|
* Update the visibility of the {@code InfoDialog}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
componentWillReceiveProps(nextProps) {
|
|
|
|
// Ensure the dialog is closed when the toolbox becomes hidden.
|
2018-04-04 15:58:54 +00:00
|
|
|
if (this.state.showDialog && !nextProps._toolboxVisible) {
|
2017-09-29 20:27:23 +00:00
|
|
|
this._onDialogClose();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clear the timeout to automatically show the {@code InfoDialog}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
componentWillUnmount() {
|
2018-04-04 15:58:54 +00:00
|
|
|
clearTimeout(this._autoShowTimeout);
|
2017-09-29 20:27:23 +00:00
|
|
|
}
|
|
|
|
|
2017-09-20 20:38:07 +00:00
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
2018-04-20 17:28:16 +00:00
|
|
|
const { _dialIn, _liveStreamViewURL, t } = this.props;
|
2018-04-09 05:03:26 +00:00
|
|
|
const { showDialog } = this.state;
|
|
|
|
const iconClass = `icon-info ${showDialog ? 'toggled' : ''}`;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className = 'toolbox-button-wth-dialog'>
|
|
|
|
<InlineDialog
|
|
|
|
content = {
|
2018-04-20 17:28:16 +00:00
|
|
|
<InfoDialog
|
|
|
|
dialIn = { _dialIn }
|
|
|
|
liveStreamViewURL = { _liveStreamViewURL }
|
|
|
|
onClose = { this._onDialogClose } /> }
|
2018-04-09 05:03:26 +00:00
|
|
|
isOpen = { showDialog }
|
|
|
|
onClose = { this._onDialogClose }
|
|
|
|
position = { 'top right' }>
|
2018-04-10 03:27:19 +00:00
|
|
|
<ToolbarButton
|
2018-06-07 20:32:18 +00:00
|
|
|
accessibilityLabel = { t('info.accessibilityLabel') }
|
2018-04-09 05:03:26 +00:00
|
|
|
iconName = { iconClass }
|
|
|
|
onClick = { this._onDialogToggle }
|
|
|
|
tooltip = { t('info.tooltip') } />
|
|
|
|
</InlineDialog>
|
|
|
|
</div>
|
|
|
|
);
|
2017-09-20 20:38:07 +00:00
|
|
|
}
|
2017-09-29 20:27:23 +00:00
|
|
|
|
|
|
|
/**
|
2018-04-04 15:58:54 +00:00
|
|
|
* Callback invoked after a timeout to trigger display of the
|
|
|
|
* {@code InfoDialog} if certain conditions are met.
|
2017-09-29 20:27:23 +00:00
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2018-04-04 15:58:54 +00:00
|
|
|
_maybeAutoShowDialog() {
|
|
|
|
if (this.props._participantCount < 2 && !this.props._disableAutoShow) {
|
|
|
|
this.setState({ showDialog: true });
|
|
|
|
}
|
2017-09-29 20:27:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hides {@code InfoDialog}.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onDialogClose() {
|
2018-04-04 15:58:54 +00:00
|
|
|
this.setState({ showDialog: false });
|
2017-09-29 20:27:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Toggles the display of {@code InfoDialog}.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onDialogToggle() {
|
2018-03-07 00:28:19 +00:00
|
|
|
sendAnalytics(createToolbarEvent('info'));
|
|
|
|
|
2018-04-04 15:58:54 +00:00
|
|
|
this.setState({ showDialog: !this.state.showDialog });
|
2017-09-29 20:27:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps (parts of) the Redux state to the associated {@code InfoDialogButton}
|
|
|
|
* component's props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @private
|
|
|
|
* @returns {{
|
2018-04-20 17:28:16 +00:00
|
|
|
* _dialIn: Object,
|
|
|
|
* _disableAutoShow: boolean,
|
|
|
|
* _liveStreamViewURL: string,
|
2018-04-04 15:58:54 +00:00
|
|
|
* _participantCount: number,
|
2017-09-29 20:27:23 +00:00
|
|
|
* _toolboxVisible: boolean
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
function _mapStateToProps(state) {
|
2018-05-16 14:00:16 +00:00
|
|
|
const currentLiveStreamingSession
|
|
|
|
= getActiveSession(state, JitsiRecordingConstants.mode.STREAM);
|
|
|
|
|
2017-09-29 20:27:23 +00:00
|
|
|
return {
|
2018-04-20 17:28:16 +00:00
|
|
|
_dialIn: state['features/invite'],
|
2018-04-04 15:58:54 +00:00
|
|
|
_disableAutoShow: state['features/base/config'].iAmRecorder,
|
2018-05-22 22:41:53 +00:00
|
|
|
_liveStreamViewURL:
|
|
|
|
currentLiveStreamingSession
|
|
|
|
&& currentLiveStreamingSession.liveStreamViewURL,
|
|
|
|
_participantCount: getParticipantCount(state),
|
2017-09-29 20:27:23 +00:00
|
|
|
_toolboxVisible: state['features/toolbox'].visible
|
|
|
|
};
|
2017-09-20 20:38:07 +00:00
|
|
|
}
|
|
|
|
|
2018-03-07 00:28:19 +00:00
|
|
|
export default translate(connect(_mapStateToProps)(InfoDialogButton));
|