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.ts 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { connect } from 'react-redux';
  2. import { createToolbarEvent } from '../../../analytics/AnalyticsEvents';
  3. import { sendAnalytics } from '../../../analytics/functions';
  4. import { translate } from '../../../base/i18n/functions';
  5. import { IconGear } from '../../../base/icons/svg';
  6. import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton';
  7. import { openSettingsDialog } from '../../actions';
  8. /**
  9. * The type of the React {@code Component} props of {@link SettingsButton}.
  10. */
  11. interface IProps extends AbstractButtonProps {
  12. /**
  13. * The default tab at which the settings dialog will be opened.
  14. */
  15. defaultTab: string;
  16. /**
  17. * Indicates whether the device selection dialog is displayed on the
  18. * welcome page or not.
  19. */
  20. isDisplayedOnWelcomePage: boolean;
  21. }
  22. /**
  23. * An abstract implementation of a button for accessing settings.
  24. */
  25. class SettingsButton extends AbstractButton<IProps> {
  26. accessibilityLabel = 'toolbar.accessibilityLabel.Settings';
  27. icon = IconGear;
  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 { dispatch, isDisplayedOnWelcomePage = false } = this.props;
  38. sendAnalytics(createToolbarEvent('settings'));
  39. dispatch(openSettingsDialog(undefined, isDisplayedOnWelcomePage));
  40. }
  41. }
  42. export default translate(connect()(SettingsButton));