2019-10-16 11:11:02 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import { createToolbarEvent, sendAnalytics } from '../../analytics';
|
|
|
|
import { translate } from '../../base/i18n';
|
|
|
|
import { IconDownload } from '../../base/icons';
|
|
|
|
import { connect } from '../../base/redux';
|
2020-07-24 12:14:33 +00:00
|
|
|
import { AbstractButton, type AbstractButtonProps } from '../../base/toolbox/components';
|
2020-05-20 10:57:03 +00:00
|
|
|
import { openURLInBrowser } from '../../base/util';
|
2019-10-16 11:11:02 +00:00
|
|
|
|
|
|
|
type Props = AbstractButtonProps & {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The URL to the applications page.
|
|
|
|
*/
|
|
|
|
_downloadAppsUrl: string
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements an {@link AbstractButton} to open the applications page in a new window.
|
|
|
|
*/
|
|
|
|
class DownloadButton extends AbstractButton<Props, *> {
|
|
|
|
accessibilityLabel = 'toolbar.accessibilityLabel.download';
|
|
|
|
icon = IconDownload;
|
|
|
|
label = 'toolbar.download';
|
2021-07-08 13:42:07 +00:00
|
|
|
tooltip = 'toolbar.download';
|
2019-10-16 11:11:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles clicking / pressing the button, and opens a new window with the user documentation.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_handleClick() {
|
2022-01-04 11:21:00 +00:00
|
|
|
const { _downloadAppsUrl } = this.props;
|
2021-09-14 07:07:20 +00:00
|
|
|
|
2019-10-16 11:11:02 +00:00
|
|
|
sendAnalytics(createToolbarEvent('download.pressed'));
|
2021-09-14 07:07:20 +00:00
|
|
|
openURLInBrowser(_downloadAppsUrl);
|
2019-10-16 11:11:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps part of the redux state to the component's props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The redux store/state.
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
|
|
|
function _mapStateToProps(state: Object) {
|
|
|
|
const { downloadAppsUrl } = state['features/base/config'].deploymentUrls || {};
|
2022-06-09 13:00:41 +00:00
|
|
|
const visible = typeof downloadAppsUrl === 'string';
|
2019-10-16 11:11:02 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
_downloadAppsUrl: downloadAppsUrl,
|
|
|
|
visible
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default translate(connect(_mapStateToProps)(DownloadButton));
|