/* global interfaceConfig */ import React from 'react'; import { isMobileBrowser } from '../../base/environment/utils'; import { translate, translateToHTML } from '../../base/i18n'; import { Icon, IconWarning } from '../../base/icons'; import { Watermarks } from '../../base/react'; import { connect } from '../../base/redux'; import { CalendarList } from '../../calendar-sync'; import { RecentList } from '../../recent-list'; import { SettingsButton, SETTINGS_TABS } from '../../settings'; import { AbstractWelcomePage, _mapStateToProps } from './AbstractWelcomePage'; import Tabs from './Tabs'; /** * The pattern used to validate room name. * @type {string} */ export const ROOM_NAME_VALIDATE_PATTERN_STR = '^[^?&:\u0022\u0027%#]+$'; /** * Maximum number of pixels corresponding to a mobile layout. * @type {number} */ const WINDOW_WIDTH_THRESHOLD = 425; /** * The Web container rendering the welcome page. * * @extends AbstractWelcomePage */ class WelcomePage extends AbstractWelcomePage { /** * Default values for {@code WelcomePage} component's properties. * * @static */ static defaultProps = { _room: '' }; /** * Initializes a new WelcomePage instance. * * @param {Object} props - The read-only properties with which the new * instance is to be initialized. */ constructor(props) { super(props); this.state = { ...this.state, generateRoomnames: interfaceConfig.GENERATE_ROOMNAMES_ON_WELCOME_PAGE, selectedTab: 0 }; /** * The HTML Element used as the container for additional content. Used * for directly appending the additional content template to the dom. * * @private * @type {HTMLTemplateElement|null} */ this._additionalContentRef = null; this._roomInputRef = null; /** * The HTML Element used as the container for additional toolbar content. Used * for directly appending the additional content template to the dom. * * @private * @type {HTMLTemplateElement|null} */ this._additionalToolbarContentRef = null; /** * The template to use as the main content for the welcome page. If * not found then only the welcome page head will display. * * @private * @type {HTMLTemplateElement|null} */ this._additionalContentTemplate = document.getElementById( 'welcome-page-additional-content-template'); /** * The template to use as the additional content for the welcome page header toolbar. * If not found then only the settings icon will be displayed. * * @private * @type {HTMLTemplateElement|null} */ this._additionalToolbarContentTemplate = document.getElementById( 'settings-toolbar-additional-content-template' ); // Bind event handlers so they are only bound once per instance. this._onFormSubmit = this._onFormSubmit.bind(this); this._onRoomChange = this._onRoomChange.bind(this); this._setAdditionalContentRef = this._setAdditionalContentRef.bind(this); this._setRoomInputRef = this._setRoomInputRef.bind(this); this._setAdditionalToolbarContentRef = this._setAdditionalToolbarContentRef.bind(this); this._onTabSelected = this._onTabSelected.bind(this); } /** * Implements React's {@link Component#componentDidMount()}. Invoked * immediately after this component is mounted. * * @inheritdoc * @returns {void} */ componentDidMount() { super.componentDidMount(); document.body.classList.add('welcome-page'); document.title = interfaceConfig.APP_NAME; if (this.state.generateRoomnames) { this._updateRoomname(); } if (this._shouldShowAdditionalContent()) { this._additionalContentRef.appendChild( this._additionalContentTemplate.content.cloneNode(true)); } if (this._shouldShowAdditionalToolbarContent()) { this._additionalToolbarContentRef.appendChild( this._additionalToolbarContentTemplate.content.cloneNode(true) ); } } /** * Removes the classname used for custom styling of the welcome page. * * @inheritdoc * @returns {void} */ componentWillUnmount() { super.componentWillUnmount(); document.body.classList.remove('welcome-page'); } /** * Implements React's {@link Component#render()}. * * @inheritdoc * @returns {ReactElement|null} */ render() { const { _moderatedRoomServiceUrl, t } = this.props; const { APP_NAME } = interfaceConfig; const showAdditionalContent = this._shouldShowAdditionalContent(); const showAdditionalToolbarContent = this._shouldShowAdditionalToolbarContent(); const showResponsiveText = this._shouldShowResponsiveText(); return (
{ t('welcomepage.appDescription', { app: APP_NAME }) }
{ translateToHTML( t, 'welcomepage.moderatedMessage', { url: _moderatedRoomServiceUrl }) }