Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

WelcomePage.web.js 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. /* global interfaceConfig */
  2. import React from 'react';
  3. import { isMobileBrowser } from '../../base/environment/utils';
  4. import { translate, translateToHTML } from '../../base/i18n';
  5. import { Icon, IconWarning } from '../../base/icons';
  6. import { Watermarks } from '../../base/react';
  7. import { connect } from '../../base/redux';
  8. import { CalendarList } from '../../calendar-sync';
  9. import { RecentList } from '../../recent-list';
  10. import { SETTINGS_TABS, SettingsButton } from '../../settings';
  11. import { AbstractWelcomePage, _mapStateToProps } from './AbstractWelcomePage';
  12. import Tabs from './Tabs';
  13. /**
  14. * The pattern used to validate room name.
  15. *
  16. * @type {string}
  17. */
  18. export const ROOM_NAME_VALIDATE_PATTERN_STR = '^[^?&:\u0022\u0027%#]+$';
  19. /**
  20. * The Web container rendering the welcome page.
  21. *
  22. * @augments AbstractWelcomePage
  23. */
  24. class WelcomePage extends AbstractWelcomePage {
  25. /**
  26. * Default values for {@code WelcomePage} component's properties.
  27. *
  28. * @static
  29. */
  30. static defaultProps = {
  31. _room: ''
  32. };
  33. /**
  34. * Initializes a new WelcomePage instance.
  35. *
  36. * @param {Object} props - The read-only properties with which the new
  37. * instance is to be initialized.
  38. */
  39. constructor(props) {
  40. super(props);
  41. this.state = {
  42. ...this.state,
  43. generateRoomnames:
  44. interfaceConfig.GENERATE_ROOMNAMES_ON_WELCOME_PAGE
  45. };
  46. /**
  47. * The HTML Element used as the container for additional content. Used
  48. * for directly appending the additional content template to the dom.
  49. *
  50. * @private
  51. * @type {HTMLTemplateElement|null}
  52. */
  53. this._additionalContentRef = null;
  54. this._roomInputRef = null;
  55. /**
  56. * The HTML Element used as the container for additional toolbar content. Used
  57. * for directly appending the additional content template to the dom.
  58. *
  59. * @private
  60. * @type {HTMLTemplateElement|null}
  61. */
  62. this._additionalToolbarContentRef = null;
  63. this._additionalCardRef = null;
  64. /**
  65. * The template to use as the additional card displayed near the main one.
  66. *
  67. * @private
  68. * @type {HTMLTemplateElement|null}
  69. */
  70. this._additionalCardTemplate = document.getElementById(
  71. 'welcome-page-additional-card-template');
  72. /**
  73. * The template to use as the main content for the welcome page. If
  74. * not found then only the welcome page head will display.
  75. *
  76. * @private
  77. * @type {HTMLTemplateElement|null}
  78. */
  79. this._additionalContentTemplate = document.getElementById(
  80. 'welcome-page-additional-content-template');
  81. /**
  82. * The template to use as the additional content for the welcome page header toolbar.
  83. * If not found then only the settings icon will be displayed.
  84. *
  85. * @private
  86. * @type {HTMLTemplateElement|null}
  87. */
  88. this._additionalToolbarContentTemplate = document.getElementById(
  89. 'settings-toolbar-additional-content-template'
  90. );
  91. // Bind event handlers so they are only bound once per instance.
  92. this._onFormSubmit = this._onFormSubmit.bind(this);
  93. this._onRoomChange = this._onRoomChange.bind(this);
  94. this._setAdditionalCardRef = this._setAdditionalCardRef.bind(this);
  95. this._setAdditionalContentRef
  96. = this._setAdditionalContentRef.bind(this);
  97. this._setRoomInputRef = this._setRoomInputRef.bind(this);
  98. this._setAdditionalToolbarContentRef
  99. = this._setAdditionalToolbarContentRef.bind(this);
  100. this._renderFooter = this._renderFooter.bind(this);
  101. }
  102. /**
  103. * Implements React's {@link Component#componentDidMount()}. Invoked
  104. * immediately after this component is mounted.
  105. *
  106. * @inheritdoc
  107. * @returns {void}
  108. */
  109. componentDidMount() {
  110. super.componentDidMount();
  111. document.body.classList.add('welcome-page');
  112. document.title = interfaceConfig.APP_NAME;
  113. if (this.state.generateRoomnames) {
  114. this._updateRoomname();
  115. }
  116. if (this._shouldShowAdditionalContent()) {
  117. this._additionalContentRef.appendChild(
  118. this._additionalContentTemplate.content.cloneNode(true));
  119. }
  120. if (this._shouldShowAdditionalToolbarContent()) {
  121. this._additionalToolbarContentRef.appendChild(
  122. this._additionalToolbarContentTemplate.content.cloneNode(true)
  123. );
  124. }
  125. if (this._shouldShowAdditionalCard()) {
  126. this._additionalCardRef.appendChild(
  127. this._additionalCardTemplate.content.cloneNode(true)
  128. );
  129. }
  130. }
  131. /**
  132. * Removes the classname used for custom styling of the welcome page.
  133. *
  134. * @inheritdoc
  135. * @returns {void}
  136. */
  137. componentWillUnmount() {
  138. super.componentWillUnmount();
  139. document.body.classList.remove('welcome-page');
  140. }
  141. /**
  142. * Implements React's {@link Component#render()}.
  143. *
  144. * @inheritdoc
  145. * @returns {ReactElement|null}
  146. */
  147. render() {
  148. const { _moderatedRoomServiceUrl, t } = this.props;
  149. const { DEFAULT_WELCOME_PAGE_LOGO_URL, DISPLAY_WELCOME_FOOTER } = interfaceConfig;
  150. const showAdditionalCard = this._shouldShowAdditionalCard();
  151. const showAdditionalContent = this._shouldShowAdditionalContent();
  152. const showAdditionalToolbarContent = this._shouldShowAdditionalToolbarContent();
  153. const contentClassName = showAdditionalContent ? 'with-content' : 'without-content';
  154. const footerClassName = DISPLAY_WELCOME_FOOTER ? 'with-footer' : 'without-footer';
  155. return (
  156. <div
  157. className = { `welcome ${contentClassName} ${footerClassName}` }
  158. id = 'welcome_page'>
  159. <div className = 'header'>
  160. <div className = 'header-image' />
  161. <div className = 'header-container'>
  162. <div className = 'header-watermark-container'>
  163. <div className = 'welcome-watermark'>
  164. <Watermarks
  165. defaultJitsiLogoURL = { DEFAULT_WELCOME_PAGE_LOGO_URL }
  166. noMargins = { true } />
  167. </div>
  168. </div>
  169. <div className = 'welcome-page-settings'>
  170. <SettingsButton
  171. defaultTab = { SETTINGS_TABS.CALENDAR }
  172. isDisplayedOnWelcomePage = { true } />
  173. { showAdditionalToolbarContent
  174. ? <div
  175. className = 'settings-toolbar-content'
  176. ref = { this._setAdditionalToolbarContentRef } />
  177. : null
  178. }
  179. </div>
  180. <h1 className = 'header-text-title'>
  181. { t('welcomepage.headerTitle') }
  182. </h1>
  183. <span className = 'header-text-subtitle'>
  184. { t('welcomepage.headerSubtitle')}
  185. </span>
  186. <div id = 'enter_room'>
  187. <div className = 'enter-room-input-container'>
  188. <form onSubmit = { this._onFormSubmit }>
  189. <input
  190. aria-disabled = 'false'
  191. aria-label = 'Meeting name input'
  192. autoFocus = { true }
  193. className = 'enter-room-input'
  194. id = 'enter_room_field'
  195. onChange = { this._onRoomChange }
  196. pattern = { ROOM_NAME_VALIDATE_PATTERN_STR }
  197. placeholder = { this.state.roomPlaceholder }
  198. ref = { this._setRoomInputRef }
  199. title = { t('welcomepage.roomNameAllowedChars') }
  200. type = 'text'
  201. value = { this.state.room } />
  202. <div
  203. className = { _moderatedRoomServiceUrl
  204. ? 'warning-with-link'
  205. : 'warning-without-link' }>
  206. { this._renderInsecureRoomNameWarning() }
  207. </div>
  208. </form>
  209. </div>
  210. <button
  211. aria-disabled = 'false'
  212. aria-label = 'Start meeting'
  213. className = 'welcome-page-button'
  214. id = 'enter_room_button'
  215. onClick = { this._onFormSubmit }
  216. tabIndex = '0'
  217. type = 'button'>
  218. { t('welcomepage.startMeeting') }
  219. </button>
  220. </div>
  221. { _moderatedRoomServiceUrl && (
  222. <div id = 'moderated-meetings'>
  223. {
  224. translateToHTML(
  225. t, 'welcomepage.moderatedMessage', { url: _moderatedRoomServiceUrl })
  226. }
  227. </div>)}
  228. </div>
  229. </div>
  230. <div className = 'welcome-cards-container'>
  231. <div className = 'welcome-card-column'>
  232. <div className = 'welcome-tabs welcome-card welcome-card--blue'>
  233. { this._renderTabs() }
  234. </div>
  235. { showAdditionalCard
  236. ? <div
  237. className = 'welcome-card welcome-card--dark'
  238. ref = { this._setAdditionalCardRef } />
  239. : null }
  240. </div>
  241. { showAdditionalContent
  242. ? <div
  243. className = 'welcome-page-content'
  244. ref = { this._setAdditionalContentRef } />
  245. : null }
  246. </div>
  247. { DISPLAY_WELCOME_FOOTER && this._renderFooter()}
  248. </div>
  249. );
  250. }
  251. /**
  252. * Renders the insecure room name warning.
  253. *
  254. * @inheritdoc
  255. */
  256. _doRenderInsecureRoomNameWarning() {
  257. return (
  258. <div className = 'insecure-room-name-warning'>
  259. <Icon src = { IconWarning } />
  260. <span>
  261. { this.props.t('security.insecureRoomNameWarning') }
  262. </span>
  263. </div>
  264. );
  265. }
  266. /**
  267. * Prevents submission of the form and delegates join logic.
  268. *
  269. * @param {Event} event - The HTML Event which details the form submission.
  270. * @private
  271. * @returns {void}
  272. */
  273. _onFormSubmit(event) {
  274. event.preventDefault();
  275. if (!this._roomInputRef || this._roomInputRef.reportValidity()) {
  276. this._onJoin();
  277. }
  278. }
  279. /**
  280. * Overrides the super to account for the differences in the argument types
  281. * provided by HTML and React Native text inputs.
  282. *
  283. * @inheritdoc
  284. * @override
  285. * @param {Event} event - The (HTML) Event which details the change such as
  286. * the EventTarget.
  287. * @protected
  288. */
  289. _onRoomChange(event) {
  290. super._onRoomChange(event.target.value);
  291. }
  292. /**
  293. * Renders the footer.
  294. *
  295. * @returns {ReactElement}
  296. */
  297. _renderFooter() {
  298. const {
  299. t,
  300. _deeplinkingCfg: {
  301. ios = {},
  302. android = {}
  303. }
  304. } = this.props;
  305. const { downloadLink: iosDownloadLink } = ios;
  306. const { fDroidUrl, downloadLink: androidDownloadLink } = android;
  307. return (<footer className = 'welcome-footer'>
  308. <div className = 'welcome-footer-centered'>
  309. <div className = 'welcome-footer-padded'>
  310. <div className = 'welcome-footer-row-block welcome-footer--row-1'>
  311. <div className = 'welcome-footer-row-1-text'>{t('welcomepage.jitsiOnMobile')}</div>
  312. <a
  313. className = 'welcome-badge'
  314. href = { iosDownloadLink }>
  315. <img
  316. alt = { t('welcomepage.mobileDownLoadLinkIos') }
  317. src = './images/app-store-badge.png' />
  318. </a>
  319. <a
  320. className = 'welcome-badge'
  321. href = { androidDownloadLink }>
  322. <img
  323. alt = { t('welcomepage.mobileDownLoadLinkAndroid') }
  324. src = './images/google-play-badge.png' />
  325. </a>
  326. <a
  327. className = 'welcome-badge'
  328. href = { fDroidUrl }>
  329. <img
  330. alt = { t('welcomepage.mobileDownLoadLinkFDroid') }
  331. src = './images/f-droid-badge.png' />
  332. </a>
  333. </div>
  334. </div>
  335. </div>
  336. </footer>);
  337. }
  338. /**
  339. * Renders tabs to show previous meetings and upcoming calendar events. The
  340. * tabs are purposefully hidden on mobile browsers.
  341. *
  342. * @returns {ReactElement|null}
  343. */
  344. _renderTabs() {
  345. if (isMobileBrowser()) {
  346. return null;
  347. }
  348. const { _calendarEnabled, _recentListEnabled, t } = this.props;
  349. const tabs = [];
  350. if (_calendarEnabled) {
  351. tabs.push({
  352. id: 'calendar',
  353. label: t('welcomepage.upcomingMeetings'),
  354. content: <CalendarList />
  355. });
  356. }
  357. if (_recentListEnabled) {
  358. tabs.push({
  359. id: 'recent',
  360. label: t('welcomepage.recentMeetings'),
  361. content: <RecentList />
  362. });
  363. }
  364. if (tabs.length === 0) {
  365. return null;
  366. }
  367. return (
  368. <Tabs
  369. accessibilityLabel = { t('welcomepage.meetingsAccessibilityLabel') }
  370. tabs = { tabs } />
  371. );
  372. }
  373. /**
  374. * Sets the internal reference to the HTMLDivElement used to hold the
  375. * additional card shown near the tabs card.
  376. *
  377. * @param {HTMLDivElement} el - The HTMLElement for the div that is the root
  378. * of the welcome page content.
  379. * @private
  380. * @returns {void}
  381. */
  382. _setAdditionalCardRef(el) {
  383. this._additionalCardRef = el;
  384. }
  385. /**
  386. * Sets the internal reference to the HTMLDivElement used to hold the
  387. * welcome page content.
  388. *
  389. * @param {HTMLDivElement} el - The HTMLElement for the div that is the root
  390. * of the welcome page content.
  391. * @private
  392. * @returns {void}
  393. */
  394. _setAdditionalContentRef(el) {
  395. this._additionalContentRef = el;
  396. }
  397. /**
  398. * Sets the internal reference to the HTMLDivElement used to hold the
  399. * toolbar additional content.
  400. *
  401. * @param {HTMLDivElement} el - The HTMLElement for the div that is the root
  402. * of the additional toolbar content.
  403. * @private
  404. * @returns {void}
  405. */
  406. _setAdditionalToolbarContentRef(el) {
  407. this._additionalToolbarContentRef = el;
  408. }
  409. /**
  410. * Sets the internal reference to the HTMLInputElement used to hold the
  411. * welcome page input room element.
  412. *
  413. * @param {HTMLInputElement} el - The HTMLElement for the input of the room name on the welcome page.
  414. * @private
  415. * @returns {void}
  416. */
  417. _setRoomInputRef(el) {
  418. this._roomInputRef = el;
  419. }
  420. /**
  421. * Returns whether or not an additional card should be displayed near the tabs.
  422. *
  423. * @private
  424. * @returns {boolean}
  425. */
  426. _shouldShowAdditionalCard() {
  427. return interfaceConfig.DISPLAY_WELCOME_PAGE_ADDITIONAL_CARD
  428. && this._additionalCardTemplate
  429. && this._additionalCardTemplate.content
  430. && this._additionalCardTemplate.innerHTML.trim();
  431. }
  432. /**
  433. * Returns whether or not additional content should be displayed below
  434. * the welcome page's header for entering a room name.
  435. *
  436. * @private
  437. * @returns {boolean}
  438. */
  439. _shouldShowAdditionalContent() {
  440. return interfaceConfig.DISPLAY_WELCOME_PAGE_CONTENT
  441. && this._additionalContentTemplate
  442. && this._additionalContentTemplate.content
  443. && this._additionalContentTemplate.innerHTML.trim();
  444. }
  445. /**
  446. * Returns whether or not additional content should be displayed inside
  447. * the header toolbar.
  448. *
  449. * @private
  450. * @returns {boolean}
  451. */
  452. _shouldShowAdditionalToolbarContent() {
  453. return interfaceConfig.DISPLAY_WELCOME_PAGE_TOOLBAR_ADDITIONAL_CONTENT
  454. && this._additionalToolbarContentTemplate
  455. && this._additionalToolbarContentTemplate.content
  456. && this._additionalToolbarContentTemplate.innerHTML.trim();
  457. }
  458. }
  459. export default translate(connect(_mapStateToProps)(WelcomePage));