jiti-meet/react/features/unsupported-browser/components/UnsupportedMobileBrowser.js

165 lines
4.5 KiB
JavaScript
Raw Normal View History

2017-02-07 14:45:51 +00:00
/* @flow */
2016-12-23 16:21:51 +00:00
import React, { Component } from 'react';
import { connect } from 'react-redux';
2017-01-13 22:37:53 +00:00
2017-03-01 02:55:12 +00:00
import { translate, translateToHTML } from '../../base/i18n';
import { Platform } from '../../base/react';
import HideNotificationBarStyle from './HideNotificationBarStyle';
2017-02-16 20:00:54 +00:00
2017-03-01 02:55:12 +00:00
/**
* The namespace of the CSS styles of UnsupportedMobileBrowser.
*
* @private
* @type {string}
*/
const _SNS = 'unsupported-mobile-browser';
/**
* The namespace of the i18n/translation keys of UnsupportedMobileBrowser.
*
* @private
* @type {string}
*/
const _TNS = 'unsupportedBrowser';
/**
* The map of platforms to URLs at which the mobile app for the associated
* platform is available for download.
2017-02-01 04:25:09 +00:00
*
* @private
2017-03-01 02:55:12 +00:00
* @type {Array<string>}
*/
2017-02-01 04:25:09 +00:00
const _URLS = {
android: 'https://play.google.com/store/apps/details?id=org.jitsi.meet',
ios: 'https://itunes.apple.com/us/app/jitsi-meet/id1165103905'
2016-12-23 16:21:51 +00:00
};
/**
2017-01-19 15:47:22 +00:00
* React component representing mobile browser page.
2016-12-23 16:21:51 +00:00
*
2017-01-25 22:11:44 +00:00
* @class UnsupportedMobileBrowser
2016-12-23 16:21:51 +00:00
*/
2017-01-25 22:11:44 +00:00
class UnsupportedMobileBrowser extends Component {
2017-02-07 14:45:51 +00:00
state: Object;
2017-01-25 22:11:44 +00:00
/**
2017-02-01 04:25:09 +00:00
* UnsupportedMobileBrowser component's property types.
2017-01-25 22:11:44 +00:00
*
* @static
*/
static propTypes = {
/**
* The name of the conference room to be joined upon clicking the
* respective button.
*
* @private
* @type {string}
*/
_room: React.PropTypes.string,
2017-03-01 02:55:12 +00:00
/**
* The function to translate human-readable text.
*
* @public
* @type {Function}
*/
t: React.PropTypes.func
2017-01-25 22:11:44 +00:00
}
2017-01-18 12:21:30 +00:00
/**
2017-02-01 04:25:09 +00:00
* Initializes the text and URL of the `Start a conference` / `Join the
* conversation` button which takes the user to the mobile app.
2017-01-18 12:21:30 +00:00
*
2017-02-01 04:25:09 +00:00
* @inheritdoc
2016-12-23 16:21:51 +00:00
*/
componentWillMount() {
2017-02-01 04:25:09 +00:00
const joinText
2017-03-01 02:55:12 +00:00
= this.props._room ? 'joinConversation' : 'startConference';
2016-12-23 16:21:51 +00:00
2017-02-01 04:25:09 +00:00
// If the user installed the app while this Component was displayed
// (e.g. the user clicked the Download the App button), then we would
// like to open the current URL in the mobile app. The only way to do it
// appears to be a link with an app-specific scheme, not a Universal
// Link.
const joinURL = `org.jitsi.meet:${window.location.href}`;
2016-12-23 16:21:51 +00:00
this.setState({
2017-02-01 04:25:09 +00:00
joinText,
joinURL
2016-12-23 16:21:51 +00:00
});
}
/**
2017-02-01 04:25:09 +00:00
* Implements React's {@link Component#render()}.
2016-12-23 16:21:51 +00:00
*
2017-02-01 04:25:09 +00:00
* @inheritdoc
2016-12-23 16:21:51 +00:00
* @returns {ReactElement}
*/
render() {
const { t } = this.props;
2016-12-23 16:21:51 +00:00
2017-03-01 02:55:12 +00:00
const downloadButtonClassName
= `${_SNS}__button ${_SNS}__button_primary`;
2016-12-23 16:21:51 +00:00
return (
2017-03-01 02:55:12 +00:00
<div className = { _SNS }>
<div className = { `${_SNS}__body` }>
2016-12-23 16:21:51 +00:00
<img
2017-03-01 02:55:12 +00:00
className = { `${_SNS}__logo` }
src = 'images/logo-blue.svg' />
2017-03-01 02:55:12 +00:00
<p className = { `${_SNS}__text` }>
{
translateToHTML(
t,
`${_TNS}.appNotInstalled`,
{ postProcess: 'resolveAppName' })
}
2016-12-23 16:21:51 +00:00
</p>
2017-02-01 04:25:09 +00:00
<a href = { _URLS[Platform.OS] }>
<button className = { downloadButtonClassName }>
2017-03-01 02:55:12 +00:00
{ t(`${_TNS}.downloadApp`) }
2016-12-23 16:21:51 +00:00
</button>
</a>
2017-03-01 02:55:12 +00:00
<p className = { `${_SNS}__text ${_SNS}__text_small` }>
{ translateToHTML(t, `${_TNS}.appInstalled`) }
2016-12-23 16:21:51 +00:00
</p>
2017-02-01 04:25:09 +00:00
<a href = { this.state.joinURL }>
2017-03-01 02:55:12 +00:00
<button className = { `${_SNS}__button` }>
{ t(`${_TNS}.${this.state.joinText}`) }
2017-02-01 04:25:09 +00:00
</button>
</a>
2016-12-23 16:21:51 +00:00
</div>
<HideNotificationBarStyle />
2016-12-23 16:21:51 +00:00
</div>
);
}
}
2017-01-13 22:37:53 +00:00
/**
2017-01-25 22:11:44 +00:00
* Maps (parts of) the Redux state to the associated UnsupportedMobileBrowser's
* props.
2017-01-13 22:37:53 +00:00
*
* @param {Object} state - Redux state.
* @private
2017-01-13 22:37:53 +00:00
* @returns {{
* _room: string
2017-01-13 22:37:53 +00:00
* }}
*/
function _mapStateToProps(state) {
return {
/**
* The name of the conference room to be joined upon clicking the
* respective button.
*
* @private
* @type {string}
*/
_room: state['features/base/conference'].room
};
2017-01-13 22:37:53 +00:00
}
export default translate(connect(_mapStateToProps)(UnsupportedMobileBrowser));