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';
|
2019-03-19 15:42:25 +00:00
|
|
|
import type { Dispatch } from 'redux';
|
2017-09-20 20:38:07 +00:00
|
|
|
|
2019-04-02 13:16:52 +00:00
|
|
|
import { createToolbarEvent, sendAnalytics } from '../../../../analytics';
|
|
|
|
import { openDialog } from '../../../../base/dialog';
|
|
|
|
import { translate } from '../../../../base/i18n';
|
2019-08-30 16:39:06 +00:00
|
|
|
import { IconInfo } from '../../../../base/icons';
|
2019-04-02 13:16:52 +00:00
|
|
|
import { JitsiRecordingConstants } from '../../../../base/lib-jitsi-meet';
|
|
|
|
import { getParticipantCount } from '../../../../base/participants';
|
|
|
|
import { OverflowMenuItem } from '../../../../base/toolbox';
|
|
|
|
import { connect } from '../../../../base/redux';
|
|
|
|
import { getActiveSession } from '../../../../recording';
|
|
|
|
import { ToolbarButton } from '../../../../toolbox';
|
|
|
|
import { updateDialInNumbers } from '../../../actions';
|
|
|
|
|
|
|
|
import InfoDialog from './InfoDialog';
|
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,
|
|
|
|
|
|
|
|
/**
|
2020-02-25 15:09:52 +00:00
|
|
|
* True if the number of real participants in the call is less than 2. If in a lonely call, the
|
2018-06-21 17:38:53 +00:00
|
|
|
* {@code InfoDialog} will be automatically shown.
|
|
|
|
*/
|
2020-02-25 15:09:52 +00:00
|
|
|
_isLonelyCall: boolean,
|
2018-06-21 17:38:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not the toolbox, in which this component exists, is visible.
|
|
|
|
*/
|
|
|
|
_toolboxVisible: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoked to toggle display of the info dialog.
|
|
|
|
*/
|
2019-03-19 15:42:25 +00:00
|
|
|
dispatch: Dispatch<any>,
|
2018-06-21 17:38:53 +00:00
|
|
|
|
2019-03-05 14:26:45 +00:00
|
|
|
/**
|
|
|
|
* Whether to show the label or not.
|
|
|
|
*/
|
|
|
|
showLabel: boolean,
|
|
|
|
|
2018-06-21 17:38:53 +00:00
|
|
|
/**
|
|
|
|
* Invoked to obtain translated strings.
|
|
|
|
*/
|
|
|
|
t: Function
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} state of {@link InfoDialogButton}.
|
|
|
|
*/
|
|
|
|
type State = {
|
|
|
|
|
2018-10-29 02:10:55 +00:00
|
|
|
/**
|
|
|
|
* Cache the conference connection state to derive when transitioning from
|
|
|
|
* not joined to join, in order to auto-show the InfoDialog.
|
|
|
|
*/
|
|
|
|
hasConnectedToConference: boolean,
|
|
|
|
|
2018-06-21 17:38:53 +00:00
|
|
|
/**
|
|
|
|
* 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> {
|
2018-10-29 02:10:55 +00:00
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#getDerivedStateFromProps()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
static getDerivedStateFromProps(props, state) {
|
|
|
|
return {
|
|
|
|
hasConnectedToConference: props._isConferenceJoined,
|
|
|
|
showDialog: (props._toolboxVisible && state.showDialog)
|
|
|
|
|| (!state.hasConnectedToConference
|
|
|
|
&& props._isConferenceJoined
|
2020-02-25 15:09:52 +00:00
|
|
|
&& props._isLonelyCall
|
2018-10-29 02:10:55 +00:00
|
|
|
&& props._toolboxVisible
|
|
|
|
&& !props._disableAutoShow)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
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 = {
|
2018-10-29 02:10:55 +00:00
|
|
|
hasConnectedToConference: props._isConferenceJoined,
|
2018-04-04 15:58:54 +00:00
|
|
|
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);
|
2019-03-05 14:26:45 +00:00
|
|
|
this._onClickOverflowMenuButton
|
|
|
|
= this._onClickOverflowMenuButton.bind(this);
|
2017-09-29 20:27:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
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-09-20 20:38:07 +00:00
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
2019-03-05 14:26:45 +00:00
|
|
|
const { _dialIn, _liveStreamViewURL, showLabel, t } = this.props;
|
2018-04-09 05:03:26 +00:00
|
|
|
const { showDialog } = this.state;
|
|
|
|
|
2019-03-05 14:26:45 +00:00
|
|
|
if (showLabel) {
|
|
|
|
return (
|
|
|
|
<OverflowMenuItem
|
|
|
|
accessibilityLabel = { t('info.accessibilityLabel') }
|
|
|
|
icon = 'icon-info'
|
|
|
|
key = 'info-button'
|
|
|
|
onClick = { this._onClickOverflowMenuButton }
|
|
|
|
text = { t('info.label') } />
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-04-09 05:03:26 +00:00
|
|
|
return (
|
|
|
|
<div className = 'toolbox-button-wth-dialog'>
|
|
|
|
<InlineDialog
|
|
|
|
content = {
|
2018-04-20 17:28:16 +00:00
|
|
|
<InfoDialog
|
|
|
|
dialIn = { _dialIn }
|
2019-03-05 14:26:45 +00:00
|
|
|
isInlineDialog = { true }
|
2018-04-20 17:28:16 +00:00
|
|
|
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') }
|
2019-08-30 16:39:06 +00:00
|
|
|
icon = { IconInfo }
|
2018-04-09 05:03:26 +00:00
|
|
|
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
|
|
|
_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
|
|
|
}
|
|
|
|
|
2019-03-05 14:26:45 +00:00
|
|
|
_onClickOverflowMenuButton: () => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Opens the Info dialog.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onClickOverflowMenuButton() {
|
|
|
|
const { _dialIn, _liveStreamViewURL } = this.props;
|
|
|
|
|
|
|
|
this.props.dispatch(openDialog(InfoDialog, {
|
|
|
|
dialIn: _dialIn,
|
|
|
|
liveStreamViewURL: _liveStreamViewURL,
|
|
|
|
isInlineDialog: false
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
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,
|
2020-02-25 15:09:52 +00:00
|
|
|
* _isLonelyCall: boolean,
|
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);
|
2020-02-25 10:45:00 +00:00
|
|
|
const { iAmRecorder, iAmSipGateway } = state['features/base/config'];
|
2018-05-16 14:00:16 +00:00
|
|
|
|
2017-09-29 20:27:23 +00:00
|
|
|
return {
|
2018-04-20 17:28:16 +00:00
|
|
|
_dialIn: state['features/invite'],
|
2020-02-25 10:45:00 +00:00
|
|
|
_disableAutoShow: iAmRecorder || iAmSipGateway,
|
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,
|
2020-02-25 15:09:52 +00:00
|
|
|
_isLonelyCall: getParticipantCount(state) < 2,
|
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));
|