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.

HelpButton.js 1.5KB

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