2018-06-21 17:38:53 +00:00
|
|
|
// @flow
|
|
|
|
|
2017-09-29 20:27:23 +00:00
|
|
|
import InlineDialog from '@atlaskit/inline-dialog';
|
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
|
|
|
/**
|
2018-06-21 17:38:53 +00:00
|
|
|
* The type of the React {@code Component} props of {@link InfoDialogButton}.
|
2018-04-04 15:58:54 +00:00
|
|
|
*/
|
2018-06-21 17:38:53 +00:00
|
|
|
type Props = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The redux state representing the dial-in numbers feature.
|
|
|
|
*/
|
|
|
|
_dialIn: Object,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not the {@code InfoDialog} should display automatically when
|
|
|
|
* in a lonely call.
|
|
|
|
*/
|
|
|
|
_disableAutoShow: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not the local participant has joined a
|
|
|
|
* {@code JitsiConference}. Used to trigger auto showing of the
|
|
|
|
* {@code InfoDialog}.
|
|
|
|
*/
|
|
|
|
_isConferenceJoined: Boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The URL for a currently active live broadcast
|
|
|
|
*/
|
|
|
|
_liveStreamViewURL: ?string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The number of real participants in the call. If in a lonely call, the
|
|
|
|
* {@code InfoDialog} will be automatically shown.
|
|
|
|
*/
|
|
|
|
_participantCount: number,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not the toolbox, in which this component exists, is visible.
|
|
|
|
*/
|
|
|
|
_toolboxVisible: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoked to toggle display of the info dialog.
|
|
|
|
*/
|
|
|
|
dispatch: Dispatch<*>,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoked to obtain translated strings.
|
|
|
|
*/
|
|
|
|
t: Function
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} state of {@link InfoDialogButton}.
|
|
|
|
*/
|
|
|
|
type State = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not {@code InfoDialog} should be visible.
|
|
|
|
*/
|
|
|
|
showDialog: boolean
|
|
|
|
};
|
2018-04-04 15:58:54 +00:00
|
|
|
|
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
|
|
|
|
*/
|
2018-06-21 17:38:53 +00:00
|
|
|
class InfoDialogButton extends Component<Props, State> {
|
2017-09-29 20:27:23 +00:00
|
|
|
/**
|
2018-04-10 03:07:06 +00:00
|
|
|
* Initializes new {@code InfoDialogButton} instance.
|
2017-09-29 20:27:23 +00:00
|
|
|
*
|
2018-06-21 17:38:53 +00:00
|
|
|
* @inheritdoc
|
2017-09-29 20:27:23 +00:00
|
|
|
*/
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
2018-04-04 15:58:54 +00:00
|
|
|
this.state = {
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-06-21 17:38:53 +00:00
|
|
|
* Update dial-in numbers {@code InfoDialog}.
|
2017-09-29 20:27:23 +00:00
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
componentDidMount() {
|
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();
|
2018-06-21 17:38:53 +00:00
|
|
|
|
|
|
|
return;
|
2017-09-29 20:27:23 +00:00
|
|
|
}
|
|
|
|
|
2018-06-21 17:38:53 +00:00
|
|
|
this._maybeAutoShowDialog(nextProps);
|
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-06-21 17:38:53 +00:00
|
|
|
* Invoked to trigger display of the {@code InfoDialog} if certain
|
|
|
|
* conditions are met.
|
2017-09-29 20:27:23 +00:00
|
|
|
*
|
2018-06-21 17:38:53 +00:00
|
|
|
* @param {Object} nextProps - The future properties of this component.
|
2017-09-29 20:27:23 +00:00
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2018-06-21 17:38:53 +00:00
|
|
|
_maybeAutoShowDialog(nextProps) {
|
|
|
|
if (!this.props._isConferenceJoined
|
|
|
|
&& nextProps._isConferenceJoined
|
|
|
|
&& nextProps._participantCount < 2
|
|
|
|
&& nextProps._toolboxVisible
|
|
|
|
&& !nextProps._disableAutoShow) {
|
2018-04-04 15:58:54 +00:00
|
|
|
this.setState({ showDialog: true });
|
|
|
|
}
|
2017-09-29 20:27:23 +00:00
|
|
|
}
|
|
|
|
|
2018-06-21 17:38:53 +00:00
|
|
|
_onDialogClose: () => void;
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-06-21 17:38:53 +00:00
|
|
|
_onDialogToggle: () => void;
|
|
|
|
|
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,
|
2018-06-21 17:38:53 +00:00
|
|
|
* _isConferenceIsJoined: boolean,
|
2018-04-20 17:28:16 +00:00
|
|
|
* _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-06-21 17:38:53 +00:00
|
|
|
_isConferenceJoined:
|
|
|
|
Boolean(state['features/base/conference'].conference),
|
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));
|