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.js 4.9KB

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