2019-10-11 18:09:50 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import { createToolbarEvent, sendAnalytics } from '../../analytics';
|
2021-02-10 21:34:13 +00:00
|
|
|
import { getFeatureFlag, HELP_BUTTON_ENABLED } from '../../base/flags';
|
2019-10-11 18:09:50 +00:00
|
|
|
import { translate } from '../../base/i18n';
|
|
|
|
import { IconHelp } 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';
|
2021-05-11 09:17:55 +00:00
|
|
|
import { isVpaasMeeting } from '../../billing-counter/functions';
|
2019-10-11 18:09:50 +00:00
|
|
|
|
|
|
|
type Props = AbstractButtonProps & {
|
|
|
|
|
|
|
|
/**
|
2021-03-16 15:59:33 +00:00
|
|
|
* The URL to the user documentation.
|
2019-10-11 18:09:50 +00:00
|
|
|
*/
|
|
|
|
_userDocumentationURL: string
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements an {@link AbstractButton} to open the user documentation in a new window.
|
|
|
|
*/
|
|
|
|
class HelpButton extends AbstractButton<Props, *> {
|
|
|
|
accessibilityLabel = 'toolbar.accessibilityLabel.help';
|
|
|
|
icon = IconHelp;
|
|
|
|
label = 'toolbar.help';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles clicking / pressing the button, and opens a new window with the user documentation.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_handleClick() {
|
|
|
|
sendAnalytics(createToolbarEvent('help.pressed'));
|
|
|
|
openURLInBrowser(this.props._userDocumentationURL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps part of the redux state to the component's props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The redux store/state.
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
|
|
|
function _mapStateToProps(state: Object) {
|
2019-10-16 18:36:39 +00:00
|
|
|
const { userDocumentationURL } = state['features/base/config'].deploymentUrls || {};
|
2021-02-10 21:34:13 +00:00
|
|
|
const enabled = getFeatureFlag(state, HELP_BUTTON_ENABLED, true);
|
2021-05-11 09:17:55 +00:00
|
|
|
const visible = typeof userDocumentationURL === 'string' && enabled && !isVpaasMeeting(state);
|
2019-10-11 18:09:50 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
_userDocumentationURL: userDocumentationURL,
|
|
|
|
visible
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default translate(connect(_mapStateToProps)(HelpButton));
|