2019-10-07 12:35:04 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import React, { Component } from 'react';
|
|
|
|
|
|
|
|
import { translate } from '../../../base/i18n';
|
|
|
|
import { IconMessage } from '../../../base/icons';
|
|
|
|
import { connect } from '../../../base/redux';
|
2022-10-06 10:09:40 +00:00
|
|
|
import ContextMenuItem from '../../../base/ui/components/web/ContextMenuItem';
|
2021-02-12 11:18:16 +00:00
|
|
|
import { openChat } from '../../../chat/';
|
2019-11-08 13:40:20 +00:00
|
|
|
import {
|
2022-09-27 07:10:28 +00:00
|
|
|
type Props as AbstractProps,
|
|
|
|
_mapStateToProps as _abstractMapStateToProps
|
2021-11-11 12:32:01 +00:00
|
|
|
} from '../../../chat/components/web/PrivateMessageButton';
|
2020-07-24 12:14:33 +00:00
|
|
|
import { isButtonEnabled } from '../../../toolbox/functions.web';
|
2019-10-07 12:35:04 +00:00
|
|
|
|
2019-11-08 13:40:20 +00:00
|
|
|
declare var interfaceConfig: Object;
|
|
|
|
|
|
|
|
type Props = AbstractProps & {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* True if the private chat functionality is disabled, hence the button is not visible.
|
|
|
|
*/
|
|
|
|
_hidden: boolean
|
|
|
|
};
|
|
|
|
|
2019-10-07 12:35:04 +00:00
|
|
|
/**
|
|
|
|
* A custom implementation of the PrivateMessageButton specialized for
|
|
|
|
* the web version of the remote video menu. When the web platform starts to use
|
|
|
|
* the {@code AbstractButton} component for the remote video menu, we can get rid
|
|
|
|
* of this component and use the generic button in the chat feature.
|
|
|
|
*/
|
|
|
|
class PrivateMessageMenuButton extends Component<Props> {
|
|
|
|
/**
|
|
|
|
* Instantiates a new Component instance.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
constructor(props: Props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this._onClick = this._onClick.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
2021-12-15 13:18:41 +00:00
|
|
|
const { t, _hidden } = this.props;
|
2019-11-08 13:40:20 +00:00
|
|
|
|
|
|
|
if (_hidden) {
|
|
|
|
return null;
|
|
|
|
}
|
2019-10-07 12:35:04 +00:00
|
|
|
|
|
|
|
return (
|
2021-12-15 13:18:41 +00:00
|
|
|
<ContextMenuItem
|
|
|
|
accessibilityLabel = { t('toolbar.accessibilityLabel.privateMessage') }
|
2019-10-07 12:35:04 +00:00
|
|
|
icon = { IconMessage }
|
2021-12-15 13:18:41 +00:00
|
|
|
onClick = { this._onClick }
|
|
|
|
text = { t('toolbar.privateMessage') } />
|
2019-10-07 12:35:04 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
_onClick: () => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback to be invoked on pressing the button.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onClick() {
|
2021-02-12 11:18:16 +00:00
|
|
|
const { dispatch, _participant } = this.props;
|
2019-10-07 12:35:04 +00:00
|
|
|
|
2021-02-12 11:18:16 +00:00
|
|
|
dispatch(openChat(_participant));
|
2019-10-07 12:35:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-08 13:40:20 +00:00
|
|
|
/**
|
|
|
|
* 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'
|
2021-03-10 15:39:35 +00:00
|
|
|
&& (interfaceConfig.DISABLE_PRIVATE_MESSAGES || !isButtonEnabled('chat', state))
|
2019-11-08 13:40:20 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-02-12 11:18:16 +00:00
|
|
|
export default translate(connect(_mapStateToProps)(PrivateMessageMenuButton));
|