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