2017-02-23 16:56:25 +00:00
|
|
|
/* global APP, interfaceConfig */
|
2016-12-01 18:55:42 +00:00
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
2017-03-01 02:55:12 +00:00
|
|
|
import { translate } from '../../base/i18n';
|
2017-01-17 22:16:08 +00:00
|
|
|
import { Watermarks } from '../../base/react';
|
2016-12-01 18:55:42 +00:00
|
|
|
|
2017-01-28 23:34:57 +00:00
|
|
|
import { AbstractWelcomePage, _mapStateToProps } from './AbstractWelcomePage';
|
2016-11-23 21:46:46 +00:00
|
|
|
|
2016-12-16 03:00:06 +00:00
|
|
|
/* eslint-disable require-jsdoc */
|
2016-11-30 20:38:47 +00:00
|
|
|
|
2016-11-23 21:46:46 +00:00
|
|
|
/**
|
2016-12-16 03:00:06 +00:00
|
|
|
* The Web container rendering the welcome page.
|
|
|
|
*
|
|
|
|
* @extends AbstractWelcomePage
|
2016-11-23 21:46:46 +00:00
|
|
|
*/
|
2016-12-01 18:55:42 +00:00
|
|
|
class WelcomePage extends AbstractWelcomePage {
|
|
|
|
|
2016-12-16 03:00:06 +00:00
|
|
|
/* eslint-enable require-jsdoc */
|
|
|
|
|
2016-12-01 18:55:42 +00:00
|
|
|
/**
|
2016-12-16 03:00:06 +00:00
|
|
|
* Initializes a new WelcomePage instance.
|
|
|
|
*
|
|
|
|
* @param {Object} props - The read-only properties with which the new
|
|
|
|
* instance is to be initialized.
|
|
|
|
*/
|
2016-12-01 18:55:42 +00:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
2016-12-16 03:00:06 +00:00
|
|
|
|
2017-01-17 22:16:08 +00:00
|
|
|
this.state = {
|
|
|
|
...this.state,
|
|
|
|
|
|
|
|
enableWelcomePage: true,
|
|
|
|
generateRoomnames:
|
|
|
|
interfaceConfig.GENERATE_ROOMNAMES_ON_WELCOME_PAGE
|
|
|
|
};
|
2016-12-01 18:55:42 +00:00
|
|
|
|
|
|
|
// Bind event handlers so they are only bound once for every instance.
|
2016-12-16 03:00:06 +00:00
|
|
|
this._onDisableWelcomeChange = this._onDisableWelcomeChange.bind(this);
|
2016-12-01 18:55:42 +00:00
|
|
|
this._onKeyDown = this._onKeyDown.bind(this);
|
2016-12-16 03:00:06 +00:00
|
|
|
this._onRoomChange = this._onRoomChange.bind(this);
|
2016-12-01 18:55:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-12-16 03:00:06 +00:00
|
|
|
* This method is executed when comonent is mounted.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2016-12-01 18:55:42 +00:00
|
|
|
componentDidMount() {
|
|
|
|
if (this.state.generateRoomnames) {
|
|
|
|
this._updateRoomname();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-23 21:46:46 +00:00
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement|null}
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
return (
|
2017-01-17 22:16:08 +00:00
|
|
|
<div id = 'welcome_page'>
|
|
|
|
{
|
|
|
|
this._renderHeader()
|
|
|
|
}
|
|
|
|
{
|
|
|
|
this._renderMain()
|
|
|
|
}
|
2016-11-23 21:46:46 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-12-01 18:55:42 +00:00
|
|
|
/**
|
2017-02-05 02:29:24 +00:00
|
|
|
* Returns the URL of this WelcomePage for display purposes. For
|
|
|
|
* historic/legacy reasons, the return value is referred to as domain.
|
2016-12-16 03:00:06 +00:00
|
|
|
*
|
|
|
|
* @private
|
2017-02-05 02:29:24 +00:00
|
|
|
* @returns {string} The URL of this WelcomePage for display purposes.
|
2016-12-16 03:00:06 +00:00
|
|
|
*/
|
|
|
|
_getDomain() {
|
2017-02-05 02:29:24 +00:00
|
|
|
// As the returned URL is for display purposes, do not return the
|
|
|
|
// userinfo, query and fragment URI parts.
|
|
|
|
const wl = window.location;
|
2017-02-01 04:25:09 +00:00
|
|
|
|
2017-02-05 02:29:24 +00:00
|
|
|
return `${wl.protocol}//${wl.host}${wl.pathname}`;
|
2016-12-16 03:00:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles <tt>change</tt> event of the checkbox which allows specifying
|
|
|
|
* whether the WelcomePage is disabled.
|
|
|
|
*
|
|
|
|
* @param {Event} event - The (HTML) Event which details the change such as
|
|
|
|
* the EventTarget.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onDisableWelcomeChange(event) {
|
|
|
|
this.setState({
|
2017-01-17 22:20:43 +00:00
|
|
|
enableWelcomePage: !event.target.checked
|
2016-12-16 03:00:06 +00:00
|
|
|
}, () => {
|
|
|
|
APP.settings.setWelcomePageEnabled(this.state.enableWelcomePage);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles 'keydown' event to initiate joining the room when the
|
|
|
|
* 'Enter/Return' button is pressed.
|
|
|
|
*
|
|
|
|
* @param {Event} event - Key down event object.
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onKeyDown(event) {
|
|
|
|
if (event.keyCode === /* Enter */ 13) {
|
|
|
|
this._onJoin();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Overrides the super to account for the differences in the argument types
|
|
|
|
* provided by HTML and React Native text inputs.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @override
|
|
|
|
* @param {Event} event - The (HTML) Event which details the change such as
|
|
|
|
* the EventTarget.
|
|
|
|
* @protected
|
|
|
|
*/
|
|
|
|
_onRoomChange(event) {
|
|
|
|
super._onRoomChange(event.target.value);
|
|
|
|
}
|
|
|
|
|
2016-11-23 21:46:46 +00:00
|
|
|
/**
|
|
|
|
* Renders a feature with a specific index.
|
|
|
|
*
|
|
|
|
* @param {number} index - The index of the feature to render.
|
|
|
|
* @private
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_renderFeature(index) {
|
2017-02-23 16:56:25 +00:00
|
|
|
const { t } = this.props;
|
2017-03-01 02:55:12 +00:00
|
|
|
const tns = `welcomepage.feature${index}`;
|
2017-02-23 16:56:25 +00:00
|
|
|
|
2016-11-23 21:46:46 +00:00
|
|
|
return (
|
2017-02-22 11:08:12 +00:00
|
|
|
<div
|
|
|
|
className = 'feature_holder'
|
|
|
|
key = { index } >
|
2017-03-01 02:55:12 +00:00
|
|
|
<div className = 'feature_icon'>
|
|
|
|
{ t(`${tns}.title`) }
|
2017-02-23 16:56:25 +00:00
|
|
|
</div>
|
2017-03-01 02:55:12 +00:00
|
|
|
<div className = 'feature_description'>
|
|
|
|
{ t(`${tns}.content`, { postProcess: 'resolveAppName' }) }
|
2017-02-23 16:56:25 +00:00
|
|
|
</div>
|
2016-11-23 21:46:46 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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 (
|
|
|
|
<div className = 'feature_row'>
|
|
|
|
{
|
|
|
|
features
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders the header part of this WelcomePage.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {ReactElement|null}
|
|
|
|
*/
|
|
|
|
_renderHeader() {
|
2017-02-23 16:56:25 +00:00
|
|
|
const { t } = this.props;
|
2016-12-16 03:00:06 +00:00
|
|
|
|
2016-11-23 21:46:46 +00:00
|
|
|
return (
|
|
|
|
<div id = 'welcome_page_header'>
|
2017-01-17 22:16:08 +00:00
|
|
|
<Watermarks />
|
|
|
|
|
2016-11-23 21:46:46 +00:00
|
|
|
<div id = 'enter_room_container'>
|
|
|
|
<div id = 'enter_room_form'>
|
2016-12-16 03:00:06 +00:00
|
|
|
<div className = 'domain-name'>
|
|
|
|
{
|
|
|
|
this._getDomain()
|
|
|
|
}
|
2016-12-01 18:55:42 +00:00
|
|
|
</div>
|
2016-11-23 21:46:46 +00:00
|
|
|
<div id = 'enter_room'>
|
|
|
|
<input
|
|
|
|
autoFocus = { true }
|
2016-12-01 18:55:42 +00:00
|
|
|
className = 'enter-room__field'
|
2016-12-16 03:00:06 +00:00
|
|
|
data-room-name
|
|
|
|
= { this.state.generatedRoomname }
|
2016-11-23 21:46:46 +00:00
|
|
|
id = 'enter_room_field'
|
2016-12-01 18:55:42 +00:00
|
|
|
onChange = { this._onRoomChange }
|
|
|
|
onKeyDown = { this._onKeyDown }
|
|
|
|
placeholder = { this.state.roomPlaceholder }
|
|
|
|
type = 'text'
|
|
|
|
value = { this.state.room } />
|
2016-12-16 03:00:06 +00:00
|
|
|
|
|
|
|
{ /* eslint-disable react/jsx-handler-names */ }
|
2016-11-23 21:46:46 +00:00
|
|
|
<div
|
2016-12-01 18:55:42 +00:00
|
|
|
className = 'icon-reload enter-room__reload'
|
2016-12-16 03:00:06 +00:00
|
|
|
onClick = { this._updateRoomname } />
|
|
|
|
{ /* eslint-enable react/jsx-handler-names */ }
|
|
|
|
|
2016-12-01 18:55:42 +00:00
|
|
|
<button
|
|
|
|
className = 'enter-room__button'
|
2016-11-23 21:46:46 +00:00
|
|
|
id = 'enter_room_button'
|
2016-12-01 18:55:42 +00:00
|
|
|
onClick = { this._onJoin }
|
2017-02-23 16:56:25 +00:00
|
|
|
type = 'button'>
|
|
|
|
{ t('welcomepage.go') }
|
|
|
|
</button>
|
2016-11-23 21:46:46 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div id = 'brand_header' />
|
|
|
|
<input
|
2016-12-01 18:55:42 +00:00
|
|
|
checked = { !this.state.enableWelcomePage }
|
2016-11-23 21:46:46 +00:00
|
|
|
id = 'disable_welcome'
|
|
|
|
name = 'checkbox'
|
2016-12-16 03:00:06 +00:00
|
|
|
onChange = { this._onDisableWelcomeChange }
|
2016-11-23 21:46:46 +00:00
|
|
|
type = 'checkbox' />
|
|
|
|
<label
|
|
|
|
className = 'disable_welcome_position'
|
2017-02-23 16:56:25 +00:00
|
|
|
htmlFor = 'disable_welcome'>
|
|
|
|
{ t('welcomepage.disable') }
|
|
|
|
</label>
|
2016-11-23 21:46:46 +00:00
|
|
|
<div id = 'header_text' />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders the main part of this WelcomePage.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {ReactElement|null}
|
|
|
|
*/
|
|
|
|
_renderMain() {
|
|
|
|
return (
|
|
|
|
<div id = 'welcome_page_main'>
|
|
|
|
<div id = 'features'>
|
|
|
|
{
|
|
|
|
this._renderFeatureRow(1, 5)
|
|
|
|
}
|
|
|
|
{
|
|
|
|
this._renderFeatureRow(5, 9)
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2016-12-01 18:55:42 +00:00
|
|
|
|
2017-02-23 16:56:25 +00:00
|
|
|
export default translate(connect(_mapStateToProps)(WelcomePage));
|