You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DeepLinkingDesktopPage.web.js 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /* @flow */
  2. import Button, { ButtonGroup } from '@atlaskit/button';
  3. import { AtlasKitThemeProvider } from '@atlaskit/theme';
  4. import React, { Component } from 'react';
  5. import { connect } from 'react-redux';
  6. import { createDeepLinkingPageEvent, sendAnalytics } from '../../analytics';
  7. import { translate } from '../../base/i18n';
  8. import {
  9. openWebApp,
  10. openDesktopApp
  11. } from '../actions';
  12. import { _TNS } from '../constants';
  13. declare var interfaceConfig: Object;
  14. /**
  15. * The type of the React {@code Component} props of
  16. * {@link DeepLinkingDesktopPage}.
  17. */
  18. type Props = {
  19. /**
  20. * Used to dispatch actions from the buttons.
  21. */
  22. dispatch: Dispatch<*>,
  23. /**
  24. * Used to obtain translations.
  25. */
  26. t: Function
  27. };
  28. /**
  29. * React component representing the deep linking page.
  30. *
  31. * @class DeepLinkingDesktopPage
  32. */
  33. class DeepLinkingDesktopPage<P : Props> extends Component<P> {
  34. /**
  35. * Initializes a new {@code DeepLinkingDesktopPage} instance.
  36. *
  37. * @param {Object} props - The read-only React {@code Component} props with
  38. * which the new instance is to be initialized.
  39. */
  40. constructor(props: P) {
  41. super(props);
  42. // Bind event handlers so they are only bound once per instance.
  43. this._openDesktopApp = this._openDesktopApp.bind(this);
  44. this._onLaunchWeb = this._onLaunchWeb.bind(this);
  45. this._onTryAgain = this._onTryAgain.bind(this);
  46. }
  47. /**
  48. * Implements the Component's componentDidMount method.
  49. *
  50. * @inheritdoc
  51. */
  52. componentDidMount() {
  53. this._openDesktopApp();
  54. sendAnalytics(
  55. createDeepLinkingPageEvent(
  56. 'displayed', 'DeepLinkingDesktop', { isMobileBrowser: false }));
  57. }
  58. /**
  59. * Renders the component.
  60. *
  61. * @returns {ReactElement}
  62. */
  63. render() {
  64. const { t } = this.props;
  65. const { NATIVE_APP_NAME, SHOW_DEEP_LINKING_IMAGE } = interfaceConfig;
  66. const rightColumnStyle
  67. = SHOW_DEEP_LINKING_IMAGE ? null : { width: '100%' };
  68. return (
  69. // Enabling light theme because of the color of the buttons.
  70. <AtlasKitThemeProvider mode = 'light'>
  71. <div className = 'deep-linking-desktop'>
  72. <div className = 'header'>
  73. <img
  74. className = 'logo'
  75. src = 'images/logo-deep-linking.png' />
  76. </div>
  77. <div className = 'content'>
  78. {
  79. SHOW_DEEP_LINKING_IMAGE
  80. ? <div className = 'leftColumn'>
  81. <div className = 'leftColumnContent'>
  82. <div className = 'image' />
  83. </div>
  84. </div> : null
  85. }
  86. <div
  87. className = 'rightColumn'
  88. style = { rightColumnStyle }>
  89. <div className = 'rightColumnContent'>
  90. <h1 className = 'title'>
  91. {
  92. t(`${_TNS}.title`,
  93. { app: NATIVE_APP_NAME })
  94. }
  95. </h1>
  96. <p className = 'description'>
  97. {
  98. t(`${_TNS}.description`,
  99. { app: NATIVE_APP_NAME })
  100. }
  101. </p>
  102. <div className = 'buttons'>
  103. <ButtonGroup>
  104. <Button
  105. appearance = 'default'
  106. onClick = { this._onTryAgain }>
  107. { t(`${_TNS}.tryAgainButton`) }
  108. </Button>
  109. <Button onClick = { this._onLaunchWeb }>
  110. { t(`${_TNS}.launchWebButton`) }
  111. </Button>
  112. </ButtonGroup>
  113. </div>
  114. </div>
  115. </div>
  116. </div>
  117. </div>
  118. </AtlasKitThemeProvider>
  119. );
  120. }
  121. _openDesktopApp: () => {}
  122. /**
  123. * Dispatches the <tt>openDesktopApp</tt> action.
  124. *
  125. * @returns {void}
  126. */
  127. _openDesktopApp() {
  128. this.props.dispatch(openDesktopApp());
  129. }
  130. _onTryAgain: () => {}
  131. /**
  132. * Handles try again button clicks.
  133. *
  134. * @returns {void}
  135. */
  136. _onTryAgain() {
  137. sendAnalytics(
  138. createDeepLinkingPageEvent(
  139. 'clicked', 'tryAgainButton', { isMobileBrowser: false }));
  140. this._openDesktopApp();
  141. }
  142. _onLaunchWeb: () => {}
  143. /**
  144. * Handles launch web button clicks.
  145. *
  146. * @returns {void}
  147. */
  148. _onLaunchWeb() {
  149. sendAnalytics(
  150. createDeepLinkingPageEvent(
  151. 'clicked', 'launchWebButton', { isMobileBrowser: false }));
  152. this.props.dispatch(openWebApp());
  153. }
  154. }
  155. export default translate(connect()(DeepLinkingDesktopPage));