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

147 lines
3.6 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';
2017-01-18 12:21:30 +00:00
import { appNavigate } from '../../app';
2016-12-23 16:21:51 +00:00
import { landingIsShown } from '../actions';
/**
* The map of platforms to URLs at which the mobile app for the associated
* platform is available for download.
*/
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
};
/**
* React component representing mobile landing page.
*
* @class Landing
*/
class Landing extends Component {
2017-01-18 12:21:30 +00:00
/**
* Constructor of Landing component.
*
* @param {Object} props - The read-only React Component props with which
* the new instance is to be initialized.
*/
constructor(props) {
super(props);
// Bind methods
this._onClickJoin = this._onClickJoin.bind(this);
}
/**
* Landing component's property types.
*
* @static
*/
2017-01-13 22:37:53 +00:00
static propTypes = {
dispatch: React.PropTypes.func,
room: React.PropTypes.string
}
2016-12-23 16:21:51 +00:00
/**
2017-01-13 22:37:53 +00:00
* React lifecycle method triggered after component is mounted.
2016-12-23 16:21:51 +00:00
*
* @returns {void}
*/
componentDidMount() {
this.props.dispatch(landingIsShown());
}
/**
2017-01-13 22:37:53 +00:00
* React lifecycle method triggered before component will mount.
2016-12-23 16:21:51 +00:00
*
* @returns {void}
*/
componentWillMount() {
const { room } = this.props;
2016-12-23 16:21:51 +00:00
let btnText;
2017-01-18 12:21:30 +00:00
let link = '';
2016-12-23 16:21:51 +00:00
if (room) {
2016-12-23 16:21:51 +00:00
btnText = 'Join the conversation';
link += room;
2016-12-23 16:21:51 +00:00
} else {
btnText = 'Start a conference';
}
this.setState({
btnText,
link
2016-12-23 16:21:51 +00:00
});
}
2017-01-18 12:21:30 +00:00
/**
* Navigates to the next state of the app.
*
* @returns {void}
* @private
*/
_onClickJoin() {
const { link } = this.state;
this.props.dispatch(appNavigate(link));
}
2016-12-23 16:21:51 +00:00
/**
* Renders landing component.
*
* @returns {ReactElement}
*/
render() {
2017-01-18 12:21:30 +00:00
const { btnText } = this.state;
2016-12-23 16:21:51 +00:00
const primaryButtonClasses = 'landing__button landing__button_primary';
return (
<div className = 'landing'>
<div className = 'landing__body'>
<img
className = 'landing__logo'
src = '/images/logo-blue.svg' />
<p className = 'landing__text'>
You need <strong>Jitsi Meet</strong> to join a
conversation on your mobile
2016-12-23 16:21:51 +00:00
</p>
<a href = { URLS[Platform.OS] }>
<button className = { primaryButtonClasses }>
2016-12-23 16:21:51 +00:00
Download the App
</button>
</a>
<p className = 'landing__text landing__text_small'>
or if you already have it
<br />
<strong>then</strong>
2016-12-23 16:21:51 +00:00
</p>
2017-01-18 12:21:30 +00:00
<button
className = 'landing__button'
onClick = { this._onClickJoin }>
{ btnText }
</button>
2016-12-23 16:21:51 +00:00
</div>
</div>
);
}
}
2017-01-13 22:37:53 +00:00
/**
* Maps (parts of) the Redux state to the associated Landing's props.
*
* @param {Object} state - Redux state.
* @returns {{
* room: string
* }}
*/
function mapStateToProps(state) {
return {
room: state['features/base/conference'].room
};
2017-01-13 22:37:53 +00:00
}
export default connect(mapStateToProps)(Landing);