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 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // @flow
  2. import { connect } from 'react-redux';
  3. import { createToolbarEvent, sendAnalytics } from '../../../analytics';
  4. import { translate } from '../../../base/i18n';
  5. import { AbstractButton } from '../../../base/toolbox';
  6. import type { AbstractButtonProps } from '../../../base/toolbox';
  7. import { openDeviceSelectionPopup } from '../../../device-selection';
  8. import { openSettingsDialog } from '../../actions';
  9. import { SETTINGS_TABS } from '../../constants';
  10. declare var interfaceConfig: Object;
  11. /**
  12. * The type of the React {@code Component} props of {@link SettingsButton}.
  13. */
  14. type Props = AbstractButtonProps & {
  15. /**
  16. * Whether we are in filmstrip only mode or not.
  17. */
  18. _filmstripOnly: boolean,
  19. /**
  20. * The redux {@code dispatch} function.
  21. */
  22. dispatch: Function
  23. };
  24. /**
  25. * An abstract implementation of a button for accessing settings.
  26. */
  27. class SettingsButton extends AbstractButton<Props, *> {
  28. accessibilityLabel = 'toolbar.accessibilityLabel.Settings';
  29. iconName = 'icon-settings';
  30. label = 'toolbar.Settings';
  31. tooltip = 'toolbar.Settings';
  32. /**
  33. * Handles clicking / pressing the button, and opens the appropriate dialog.
  34. *
  35. * @protected
  36. * @returns {void}
  37. */
  38. _handleClick() {
  39. const { _filmstripOnly, dispatch } = this.props;
  40. sendAnalytics(createToolbarEvent('settings'));
  41. if (_filmstripOnly) {
  42. dispatch(openDeviceSelectionPopup());
  43. } else {
  44. dispatch(openSettingsDialog(SETTINGS_TABS.DEVICES));
  45. }
  46. }
  47. }
  48. /**
  49. * Maps (parts of) the redux state to the associated props for the
  50. * {@code SettingsButton} component.
  51. *
  52. * @param {Object} state - The Redux state.
  53. * @private
  54. * @returns {{
  55. * _filmstripOnly: boolean
  56. * }}
  57. */
  58. function _mapStateToProps(state): Object { // eslint-disable-line no-unused-vars
  59. // XXX: We are not currently using state here, but in the future, when
  60. // interfaceConfig is part of redux we will.
  61. return {
  62. _filmstripOnly: Boolean(interfaceConfig.filmStripOnly)
  63. };
  64. }
  65. export default translate(connect(_mapStateToProps)(SettingsButton));