jiti-meet/react/features/conference/components/AbstractInsecureRoomNameLab...

63 lines
1.4 KiB
TypeScript
Raw Normal View History

import React, { PureComponent } from 'react';
2020-05-18 12:07:09 +00:00
import { IReduxState } from '../../app/types';
2020-05-18 12:07:09 +00:00
import isInsecureRoomName from '../../base/util/isInsecureRoomName';
type Props = {
/**
* True of the label should be visible.
*/
_visible: boolean;
/**
* Function to be used to translate i18n labels.
*/
t: Function;
};
2020-05-18 12:07:09 +00:00
/**
* Abstract class for the {@Code InsecureRoomNameLabel} component.
2020-05-18 12:07:09 +00:00
*/
export default class AbstractInsecureRoomNameLabel extends PureComponent<Props> {
/**
* Implements {@code Component#render}.
*
* @inheritdoc
*/
render() {
if (!this.props._visible) {
return null;
}
return this._render();
}
/**
* Renders the platform dependent content.
2020-05-18 12:07:09 +00:00
*
* @returns {ReactElement}
*/
_render() {
return <></>;
}
2020-05-18 12:07:09 +00:00
}
/**
* Maps part of the Redux state to the props of this component.
*
* @param {Object} state - The Redux state.
* @returns {Props}
*/
export function _mapStateToProps(state: IReduxState) {
const { locked, room } = state['features/base/conference'];
const { lobbyEnabled } = state['features/lobby'];
const { enableInsecureRoomNameWarning = false } = state['features/base/config'];
2020-05-18 12:07:09 +00:00
return {
_visible: Boolean(enableInsecureRoomNameWarning
&& room && isInsecureRoomName(room)
&& !(lobbyEnabled || Boolean(locked)))
2020-05-18 12:07:09 +00:00
};
}