feat: private message interface config flag

This commit is contained in:
Bettenbuk Zoltan 2019-11-08 14:40:20 +01:00 committed by Zoltan Bettenbuk
parent 50f4796144
commit 53f01a39c9
2 changed files with 37 additions and 2 deletions

View File

@ -22,6 +22,7 @@ export default [
'DEFAULT_REMOTE_DISPLAY_NAME',
'DISABLE_DOMINANT_SPEAKER_INDICATOR',
'DISABLE_FOCUS_INDICATOR',
'DISABLE_PRIVATE_MESSAGES',
'DISABLE_RINGING',
'DISABLE_TRANSCRIPTION_SUBTITLES',
'DISABLE_VIDEO_BACKGROUND',

View File

@ -5,10 +5,25 @@ import React, { Component } from 'react';
import { translate } from '../../../base/i18n';
import { IconMessage } from '../../../base/icons';
import { connect } from '../../../base/redux';
import { _mapDispatchToProps, _mapStateToProps, type Props } from '../../../chat/components/PrivateMessageButton';
import {
_mapDispatchToProps,
_mapStateToProps as _abstractMapStateToProps,
type Props as AbstractProps
} from '../../../chat/components/PrivateMessageButton';
import { isButtonEnabled } from '../../../toolbox';
import RemoteVideoMenuButton from './RemoteVideoMenuButton';
declare var interfaceConfig: Object;
type Props = AbstractProps & {
/**
* True if the private chat functionality is disabled, hence the button is not visible.
*/
_hidden: boolean
};
/**
* A custom implementation of the PrivateMessageButton specialized for
* the web version of the remote video menu. When the web platform starts to use
@ -34,7 +49,11 @@ class PrivateMessageMenuButton extends Component<Props> {
* @returns {ReactElement}
*/
render() {
const { participantID, t } = this.props;
const { participantID, t, _hidden } = this.props;
if (_hidden) {
return null;
}
return (
<RemoteVideoMenuButton
@ -59,4 +78,19 @@ class PrivateMessageMenuButton extends Component<Props> {
}
}
/**
* Maps part of the Redux store to the props of this component.
*
* @param {Object} state - The Redux state.
* @param {Props} ownProps - The own props of the component.
* @returns {Props}
*/
function _mapStateToProps(state: Object, ownProps: Props): $Shape<Props> {
return {
..._abstractMapStateToProps(state, ownProps),
_hidden: typeof interfaceConfig !== 'undefined'
&& (interfaceConfig.DISABLE_PRIVATE_MESSAGES || !isButtonEnabled('chat'))
};
}
export default translate(connect(_mapStateToProps, _mapDispatchToProps)(PrivateMessageMenuButton));