From 53f01a39c9cf8218dbc9deb5161cf46e9a42e7cf Mon Sep 17 00:00:00 2001 From: Bettenbuk Zoltan Date: Fri, 8 Nov 2019 14:40:20 +0100 Subject: [PATCH] feat: private message interface config flag --- .../base/config/interfaceConfigWhitelist.js | 1 + .../web/PrivateMessageMenuButton.js | 38 ++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/react/features/base/config/interfaceConfigWhitelist.js b/react/features/base/config/interfaceConfigWhitelist.js index fed523ea9..f37762a2c 100644 --- a/react/features/base/config/interfaceConfigWhitelist.js +++ b/react/features/base/config/interfaceConfigWhitelist.js @@ -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', diff --git a/react/features/remote-video-menu/components/web/PrivateMessageMenuButton.js b/react/features/remote-video-menu/components/web/PrivateMessageMenuButton.js index 4819a2a62..c9f036b4e 100644 --- a/react/features/remote-video-menu/components/web/PrivateMessageMenuButton.js +++ b/react/features/remote-video-menu/components/web/PrivateMessageMenuButton.js @@ -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 { * @returns {ReactElement} */ render() { - const { participantID, t } = this.props; + const { participantID, t, _hidden } = this.props; + + if (_hidden) { + return null; + } return ( { } } +/** + * 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 { + return { + ..._abstractMapStateToProps(state, ownProps), + _hidden: typeof interfaceConfig !== 'undefined' + && (interfaceConfig.DISABLE_PRIVATE_MESSAGES || !isButtonEnabled('chat')) + }; +} + export default translate(connect(_mapStateToProps, _mapDispatchToProps)(PrivateMessageMenuButton));