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.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. import { SETTINGS_TABS } from '../../constants';
  9. /**
  10. * The type of the React {@code Component} props of {@link SettingsButton}.
  11. */
  12. interface IProps extends AbstractButtonProps {
  13. /**
  14. * The default tab at which the settings dialog will be opened.
  15. */
  16. defaultTab: string;
  17. /**
  18. * Indicates whether the device selection dialog is displayed on the
  19. * welcome page or not.
  20. */
  21. isDisplayedOnWelcomePage: boolean;
  22. }
  23. /**
  24. * An abstract implementation of a button for accessing settings.
  25. */
  26. class SettingsButton extends AbstractButton<IProps> {
  27. accessibilityLabel = 'toolbar.accessibilityLabel.Settings';
  28. icon = IconGear;
  29. label = 'toolbar.Settings';
  30. tooltip = 'toolbar.Settings';
  31. /**
  32. * Handles clicking / pressing the button, and opens the appropriate dialog.
  33. *
  34. * @protected
  35. * @returns {void}
  36. */
  37. _handleClick() {
  38. const { defaultTab = SETTINGS_TABS.AUDIO, dispatch, isDisplayedOnWelcomePage = false } = this.props;
  39. sendAnalytics(createToolbarEvent('settings'));
  40. dispatch(openSettingsDialog(defaultTab, isDisplayedOnWelcomePage));
  41. }
  42. }
  43. export default translate(connect()(SettingsButton));