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.js 1.3KB

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