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

SettingsButton.js 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // @flow
  2. import { createToolbarEvent, sendAnalytics } from '../../../analytics';
  3. import { translate } from '../../../base/i18n';
  4. import { IconGear } 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. * Indicates whether the device selection dialog is displayed on the
  23. * welcome page or not.
  24. */
  25. isDisplayedOnWelcomePage: boolean
  26. };
  27. /**
  28. * An abstract implementation of a button for accessing settings.
  29. */
  30. class SettingsButton extends AbstractButton<Props, *> {
  31. accessibilityLabel = 'toolbar.accessibilityLabel.Settings';
  32. icon = IconGear;
  33. label = 'toolbar.Settings';
  34. tooltip = 'toolbar.Settings';
  35. /**
  36. * Handles clicking / pressing the button, and opens the appropriate dialog.
  37. *
  38. * @protected
  39. * @returns {void}
  40. */
  41. _handleClick() {
  42. const { defaultTab = SETTINGS_TABS.DEVICES, dispatch, isDisplayedOnWelcomePage = false } = this.props;
  43. sendAnalytics(createToolbarEvent('settings'));
  44. dispatch(openSettingsDialog(defaultTab, isDisplayedOnWelcomePage));
  45. }
  46. }
  47. export default translate(connect()(SettingsButton));