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 6.0KB

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