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

DeepLinkingDesktopPage.web.js 6.3KB

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