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.

KeyboardShortcutsButton.web.js 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // @flow
  2. import { createToolbarEvent, sendAnalytics } from '../../analytics';
  3. import { translate } from '../../base/i18n';
  4. import { IconDeviceDocument } from '../../base/icons';
  5. import { connect } from '../../base/redux';
  6. import { AbstractButton, type AbstractButtonProps } from '../../base/toolbox/components';
  7. import { openKeyboardShortcutsDialog } from '../actions';
  8. /**
  9. * The type of the React {@code Component} props of {@link KeyboardShortcutsButton}.
  10. */
  11. type Props = AbstractButtonProps & {
  12. /**
  13. * The redux {@code dispatch} function.
  14. */
  15. dispatch: Function
  16. };
  17. /**
  18. * Implementation of a button for opening keyboard shortcuts dialog.
  19. */
  20. class KeyboardShortcutsButton extends AbstractButton<Props, *> {
  21. accessibilityLabel = 'toolbar.accessibilityLabel.shortcuts';
  22. icon = IconDeviceDocument;
  23. label = 'toolbar.shortcuts';
  24. tooltip = 'toolbar.shortcuts';
  25. /**
  26. * Handles clicking / pressing the button, and opens the appropriate dialog.
  27. *
  28. * @protected
  29. * @returns {void}
  30. */
  31. _handleClick() {
  32. const { dispatch, handleClick } = this.props;
  33. if (handleClick) {
  34. handleClick();
  35. return;
  36. }
  37. sendAnalytics(createToolbarEvent('shortcuts'));
  38. dispatch(openKeyboardShortcutsDialog());
  39. }
  40. }
  41. export default translate(connect()(KeyboardShortcutsButton));