2018-12-19 18:40:17 +00:00
|
|
|
// @flow
|
|
|
|
|
2020-09-16 15:13:15 +00:00
|
|
|
import React, { PureComponent } from 'react';
|
2018-12-19 18:40:17 +00:00
|
|
|
import { Text, View } from 'react-native';
|
2021-07-30 09:46:49 +00:00
|
|
|
import { Divider } from 'react-native-paper';
|
2018-12-19 18:40:17 +00:00
|
|
|
|
2019-06-26 14:08:23 +00:00
|
|
|
import { Avatar } from '../../../base/avatar';
|
2019-01-22 10:35:28 +00:00
|
|
|
import { ColorSchemeRegistry } from '../../../base/color-scheme';
|
2019-07-11 11:32:17 +00:00
|
|
|
import { BottomSheet, isDialogOpen } from '../../../base/dialog';
|
2020-10-06 18:40:44 +00:00
|
|
|
import { KICK_OUT_ENABLED, getFeatureFlag } from '../../../base/flags';
|
2021-09-14 15:31:30 +00:00
|
|
|
import { translate } from '../../../base/i18n';
|
2021-07-30 09:46:49 +00:00
|
|
|
import {
|
|
|
|
getParticipantById,
|
|
|
|
getParticipantDisplayName
|
|
|
|
} from '../../../base/participants';
|
2019-03-21 16:38:29 +00:00
|
|
|
import { connect } from '../../../base/redux';
|
2019-01-22 10:35:28 +00:00
|
|
|
import { StyleType } from '../../../base/styles';
|
2021-09-14 15:31:30 +00:00
|
|
|
import { getBreakoutRooms, getCurrentRoomId } from '../../../breakout-rooms/functions';
|
2021-11-18 14:50:38 +00:00
|
|
|
import PrivateMessageButton from '../../../chat/components/native/PrivateMessageButton';
|
2021-01-21 20:46:47 +00:00
|
|
|
import { hideRemoteVideoMenu } from '../../actions.native';
|
2021-07-30 09:46:49 +00:00
|
|
|
import ConnectionStatusButton from '../native/ConnectionStatusButton';
|
2018-12-19 18:40:17 +00:00
|
|
|
|
2021-09-22 14:05:42 +00:00
|
|
|
import AskUnmuteButton from './AskUnmuteButton';
|
2020-07-15 10:13:28 +00:00
|
|
|
import GrantModeratorButton from './GrantModeratorButton';
|
2018-12-19 18:40:17 +00:00
|
|
|
import KickButton from './KickButton';
|
|
|
|
import MuteButton from './MuteButton';
|
2020-11-10 14:49:38 +00:00
|
|
|
import MuteEveryoneElseButton from './MuteEveryoneElseButton';
|
2021-07-30 09:46:49 +00:00
|
|
|
import MuteVideoButton from './MuteVideoButton';
|
2019-06-19 13:32:09 +00:00
|
|
|
import PinButton from './PinButton';
|
2021-09-14 15:31:30 +00:00
|
|
|
import SendToBreakoutRoom from './SendToBreakoutRoom';
|
2018-12-19 18:40:17 +00:00
|
|
|
import styles from './styles';
|
|
|
|
|
2021-07-30 09:46:49 +00:00
|
|
|
// import VolumeSlider from './VolumeSlider';
|
|
|
|
|
|
|
|
|
2018-12-21 09:53:24 +00:00
|
|
|
/**
|
|
|
|
* Size of the rendered avatar in the menu.
|
|
|
|
*/
|
2021-07-30 09:46:49 +00:00
|
|
|
const AVATAR_SIZE = 24;
|
2018-12-21 09:53:24 +00:00
|
|
|
|
2018-12-19 18:40:17 +00:00
|
|
|
type Props = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Redux dispatch function.
|
|
|
|
*/
|
|
|
|
dispatch: Function,
|
|
|
|
|
|
|
|
/**
|
2021-08-20 23:32:38 +00:00
|
|
|
* The ID of the participant for which this menu opened for.
|
2018-12-19 18:40:17 +00:00
|
|
|
*/
|
2021-08-20 23:32:38 +00:00
|
|
|
participantId: String,
|
2018-12-19 18:40:17 +00:00
|
|
|
|
2019-01-22 10:35:28 +00:00
|
|
|
/**
|
|
|
|
* The color-schemed stylesheet of the BottomSheet.
|
|
|
|
*/
|
|
|
|
_bottomSheetStyles: StyleType,
|
|
|
|
|
2021-09-14 15:31:30 +00:00
|
|
|
/**
|
|
|
|
* The id of the current room.
|
|
|
|
*/
|
|
|
|
_currentRoomId: String,
|
|
|
|
|
2020-03-25 21:28:31 +00:00
|
|
|
/**
|
|
|
|
* Whether or not to display the kick button.
|
|
|
|
*/
|
|
|
|
_disableKick: boolean,
|
|
|
|
|
2022-03-14 14:46:19 +00:00
|
|
|
/**
|
|
|
|
* Whether or not to display the send private message button.
|
|
|
|
*/
|
|
|
|
_disablePrivateChat: Boolean,
|
|
|
|
|
2020-03-25 21:28:31 +00:00
|
|
|
/**
|
|
|
|
* Whether or not to display the remote mute buttons.
|
|
|
|
*/
|
|
|
|
_disableRemoteMute: boolean,
|
|
|
|
|
2021-04-30 16:22:36 +00:00
|
|
|
/**
|
|
|
|
* Whether or not to display the grant moderator button.
|
|
|
|
*/
|
|
|
|
_disableGrantModerator: Boolean,
|
|
|
|
|
2019-07-11 11:32:17 +00:00
|
|
|
/**
|
|
|
|
* True if the menu is currently open, false otherwise.
|
|
|
|
*/
|
|
|
|
_isOpen: boolean,
|
|
|
|
|
2021-07-30 09:46:49 +00:00
|
|
|
/**
|
|
|
|
* Whether the participant is present in the room or not.
|
|
|
|
*/
|
|
|
|
_isParticipantAvailable?: boolean,
|
|
|
|
|
2018-12-19 18:40:17 +00:00
|
|
|
/**
|
2021-03-16 15:59:33 +00:00
|
|
|
* Display name of the participant retrieved from Redux.
|
2018-12-19 18:40:17 +00:00
|
|
|
*/
|
2021-09-14 15:31:30 +00:00
|
|
|
_participantDisplayName: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Array containing the breakout rooms.
|
|
|
|
*/
|
|
|
|
_rooms: Array<Object>,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Translation function.
|
|
|
|
*/
|
|
|
|
t: Function
|
2018-12-19 18:40:17 +00:00
|
|
|
}
|
|
|
|
|
2019-07-11 11:32:17 +00:00
|
|
|
// eslint-disable-next-line prefer-const
|
|
|
|
let RemoteVideoMenu_;
|
|
|
|
|
2018-12-19 18:40:17 +00:00
|
|
|
/**
|
|
|
|
* Class to implement a popup menu that opens upon long pressing a thumbnail.
|
|
|
|
*/
|
2020-09-16 15:13:15 +00:00
|
|
|
class RemoteVideoMenu extends PureComponent<Props> {
|
2018-12-19 18:40:17 +00:00
|
|
|
/**
|
|
|
|
* Constructor of the component.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
constructor(props: Props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this._onCancel = this._onCancel.bind(this);
|
2020-09-16 15:13:15 +00:00
|
|
|
this._renderMenuHeader = this._renderMenuHeader.bind(this);
|
2018-12-19 18:40:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements {@code Component#render}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
render() {
|
2021-07-30 09:46:49 +00:00
|
|
|
const {
|
|
|
|
_disableKick,
|
2022-03-14 14:46:19 +00:00
|
|
|
_disablePrivateChat,
|
2021-07-30 09:46:49 +00:00
|
|
|
_disableRemoteMute,
|
|
|
|
_disableGrantModerator,
|
|
|
|
_isParticipantAvailable,
|
2021-09-14 15:31:30 +00:00
|
|
|
_rooms,
|
|
|
|
_currentRoomId,
|
|
|
|
participantId,
|
|
|
|
t
|
2021-07-30 09:46:49 +00:00
|
|
|
} = this.props;
|
2018-12-19 18:40:17 +00:00
|
|
|
const buttonProps = {
|
|
|
|
afterClick: this._onCancel,
|
|
|
|
showLabel: true,
|
2021-08-20 23:32:38 +00:00
|
|
|
participantID: participantId,
|
2019-11-25 12:01:54 +00:00
|
|
|
styles: this.props._bottomSheetStyles.buttons
|
2018-12-19 18:40:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
2020-09-16 15:13:15 +00:00
|
|
|
<BottomSheet
|
|
|
|
onCancel = { this._onCancel }
|
2021-07-30 09:46:49 +00:00
|
|
|
renderHeader = { this._renderMenuHeader }
|
|
|
|
showSlidingView = { _isParticipantAvailable }>
|
2021-09-22 14:05:42 +00:00
|
|
|
<AskUnmuteButton { ...buttonProps } />
|
2020-09-16 15:13:15 +00:00
|
|
|
{ !_disableRemoteMute && <MuteButton { ...buttonProps } /> }
|
2021-07-30 09:46:49 +00:00
|
|
|
<MuteEveryoneElseButton { ...buttonProps } />
|
|
|
|
{ !_disableRemoteMute && <MuteVideoButton { ...buttonProps } /> }
|
|
|
|
<Divider style = { styles.divider } />
|
2020-09-16 15:13:15 +00:00
|
|
|
{ !_disableKick && <KickButton { ...buttonProps } /> }
|
2021-04-30 16:22:36 +00:00
|
|
|
{ !_disableGrantModerator && <GrantModeratorButton { ...buttonProps } /> }
|
2020-09-16 15:13:15 +00:00
|
|
|
<PinButton { ...buttonProps } />
|
2022-03-14 14:46:19 +00:00
|
|
|
{ !_disablePrivateChat && <PrivateMessageButton { ...buttonProps } /> }
|
2020-12-22 09:12:52 +00:00
|
|
|
<ConnectionStatusButton { ...buttonProps } />
|
2021-09-14 15:31:30 +00:00
|
|
|
{_rooms.length > 1 && <>
|
|
|
|
<Divider style = { styles.divider } />
|
|
|
|
<View style = { styles.contextMenuItem }>
|
|
|
|
<Text style = { styles.contextMenuItemText }>
|
|
|
|
{t('breakoutRooms.actions.sendToBreakoutRoom')}
|
|
|
|
</Text>
|
|
|
|
</View>
|
|
|
|
{_rooms.map(room => _currentRoomId !== room.id && (<SendToBreakoutRoom
|
|
|
|
key = { room.id }
|
|
|
|
room = { room }
|
|
|
|
{ ...buttonProps } />))}
|
|
|
|
</>}
|
2021-08-20 23:32:38 +00:00
|
|
|
{/* <VolumeSlider participantID = { participantId } />*/}
|
2018-12-19 18:40:17 +00:00
|
|
|
</BottomSheet>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-07-11 11:32:17 +00:00
|
|
|
_onCancel: () => boolean;
|
2018-12-19 18:40:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback to hide the {@code RemoteVideoMenu}.
|
|
|
|
*
|
|
|
|
* @private
|
2019-07-11 11:32:17 +00:00
|
|
|
* @returns {boolean}
|
2018-12-19 18:40:17 +00:00
|
|
|
*/
|
|
|
|
_onCancel() {
|
2019-07-11 11:32:17 +00:00
|
|
|
if (this.props._isOpen) {
|
|
|
|
this.props.dispatch(hideRemoteVideoMenu());
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2018-12-19 18:40:17 +00:00
|
|
|
}
|
2020-09-16 15:13:15 +00:00
|
|
|
|
|
|
|
_renderMenuHeader: () => React$Element<any>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function to render the menu's header.
|
|
|
|
*
|
|
|
|
* @returns {React$Element}
|
|
|
|
*/
|
|
|
|
_renderMenuHeader() {
|
2021-08-20 23:32:38 +00:00
|
|
|
const { _bottomSheetStyles, participantId } = this.props;
|
2020-09-16 15:13:15 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<View
|
|
|
|
style = { [
|
|
|
|
_bottomSheetStyles.sheet,
|
|
|
|
styles.participantNameContainer ] }>
|
|
|
|
<Avatar
|
2021-08-20 23:32:38 +00:00
|
|
|
participantId = { participantId }
|
2020-09-16 15:13:15 +00:00
|
|
|
size = { AVATAR_SIZE } />
|
|
|
|
<Text style = { styles.participantNameLabel }>
|
|
|
|
{ this.props._participantDisplayName }
|
|
|
|
</Text>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
2018-12-19 18:40:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function that maps parts of Redux state tree into component props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - Redux state.
|
|
|
|
* @param {Object} ownProps - Properties of component.
|
|
|
|
* @private
|
2019-07-11 11:32:17 +00:00
|
|
|
* @returns {Props}
|
2018-12-19 18:40:17 +00:00
|
|
|
*/
|
|
|
|
function _mapStateToProps(state, ownProps) {
|
2020-10-06 18:40:44 +00:00
|
|
|
const kickOutEnabled = getFeatureFlag(state, KICK_OUT_ENABLED, true);
|
2021-08-20 23:32:38 +00:00
|
|
|
const { participantId } = ownProps;
|
2020-03-25 21:28:31 +00:00
|
|
|
const { remoteVideoMenu = {}, disableRemoteMute } = state['features/base/config'];
|
2021-08-20 23:32:38 +00:00
|
|
|
const isParticipantAvailable = getParticipantById(state, participantId);
|
2022-03-14 14:46:19 +00:00
|
|
|
const { disableKick, disablePrivateChat } = remoteVideoMenu;
|
2021-09-14 15:31:30 +00:00
|
|
|
const _rooms = Object.values(getBreakoutRooms(state));
|
|
|
|
const _currentRoomId = getCurrentRoomId(state);
|
2022-03-14 14:46:19 +00:00
|
|
|
const shouldDisableKick = disableKick || !kickOutEnabled;
|
2018-12-19 18:40:17 +00:00
|
|
|
|
|
|
|
return {
|
2020-03-25 21:28:31 +00:00
|
|
|
_bottomSheetStyles: ColorSchemeRegistry.get(state, 'BottomSheet'),
|
2021-09-14 15:31:30 +00:00
|
|
|
_currentRoomId,
|
2022-03-14 14:46:19 +00:00
|
|
|
_disableKick: Boolean(shouldDisableKick),
|
2020-03-25 21:28:31 +00:00
|
|
|
_disableRemoteMute: Boolean(disableRemoteMute),
|
2022-03-14 14:46:19 +00:00
|
|
|
_disablePrivateChat: Boolean(disablePrivateChat),
|
2019-07-11 11:32:17 +00:00
|
|
|
_isOpen: isDialogOpen(state, RemoteVideoMenu_),
|
2021-07-30 09:46:49 +00:00
|
|
|
_isParticipantAvailable: Boolean(isParticipantAvailable),
|
2021-09-14 15:31:30 +00:00
|
|
|
_participantDisplayName: getParticipantDisplayName(state, participantId),
|
|
|
|
_rooms
|
2018-12-19 18:40:17 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-09-14 15:31:30 +00:00
|
|
|
RemoteVideoMenu_ = translate(connect(_mapStateToProps)(RemoteVideoMenu));
|
2019-07-11 11:32:17 +00:00
|
|
|
|
|
|
|
export default RemoteVideoMenu_;
|