2020-05-20 08:25:31 +00:00
|
|
|
import React, { PureComponent } from 'react';
|
2022-08-08 09:36:06 +00:00
|
|
|
import { WithTranslation } from 'react-i18next';
|
2020-05-20 08:25:31 +00:00
|
|
|
|
2022-10-20 09:11:27 +00:00
|
|
|
import { IReduxState } from '../../../app/types';
|
2022-08-08 09:36:06 +00:00
|
|
|
import { translate } from '../../../base/i18n/functions';
|
2022-08-08 08:12:22 +00:00
|
|
|
import { isLocalParticipantModerator } from '../../../base/participants/functions';
|
2022-08-02 10:31:11 +00:00
|
|
|
import { connect } from '../../../base/redux/functions';
|
|
|
|
import Switch from '../../../base/ui/components/web/Switch';
|
2021-11-30 13:41:23 +00:00
|
|
|
import { isInBreakoutRoom } from '../../../breakout-rooms/functions';
|
2022-10-11 10:47:54 +00:00
|
|
|
// eslint-disable-next-line lines-around-comment
|
2022-08-02 10:31:11 +00:00
|
|
|
// @ts-ignore
|
2020-05-20 08:25:31 +00:00
|
|
|
import { toggleLobbyMode } from '../../actions';
|
|
|
|
|
2022-10-20 09:11:27 +00:00
|
|
|
interface IProps extends WithTranslation {
|
2020-05-20 08:25:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* True if lobby is currently enabled in the conference.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
_lobbyEnabled: boolean;
|
2020-05-20 08:25:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* True if the section should be visible.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
_visible: boolean;
|
2020-05-20 08:25:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The Redux Dispatch function.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
dispatch: Function;
|
2022-08-08 09:36:06 +00:00
|
|
|
}
|
2020-05-20 08:25:31 +00:00
|
|
|
|
|
|
|
type State = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* True if the lobby switch is toggled on.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
lobbyEnabled: boolean;
|
|
|
|
};
|
2020-05-20 08:25:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements a security feature section to control lobby mode.
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
class LobbySection extends PureComponent<IProps, State> {
|
2020-05-20 08:25:31 +00:00
|
|
|
/**
|
|
|
|
* Instantiates a new component.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
constructor(props: IProps) {
|
2020-05-20 08:25:31 +00:00
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
lobbyEnabled: props._lobbyEnabled
|
|
|
|
};
|
|
|
|
|
|
|
|
this._onToggleLobby = this._onToggleLobby.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-07-10 16:50:45 +00:00
|
|
|
* Implements React's {@link Component#getDerivedStateFromProps()}.
|
2020-05-20 08:25:31 +00:00
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
static getDerivedStateFromProps(props: IProps, state: State) {
|
2020-07-10 16:50:45 +00:00
|
|
|
if (props._lobbyEnabled !== state.lobbyEnabled) {
|
|
|
|
|
|
|
|
return {
|
|
|
|
lobbyEnabled: props._lobbyEnabled
|
|
|
|
};
|
2020-05-20 08:25:31 +00:00
|
|
|
}
|
2020-07-10 16:50:45 +00:00
|
|
|
|
|
|
|
return null;
|
2020-05-20 08:25:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements {@code PureComponent#render}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
const { _visible, t } = this.props;
|
|
|
|
|
|
|
|
if (!_visible) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2020-06-24 12:12:23 +00:00
|
|
|
<>
|
|
|
|
<div id = 'lobby-section'>
|
2021-06-10 12:48:44 +00:00
|
|
|
<p
|
|
|
|
className = 'description'
|
|
|
|
role = 'banner'>
|
2020-06-25 13:44:17 +00:00
|
|
|
{ t('lobby.enableDialogText') }
|
|
|
|
</p>
|
2020-06-24 12:12:23 +00:00
|
|
|
<div className = 'control-row'>
|
2021-01-14 16:12:08 +00:00
|
|
|
<label htmlFor = 'lobby-section-switch'>
|
2020-06-24 12:12:23 +00:00
|
|
|
{ t('lobby.toggleLabel') }
|
|
|
|
</label>
|
|
|
|
<Switch
|
2022-08-02 10:31:11 +00:00
|
|
|
checked = { this.state.lobbyEnabled }
|
2021-01-14 16:12:08 +00:00
|
|
|
id = 'lobby-section-switch'
|
2022-08-02 10:31:11 +00:00
|
|
|
onChange = { this._onToggleLobby } />
|
2020-06-24 12:12:23 +00:00
|
|
|
</div>
|
2020-05-20 08:25:31 +00:00
|
|
|
</div>
|
2020-06-24 12:12:23 +00:00
|
|
|
<div className = 'separator-line' />
|
|
|
|
</>
|
2020-05-20 08:25:31 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback to be invoked when the user toggles the lobby feature on or off.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onToggleLobby() {
|
|
|
|
const newValue = !this.state.lobbyEnabled;
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
lobbyEnabled: newValue
|
|
|
|
});
|
|
|
|
|
|
|
|
this.props.dispatch(toggleLobbyMode(newValue));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps part of the Redux state to the props of this component.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
2022-10-20 09:11:27 +00:00
|
|
|
* @returns {IProps}
|
2020-05-20 08:25:31 +00:00
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
function mapStateToProps(state: IReduxState): Partial<IProps> {
|
2020-05-20 08:25:31 +00:00
|
|
|
const { conference } = state['features/base/conference'];
|
2020-09-02 15:28:22 +00:00
|
|
|
const { hideLobbyButton } = state['features/base/config'];
|
2020-05-20 08:25:31 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
_lobbyEnabled: state['features/lobby'].lobbyEnabled,
|
2021-11-30 13:41:23 +00:00
|
|
|
_visible: conference?.isLobbySupported() && isLocalParticipantModerator(state)
|
|
|
|
&& !hideLobbyButton && !isInBreakoutRoom(state)
|
2020-05-20 08:25:31 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default translate(connect(mapStateToProps)(LobbySection));
|