|
@@ -0,0 +1,56 @@
|
|
1
|
+// @flow
|
|
2
|
+
|
|
3
|
+import { createToolbarEvent, sendAnalytics } from '../../analytics';
|
|
4
|
+import { translate } from '../../base/i18n';
|
|
5
|
+import { IconDownload } from '../../base/icons';
|
|
6
|
+import { connect } from '../../base/redux';
|
|
7
|
+import { openURLInBrowser } from '../../base/util';
|
|
8
|
+import { AbstractButton, type AbstractButtonProps } from '../../base/toolbox';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+type Props = AbstractButtonProps & {
|
|
12
|
+
|
|
13
|
+ /**
|
|
14
|
+ * The URL to the applications page.
|
|
15
|
+ */
|
|
16
|
+ _downloadAppsUrl: string
|
|
17
|
+};
|
|
18
|
+
|
|
19
|
+/**
|
|
20
|
+ * Implements an {@link AbstractButton} to open the applications page in a new window.
|
|
21
|
+ */
|
|
22
|
+class DownloadButton extends AbstractButton<Props, *> {
|
|
23
|
+ accessibilityLabel = 'toolbar.accessibilityLabel.download';
|
|
24
|
+ icon = IconDownload;
|
|
25
|
+ label = 'toolbar.download';
|
|
26
|
+
|
|
27
|
+ /**
|
|
28
|
+ * Handles clicking / pressing the button, and opens a new window with the user documentation.
|
|
29
|
+ *
|
|
30
|
+ * @private
|
|
31
|
+ * @returns {void}
|
|
32
|
+ */
|
|
33
|
+ _handleClick() {
|
|
34
|
+ sendAnalytics(createToolbarEvent('download.pressed'));
|
|
35
|
+ openURLInBrowser(this.props._downloadAppsUrl);
|
|
36
|
+ }
|
|
37
|
+}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+/**
|
|
41
|
+ * Maps part of the redux state to the component's props.
|
|
42
|
+ *
|
|
43
|
+ * @param {Object} state - The redux store/state.
|
|
44
|
+ * @returns {Object}
|
|
45
|
+ */
|
|
46
|
+function _mapStateToProps(state: Object) {
|
|
47
|
+ const { downloadAppsUrl } = state['features/base/config'].deploymentUrls || {};
|
|
48
|
+ const visible = typeof downloadAppsUrl === 'string';
|
|
49
|
+
|
|
50
|
+ return {
|
|
51
|
+ _downloadAppsUrl: downloadAppsUrl,
|
|
52
|
+ visible
|
|
53
|
+ };
|
|
54
|
+}
|
|
55
|
+
|
|
56
|
+export default translate(connect(_mapStateToProps)(DownloadButton));
|