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

129 lines
3.7 KiB
JavaScript
Raw Normal View History

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
import { Platform } from '../../base/react';
/**
* 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-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-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-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
= this.props._room ? 'Join the conversation' : 'Start a conference';
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() {
2017-01-25 22:11:44 +00:00
const ns = 'unsupported-mobile-browser';
const downloadButtonClassName = `${ns}__button ${ns}__button_primary`;
2016-12-23 16:21:51 +00:00
return (
2017-01-25 22:11:44 +00:00
<div className = { ns }>
<div className = { `${ns}__body` }>
2016-12-23 16:21:51 +00:00
<img
2017-01-25 22:11:44 +00:00
className = { `${ns}__logo` }
2016-12-23 16:21:51 +00:00
src = '/images/logo-blue.svg' />
2017-01-25 22:11:44 +00:00
<p className = { `${ns}__text` }>
You need <strong>Jitsi Meet</strong> to join a
conversation on your mobile
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 }>
2016-12-23 16:21:51 +00:00
Download the App
</button>
</a>
2017-01-25 22:11:44 +00:00
<p className = { `${ns}__text ${ns}__text_small` }>
or if you already have it
<br />
<strong>then</strong>
2016-12-23 16:21:51 +00:00
</p>
2017-02-01 04:25:09 +00:00
<a href = { this.state.joinURL }>
<button className = { `${ns}__button` }>
{
this.state.joinText
}
</button>
</a>
2016-12-23 16:21:51 +00:00
</div>
</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 connect(_mapStateToProps)(UnsupportedMobileBrowser);