您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

DeepLinkingDesktopPage.web.js 5.5KB

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