您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

SettingsButton.js 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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,
  40. handleClick
  41. } = this.props;
  42. if (handleClick) {
  43. handleClick();
  44. return;
  45. }
  46. sendAnalytics(createToolbarEvent('settings'));
  47. dispatch(openSettingsDialog(defaultTab));
  48. }
  49. }
  50. export default translate(connect()(SettingsButton));