feat(prejoin) add unsafe room name warning

This commit is contained in:
Gabriel Borlea
2023-05-09 21:04:58 +03:00
committed by GitHub
parent b705c63a65
commit a112d38943
28 changed files with 433 additions and 18 deletions

View File

@@ -1,17 +1,22 @@
import { WithTranslation } from 'react-i18next';
import { connect } from 'react-redux';
import { IReduxState } from '../../../app/types';
import { translate } from '../../../base/i18n/functions';
import ExpandedLabel, { IProps as AbstractProps } from '../../../base/label/components/native/ExpandedLabel';
import getUnsafeRoomText from '../../../base/util/getUnsafeRoomText.native';
import { INSECURE_ROOM_NAME_LABEL_COLOR } from './styles';
type Props = AbstractProps & WithTranslation;
interface IProps extends AbstractProps, WithTranslation {
getUnsafeRoomTextFn: Function;
}
/**
* A react {@code Component} that implements an expanded label as tooltip-like
* component to explain the meaning of the {@code InsecureRoomNameExpandedLabel}.
*/
class InsecureRoomNameExpandedLabel extends ExpandedLabel<Props> {
class InsecureRoomNameExpandedLabel extends ExpandedLabel<IProps> {
/**
* Returns the color this expanded label should be rendered with.
*
@@ -27,8 +32,20 @@ class InsecureRoomNameExpandedLabel extends ExpandedLabel<Props> {
* @returns {string}
*/
_getLabel() {
return this.props.t('security.insecureRoomNameWarning');
return this.props.getUnsafeRoomTextFn(this.props.t);
}
}
export default translate(InsecureRoomNameExpandedLabel);
/**
* Maps part of the Redux state to the props of this component.
*
* @param {Object} state - The Redux state.
* @returns {IProps}
*/
function _mapStateToProps(state: IReduxState) {
return {
getUnsafeRoomTextFn: (t: Function) => getUnsafeRoomText(state, t, 'meeting')
};
}
export default translate(connect(_mapStateToProps)(InsecureRoomNameExpandedLabel));

View File

@@ -6,6 +6,7 @@ import { IconExclamationTriangle } from '../../../base/icons/svg';
import Label from '../../../base/label/components/web/Label';
import { COLORS } from '../../../base/label/constants';
import Tooltip from '../../../base/tooltip/components/Tooltip';
import getUnsafeRoomText from '../../../base/util/getUnsafeRoomText.web';
import AbstractInsecureRoomNameLabel, { _mapStateToProps } from '../AbstractInsecureRoomNameLabel';
/**
@@ -20,7 +21,7 @@ class InsecureRoomNameLabel extends AbstractInsecureRoomNameLabel {
_render() {
return (
<Tooltip
content = { this.props.t('security.insecureRoomNameWarning') }
content = { getUnsafeRoomText(this.props.t, 'meeting') }
position = 'bottom'>
<Label
color = { COLORS.red }