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.

SettingsButton.js 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // @flow
  2. import { createToolbarEvent, sendAnalytics } from '../../../analytics';
  3. import { translate } from '../../../base/i18n';
  4. import { IconSettings } from '../../../base/icons';
  5. import { connect } from '../../../base/redux';
  6. import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
  7. import { openSettingsDialog } from '../../actions';
  8. import { SETTINGS_TABS } from '../../constants';
  9. /**
  10. * The type of the React {@code Component} props of {@link SettingsButton}.
  11. */
  12. type Props = AbstractButtonProps & {
  13. /**
  14. * The default tab at which the settings dialog will be opened.
  15. */
  16. defaultTab: string,
  17. /**
  18. * The redux {@code dispatch} function.
  19. */
  20. dispatch: Function
  21. };
  22. /**
  23. * An abstract implementation of a button for accessing settings.
  24. */
  25. class SettingsButton extends AbstractButton<Props, *> {
  26. accessibilityLabel = 'toolbar.accessibilityLabel.Settings';
  27. icon = IconSettings;
  28. label = 'toolbar.Settings';
  29. tooltip = 'toolbar.Settings';
  30. /**
  31. * Handles clicking / pressing the button, and opens the appropriate dialog.
  32. *
  33. * @protected
  34. * @returns {void}
  35. */
  36. _handleClick() {
  37. const {
  38. defaultTab = SETTINGS_TABS.DEVICES,
  39. dispatch } = this.props;
  40. sendAnalytics(createToolbarEvent('settings'));
  41. dispatch(openSettingsDialog(defaultTab));
  42. }
  43. }
  44. export default translate(connect()(SettingsButton));