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.8KB

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