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

DeepLinkingDesktopPage.web.js 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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._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. sendAnalytics(
  54. createDeepLinkingPageEvent(
  55. 'displayed', 'DeepLinkingDesktop', { isMobileBrowser: false }));
  56. }
  57. /**
  58. * Renders the component.
  59. *
  60. * @returns {ReactElement}
  61. */
  62. render() {
  63. const { t } = this.props;
  64. const { NATIVE_APP_NAME, SHOW_DEEP_LINKING_IMAGE } = interfaceConfig;
  65. const rightColumnStyle
  66. = SHOW_DEEP_LINKING_IMAGE ? null : { width: '100%' };
  67. return (
  68. // Enabling light theme because of the color of the buttons.
  69. <AtlasKitThemeProvider mode = 'light'>
  70. <div className = 'deep-linking-desktop'>
  71. <div className = 'header'>
  72. <img
  73. className = 'logo'
  74. src = 'images/logo-deep-linking.png' />
  75. </div>
  76. <div className = 'content'>
  77. {
  78. SHOW_DEEP_LINKING_IMAGE
  79. ? <div className = 'leftColumn'>
  80. <div className = 'leftColumnContent'>
  81. <div className = 'image' />
  82. </div>
  83. </div> : null
  84. }
  85. <div
  86. className = 'rightColumn'
  87. style = { rightColumnStyle }>
  88. <div className = 'rightColumnContent'>
  89. <h1 className = 'title'>
  90. {
  91. t(`${_TNS}.title`,
  92. { app: NATIVE_APP_NAME })
  93. }
  94. </h1>
  95. <p className = 'description'>
  96. {
  97. t(`${_TNS}.description`,
  98. { app: NATIVE_APP_NAME })
  99. }
  100. </p>
  101. <div className = 'buttons'>
  102. <ButtonGroup>
  103. <Button
  104. appearance = 'default'
  105. onClick = { this._onTryAgain }>
  106. { t(`${_TNS}.tryAgainButton`) }
  107. </Button>
  108. <Button onClick = { this._onLaunchWeb }>
  109. { t(`${_TNS}.launchWebButton`) }
  110. </Button>
  111. </ButtonGroup>
  112. </div>
  113. </div>
  114. </div>
  115. </div>
  116. </div>
  117. </AtlasKitThemeProvider>
  118. );
  119. }
  120. _onTryAgain: () => {}
  121. /**
  122. * Handles try again button clicks.
  123. *
  124. * @returns {void}
  125. */
  126. _onTryAgain() {
  127. sendAnalytics(
  128. createDeepLinkingPageEvent(
  129. 'clicked', 'tryAgainButton', { isMobileBrowser: false }));
  130. this.props.dispatch(openDesktopApp());
  131. }
  132. _onLaunchWeb: () => {}
  133. /**
  134. * Handles launch web button clicks.
  135. *
  136. * @returns {void}
  137. */
  138. _onLaunchWeb() {
  139. sendAnalytics(
  140. createDeepLinkingPageEvent(
  141. 'clicked', 'launchWebButton', { isMobileBrowser: false }));
  142. this.props.dispatch(openWebApp());
  143. }
  144. }
  145. export default translate(connect()(DeepLinkingDesktopPage));