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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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 '../../base/redux';
  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 {
  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 { 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(
  99. `${_TNS}.${isSupportedBrowser()
  100. ? 'description'
  101. : 'descriptionWithoutWeb'}`,
  102. { app: NATIVE_APP_NAME }
  103. )
  104. }
  105. </p>
  106. <div className = 'buttons'>
  107. <ButtonGroup>
  108. <Button
  109. appearance = 'default'
  110. onClick = { this._onTryAgain }>
  111. { t(`${_TNS}.tryAgainButton`) }
  112. </Button>
  113. {
  114. isSupportedBrowser()
  115. && <Button onClick = { this._onLaunchWeb }>
  116. { t(`${_TNS}.launchWebButton`) }
  117. </Button>
  118. }
  119. </ButtonGroup>
  120. </div>
  121. </div>
  122. </div>
  123. </div>
  124. </div>
  125. </AtlasKitThemeProvider>
  126. );
  127. }
  128. _onTryAgain: () => void;
  129. /**
  130. * Handles try again button clicks.
  131. *
  132. * @returns {void}
  133. */
  134. _onTryAgain() {
  135. sendAnalytics(
  136. createDeepLinkingPageEvent(
  137. 'clicked', 'tryAgainButton', { isMobileBrowser: false }));
  138. this.props.dispatch(openDesktopApp());
  139. }
  140. _onLaunchWeb: () => void;
  141. /**
  142. * Handles launch web button clicks.
  143. *
  144. * @returns {void}
  145. */
  146. _onLaunchWeb() {
  147. sendAnalytics(
  148. createDeepLinkingPageEvent(
  149. 'clicked', 'launchWebButton', { isMobileBrowser: false }));
  150. this.props.dispatch(openWebApp());
  151. }
  152. }
  153. export default translate(connect()(DeepLinkingDesktopPage));