/* global interfaceConfig, APP */ import React from 'react'; import { connect } from 'react-redux'; import { AbstractWelcomePage, mapStateToProps } from './AbstractWelcomePage'; const RIGHT_WATERMARK_STYLES = { backgroundImage: 'url(images/rightwatermark.png)' }; import { Conference } from '../../conference'; /** * The web container rendering the welcome page. */ class WelcomePage extends AbstractWelcomePage { /** * Constructor function of WelcomePage. * * @param {Object} props - Props to be set. **/ constructor(props) { super(props); this._initState(); // Bind event handlers so they are only bound once for every instance. const onToggleDisableWelcome = this._onToggleDisableWelcomePage; this._onRoomChange = this._onRoomChange.bind(this); this._onKeyDown = this._onKeyDown.bind(this); this._setInput = this._setInput.bind(this); this._onUpdateRoomname = this._onUpdateRoomname.bind(this); this._onToggleDisableWelcomePage = onToggleDisableWelcome.bind(this); } /** * Method that initializes state of the component. * * @returns {void} **/ _initState() { const showPoweredBy = interfaceConfig.SHOW_POWERED_BY; const generateRoomnames = interfaceConfig.GENERATE_ROOMNAMES_ON_WELCOME_PAGE; const enableWelcomePage = true; const showJitsiWatermark = interfaceConfig.SHOW_JITSI_WATERMARK; const showBrandWatermark = interfaceConfig.SHOW_BRAND_WATERMARK; let jitsiWatermarkLink = ''; let brandWatermarkLink = ''; if (showJitsiWatermark) { jitsiWatermarkLink = interfaceConfig.JITSI_WATERMARK_LINK; } if (showBrandWatermark) { brandWatermarkLink = interfaceConfig.BRAND_WATERMARK_LINK; } this.state = Object.assign({}, this.state, { showPoweredBy, generateRoomnames, showJitsiWatermark, showBrandWatermark, jitsiWatermarkLink, brandWatermarkLink, enableWelcomePage }); } /** * Returns the domain name. * * @private * @returns {string} Domain name. **/ _getDomain() { return `${window.location.protocol}//${window.location.host}/`; } /** * This method is executed when comonent is mounted. * * @inheritdoc */ componentDidMount() { if (this.state.generateRoomnames) { this._updateRoomname(); } } /** * Handles toggling disable welcome page checkbox * * @returns {void} **/ _onToggleDisableWelcomePage() { const shouldEnable = this.state.enableWelcomePage; this.setState({ enableWelcomePage: !shouldEnable }, () => { APP.settings.setWelcomePageEnabled(this.state.enableWelcomePage); }); } /** * Implements React's {@link Component#render()}. * * @inheritdoc * @returns {ReactElement|null} */ render() { // FIXME The rendering of Conference bellow is a very quick and dirty // temporary fix for the following issue: when the WelcomePage is // disabled, app.js expects Conference to be rendered already and only // then it builds a room name but the App component expects the room // name to be built already (by looking at the window's location) in // order to choose between WelcomePage and Conference. return (
{ this._renderHeader() } { this._renderMain() }
); } /** * Sets input element as property of class. * * @param {HTMLInputElement} input - input element to be set. * @returns {void} * @private **/ _setInput(input) { this.roomNameInput = input; } /** * Renders a feature with a specific index. * * @param {number} index - The index of the feature to render. * @private * @returns {ReactElement} */ _renderFeature(index) { return (
); } /** * Renders a row of features. * * @param {number} beginIndex - The inclusive feature index to begin the row * with. * @param {number} endIndex - The exclusive feature index to end the row * with. * @private * @returns {ReactElement} */ _renderFeatureRow(beginIndex, endIndex) { const features = []; for (let index = beginIndex; index < endIndex; ++index) { features.push(this._renderFeature(index)); } return (
{ features }
); } /** * Renders the header part of this WelcomePage. * * @private * @returns {ReactElement|null} */ _renderHeader() { return (
{ this._renderJitsiWatermark() } { this._renderBrandWatermark() } { this._renderPoweredBy() }
{ this._getDomain() }