2018-04-16 12:44:08 +00:00
|
|
|
/* global interfaceConfig */
|
2016-12-01 18:55:42 +00:00
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
|
2017-03-01 02:55:12 +00:00
|
|
|
import { translate } from '../../base/i18n';
|
2018-08-27 15:13:59 +00:00
|
|
|
import { Platform, Watermarks } from '../../base/react';
|
2019-03-21 16:38:29 +00:00
|
|
|
import { connect } from '../../base/redux';
|
2018-08-27 15:13:59 +00:00
|
|
|
import { CalendarList } from '../../calendar-sync';
|
2018-08-01 16:41:54 +00:00
|
|
|
import { RecentList } from '../../recent-list';
|
2018-08-28 00:56:17 +00:00
|
|
|
import { SettingsButton, SETTINGS_TABS } from '../../settings';
|
2016-12-01 18:55:42 +00:00
|
|
|
|
2017-01-28 23:34:57 +00:00
|
|
|
import { AbstractWelcomePage, _mapStateToProps } from './AbstractWelcomePage';
|
2018-10-22 18:49:18 +00:00
|
|
|
import Tabs from './Tabs';
|
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 {
|
2018-08-06 15:24:59 +00:00
|
|
|
/**
|
|
|
|
* Default values for {@code WelcomePage} component's properties.
|
|
|
|
*
|
|
|
|
* @static
|
|
|
|
*/
|
|
|
|
static defaultProps = {
|
|
|
|
_room: ''
|
|
|
|
};
|
|
|
|
|
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,
|
|
|
|
|
|
|
|
generateRoomnames:
|
2018-09-05 21:46:28 +00:00
|
|
|
interfaceConfig.GENERATE_ROOMNAMES_ON_WELCOME_PAGE,
|
|
|
|
selectedTab: 0
|
2017-01-17 22:16:08 +00:00
|
|
|
};
|
2016-12-01 18:55:42 +00:00
|
|
|
|
2018-02-22 04:58:55 +00:00
|
|
|
/**
|
|
|
|
* The HTML Element used as the container for additional content. Used
|
2018-07-24 19:26:17 +00:00
|
|
|
* for directly appending the additional content template to the dom.
|
2018-02-22 04:58:55 +00:00
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @type {HTMLTemplateElement|null}
|
|
|
|
*/
|
|
|
|
this._additionalContentRef = 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');
|
|
|
|
|
2017-10-13 19:31:05 +00:00
|
|
|
// Bind event handlers so they are only bound once per instance.
|
2018-03-30 19:49:34 +00:00
|
|
|
this._onFormSubmit = this._onFormSubmit.bind(this);
|
2016-12-16 03:00:06 +00:00
|
|
|
this._onRoomChange = this._onRoomChange.bind(this);
|
2018-02-22 04:58:55 +00:00
|
|
|
this._setAdditionalContentRef
|
|
|
|
= this._setAdditionalContentRef.bind(this);
|
2018-09-05 21:46:28 +00:00
|
|
|
this._onTabSelected = this._onTabSelected.bind(this);
|
2016-12-01 18:55:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-09-14 09:46:35 +00:00
|
|
|
* Implements React's {@link Component#componentDidMount()}. Invoked
|
|
|
|
* immediately after this component is mounted.
|
2016-12-16 03:00:06 +00:00
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2016-12-01 18:55:42 +00:00
|
|
|
componentDidMount() {
|
2018-04-09 20:50:57 +00:00
|
|
|
document.body.classList.add('welcome-page');
|
2019-07-08 18:50:13 +00:00
|
|
|
document.title = interfaceConfig.APP_NAME;
|
2018-04-09 20:50:57 +00:00
|
|
|
|
2016-12-01 18:55:42 +00:00
|
|
|
if (this.state.generateRoomnames) {
|
|
|
|
this._updateRoomname();
|
|
|
|
}
|
2018-02-22 04:58:55 +00:00
|
|
|
|
|
|
|
if (this._shouldShowAdditionalContent()) {
|
|
|
|
this._additionalContentRef.appendChild(
|
|
|
|
this._additionalContentTemplate.content.cloneNode(true));
|
|
|
|
}
|
2016-12-01 18:55:42 +00:00
|
|
|
}
|
|
|
|
|
2018-04-09 20:50:57 +00:00
|
|
|
/**
|
|
|
|
* Removes the classname used for custom styling of the welcome page.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
componentWillUnmount() {
|
2018-04-12 21:23:30 +00:00
|
|
|
super.componentWillUnmount();
|
|
|
|
|
2018-04-09 20:50:57 +00:00
|
|
|
document.body.classList.remove('welcome-page');
|
|
|
|
}
|
|
|
|
|
2016-11-23 21:46:46 +00:00
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement|null}
|
|
|
|
*/
|
|
|
|
render() {
|
2018-02-22 04:58:55 +00:00
|
|
|
const { t } = this.props;
|
2018-08-01 20:37:15 +00:00
|
|
|
const { APP_NAME } = interfaceConfig;
|
2018-02-22 04:58:55 +00:00
|
|
|
const showAdditionalContent = this._shouldShowAdditionalContent();
|
|
|
|
|
2016-11-23 21:46:46 +00:00
|
|
|
return (
|
2018-10-22 18:49:18 +00:00
|
|
|
<div
|
|
|
|
className = { `welcome ${showAdditionalContent
|
|
|
|
? 'with-content' : 'without-content'}` }
|
|
|
|
id = 'welcome_page'>
|
2019-05-14 18:56:33 +00:00
|
|
|
<div className = 'welcome-watermark'>
|
|
|
|
<Watermarks />
|
|
|
|
</div>
|
2018-10-22 18:49:18 +00:00
|
|
|
<div className = 'header'>
|
|
|
|
<div className = 'welcome-page-settings'>
|
|
|
|
<SettingsButton
|
|
|
|
defaultTab = { SETTINGS_TABS.CALENDAR } />
|
2018-07-24 19:26:17 +00:00
|
|
|
</div>
|
2018-10-22 18:49:18 +00:00
|
|
|
<div className = 'header-image' />
|
|
|
|
<div className = 'header-text'>
|
|
|
|
<h1 className = 'header-text-title'>
|
|
|
|
{ t('welcomepage.title') }
|
|
|
|
</h1>
|
|
|
|
<p className = 'header-text-description'>
|
|
|
|
{ t('welcomepage.appDescription',
|
|
|
|
{ app: APP_NAME }) }
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<div id = 'enter_room'>
|
|
|
|
<div className = 'enter-room-input-container'>
|
|
|
|
<div className = 'enter-room-title'>
|
|
|
|
{ t('welcomepage.enterRoomTitle') }
|
|
|
|
</div>
|
|
|
|
<form onSubmit = { this._onFormSubmit }>
|
|
|
|
<input
|
2018-02-22 04:58:55 +00:00
|
|
|
autoFocus = { true }
|
2018-10-22 18:49:18 +00:00
|
|
|
className = 'enter-room-input'
|
2018-02-22 04:58:55 +00:00
|
|
|
id = 'enter_room_field'
|
|
|
|
onChange = { this._onRoomChange }
|
2018-10-22 18:49:18 +00:00
|
|
|
placeholder
|
|
|
|
= { this.state.roomPlaceholder }
|
2018-02-22 04:58:55 +00:00
|
|
|
type = 'text'
|
|
|
|
value = { this.state.room } />
|
|
|
|
</form>
|
|
|
|
</div>
|
2018-10-22 18:49:18 +00:00
|
|
|
<div
|
|
|
|
className = 'welcome-page-button'
|
|
|
|
id = 'enter_room_button'
|
|
|
|
onClick = { this._onJoin }>
|
|
|
|
{ t('welcomepage.go') }
|
|
|
|
</div>
|
2018-02-22 04:58:55 +00:00
|
|
|
</div>
|
2018-10-22 18:49:18 +00:00
|
|
|
{ this._renderTabs() }
|
2018-02-22 04:58:55 +00:00
|
|
|
</div>
|
2018-10-22 18:49:18 +00:00
|
|
|
{ showAdditionalContent
|
|
|
|
? <div
|
|
|
|
className = 'welcome-page-content'
|
|
|
|
ref = { this._setAdditionalContentRef } />
|
|
|
|
: null }
|
|
|
|
</div>
|
2016-11-23 21:46:46 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-03-30 19:49:34 +00:00
|
|
|
/**
|
2018-07-24 19:26:17 +00:00
|
|
|
* Prevents submission of the form and delegates join logic.
|
2018-03-30 19:49:34 +00:00
|
|
|
*
|
|
|
|
* @param {Event} event - The HTML Event which details the form submission.
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onFormSubmit(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
|
|
this._onJoin();
|
|
|
|
}
|
|
|
|
|
2016-12-16 03:00:06 +00:00
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
}
|
|
|
|
|
2018-09-05 21:46:28 +00:00
|
|
|
/**
|
|
|
|
* Callback invoked when the desired tab to display should be changed.
|
|
|
|
*
|
|
|
|
* @param {number} tabIndex - The index of the tab within the array of
|
|
|
|
* displayed tabs.
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2018-10-22 18:49:18 +00:00
|
|
|
_onTabSelected(tabIndex) {
|
2018-09-05 21:46:28 +00:00
|
|
|
this.setState({ selectedTab: tabIndex });
|
|
|
|
}
|
|
|
|
|
2018-08-27 15:13:59 +00:00
|
|
|
/**
|
|
|
|
* Renders tabs to show previous meetings and upcoming calendar events. The
|
|
|
|
* tabs are purposefully hidden on mobile browsers.
|
|
|
|
*
|
|
|
|
* @returns {ReactElement|null}
|
|
|
|
*/
|
|
|
|
_renderTabs() {
|
|
|
|
const isMobileBrowser
|
|
|
|
= Platform.OS === 'android' || Platform.OS === 'ios';
|
|
|
|
|
|
|
|
if (isMobileBrowser) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2019-05-28 13:32:29 +00:00
|
|
|
const { _calendarEnabled, t } = this.props;
|
2018-08-27 15:13:59 +00:00
|
|
|
|
|
|
|
const tabs = [];
|
|
|
|
|
2019-05-28 13:32:29 +00:00
|
|
|
if (_calendarEnabled) {
|
2018-08-27 15:13:59 +00:00
|
|
|
tabs.push({
|
|
|
|
label: t('welcomepage.calendar'),
|
2018-09-05 21:46:28 +00:00
|
|
|
content: <CalendarList />
|
2018-08-27 15:13:59 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
tabs.push({
|
|
|
|
label: t('welcomepage.recentList'),
|
2018-10-22 18:49:18 +00:00
|
|
|
content: <RecentList />
|
2018-08-27 15:13:59 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
2018-10-22 18:49:18 +00:00
|
|
|
<Tabs
|
|
|
|
onSelect = { this._onTabSelected }
|
|
|
|
selected = { this.state.selectedTab }
|
|
|
|
tabs = { tabs } />);
|
2018-08-27 15:13:59 +00:00
|
|
|
}
|
|
|
|
|
2016-11-23 21:46:46 +00:00
|
|
|
/**
|
2018-02-22 04:58:55 +00:00
|
|
|
* Sets the internal reference to the HTMLDivElement used to hold the
|
|
|
|
* welcome page content.
|
2016-11-23 21:46:46 +00:00
|
|
|
*
|
2018-02-22 04:58:55 +00:00
|
|
|
* @param {HTMLDivElement} el - The HTMLElement for the div that is the root
|
|
|
|
* of the welcome page content.
|
2016-11-23 21:46:46 +00:00
|
|
|
* @private
|
2018-02-22 04:58:55 +00:00
|
|
|
* @returns {void}
|
2016-11-23 21:46:46 +00:00
|
|
|
*/
|
2018-02-22 04:58:55 +00:00
|
|
|
_setAdditionalContentRef(el) {
|
|
|
|
this._additionalContentRef = el;
|
2016-11-23 21:46:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-07-24 19:26:17 +00:00
|
|
|
* Returns whether or not additional content should be displayed below
|
2018-02-22 04:58:55 +00:00
|
|
|
* the welcome page's header for entering a room name.
|
2016-11-23 21:46:46 +00:00
|
|
|
*
|
|
|
|
* @private
|
2018-02-22 04:58:55 +00:00
|
|
|
* @returns {boolean}
|
2016-11-23 21:46:46 +00:00
|
|
|
*/
|
2018-02-22 04:58:55 +00:00
|
|
|
_shouldShowAdditionalContent() {
|
|
|
|
return interfaceConfig.DISPLAY_WELCOME_PAGE_CONTENT
|
|
|
|
&& this._additionalContentTemplate
|
|
|
|
&& this._additionalContentTemplate.content
|
|
|
|
&& this._additionalContentTemplate.innerHTML.trim();
|
2016-11-23 21:46:46 +00:00
|
|
|
}
|
|
|
|
}
|
2016-12-01 18:55:42 +00:00
|
|
|
|
2017-02-23 16:56:25 +00:00
|
|
|
export default translate(connect(_mapStateToProps)(WelcomePage));
|