2022-07-18 13:16:08 +00:00
|
|
|
/* eslint-disable lines-around-comment */
|
2022-06-23 07:40:11 +00:00
|
|
|
import React, { PureComponent } from 'react';
|
2022-08-08 09:36:06 +00:00
|
|
|
import { WithTranslation } from 'react-i18next';
|
2022-06-23 07:40:11 +00:00
|
|
|
import { Text, View } from 'react-native';
|
|
|
|
|
2022-09-05 11:24:13 +00:00
|
|
|
import { IState } from '../../../app/types';
|
2022-06-23 07:40:11 +00:00
|
|
|
// @ts-ignore
|
|
|
|
import { Avatar } from '../../../base/avatar';
|
|
|
|
// @ts-ignore
|
|
|
|
import { BottomSheet, hideSheet } from '../../../base/dialog';
|
2022-07-18 13:16:08 +00:00
|
|
|
// @ts-ignore
|
2022-07-11 12:30:37 +00:00
|
|
|
import { bottomSheetStyles } from '../../../base/dialog/components/native/styles';
|
2022-08-08 09:36:06 +00:00
|
|
|
import { translate } from '../../../base/i18n/functions';
|
2022-07-18 13:16:08 +00:00
|
|
|
import { connect } from '../../../base/redux/functions';
|
|
|
|
// @ts-ignore
|
2022-06-23 07:40:11 +00:00
|
|
|
import { getBreakoutRooms } from '../../../breakout-rooms/functions';
|
2022-07-18 13:16:08 +00:00
|
|
|
// @ts-ignore
|
2022-06-23 07:40:11 +00:00
|
|
|
import SendToBreakoutRoom from '../../../video-menu/components/native/SendToBreakoutRoom';
|
2022-07-18 13:16:08 +00:00
|
|
|
// @ts-ignore
|
2022-06-23 07:40:11 +00:00
|
|
|
import styles from '../../../video-menu/components/native/styles';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Size of the rendered avatar in the menu.
|
|
|
|
*/
|
|
|
|
const AVATAR_SIZE = 24;
|
|
|
|
|
2022-08-08 09:36:06 +00:00
|
|
|
interface Props extends WithTranslation {
|
2022-06-23 07:40:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The list of all breakout rooms.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
_rooms: Array<any>;
|
2022-06-23 07:40:11 +00:00
|
|
|
|
|
|
|
/**
|
2022-07-20 08:47:01 +00:00
|
|
|
* The Redux dispatch function.
|
2022-06-23 07:40:11 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
dispatch: Function;
|
2022-06-23 07:40:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The jid of the selected participant.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
participantJid: string;
|
2022-06-23 07:40:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The display name of the selected participant.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
participantName: string;
|
2022-06-23 07:40:11 +00:00
|
|
|
|
|
|
|
/**
|
2022-07-20 08:47:01 +00:00
|
|
|
* The room the participant is in.
|
2022-06-23 07:40:11 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
room: any;
|
2022-06-23 07:40:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class to implement a popup menu that opens upon long pressing a thumbnail.
|
|
|
|
*/
|
|
|
|
class RoomParticipantMenu extends PureComponent<Props> {
|
|
|
|
/**
|
|
|
|
* Constructor of the component.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
constructor(props: Props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this._onCancel = this._onCancel.bind(this);
|
|
|
|
this._renderMenuHeader = this._renderMenuHeader.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements {@code Component#render}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
const { _rooms, participantJid, room, t } = this.props;
|
|
|
|
const buttonProps = {
|
|
|
|
afterClick: this._onCancel,
|
|
|
|
showLabel: true,
|
|
|
|
participantID: participantJid,
|
|
|
|
styles: bottomSheetStyles.buttons
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<BottomSheet
|
|
|
|
renderHeader = { this._renderMenuHeader }
|
|
|
|
showSlidingView = { true }>
|
|
|
|
<View style = { styles.contextMenuItem }>
|
|
|
|
<Text style = { styles.contextMenuItemText }>
|
|
|
|
{t('breakoutRooms.actions.sendToBreakoutRoom')}
|
|
|
|
</Text>
|
|
|
|
</View>
|
|
|
|
{_rooms.map(r => room.id !== r.id && (<SendToBreakoutRoom
|
|
|
|
key = { r.id }
|
|
|
|
room = { r }
|
|
|
|
{ ...buttonProps } />))}
|
|
|
|
</BottomSheet>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback to hide the {@code RemoteVideoMenu}.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
_onCancel() {
|
|
|
|
this.props.dispatch(hideSheet());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function to render the menu's header.
|
|
|
|
*
|
|
|
|
* @returns {React$Element}
|
|
|
|
*/
|
|
|
|
_renderMenuHeader() {
|
|
|
|
const { participantName } = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<View
|
|
|
|
style = { [
|
|
|
|
bottomSheetStyles.sheet,
|
|
|
|
styles.participantNameContainer ] }>
|
|
|
|
<Avatar
|
|
|
|
displayName = { participantName }
|
|
|
|
size = { AVATAR_SIZE } />
|
|
|
|
<Text style = { styles.participantNameLabel }>
|
|
|
|
{ participantName }
|
|
|
|
</Text>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function that maps parts of Redux state tree into component props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - Redux state.
|
|
|
|
* @private
|
|
|
|
* @returns {Props}
|
|
|
|
*/
|
2022-09-05 11:24:13 +00:00
|
|
|
function _mapStateToProps(state: IState) {
|
2022-06-23 07:40:11 +00:00
|
|
|
return {
|
|
|
|
_rooms: Object.values(getBreakoutRooms(state))
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default translate(connect(_mapStateToProps)(RoomParticipantMenu));
|