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

SettingsButton.js 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 { openDeviceSelectionDialog } from '../../../device-selection';
  8. import { toggleSettings } from '../../../side-panel';
  9. declare var interfaceConfig: Object;
  10. type Props = AbstractButtonProps & {
  11. /**
  12. * Whether we are in filmstrip only mode or not.
  13. */
  14. _filmstripOnly: boolean,
  15. /**
  16. * Array containing the enabled settings sections.
  17. */
  18. _sections: Array<string>,
  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 = '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. * @private
  36. * @returns {void}
  37. */
  38. _handleClick() {
  39. const { _filmstripOnly, _sections, dispatch } = this.props;
  40. sendAnalytics(createToolbarEvent('settings'));
  41. if (_filmstripOnly
  42. || (_sections.length === 1 && _sections.includes('devices'))) {
  43. dispatch(openDeviceSelectionDialog());
  44. } else {
  45. dispatch(toggleSettings());
  46. }
  47. }
  48. }
  49. /**
  50. * Maps (parts of) the redux state to the associated props for the
  51. * {@code SettingsButton} component.
  52. *
  53. * @param {Object} state - The Redux state.
  54. * @private
  55. * @returns {{
  56. * _filmstripOnly: boolean
  57. * }}
  58. */
  59. function _mapStateToProps(state): Object { // eslint-disable-line no-unused-vars
  60. // XXX: We are not currently using state here, but in the future, when
  61. // interfaceConfig is part of redux we will.
  62. return {
  63. _filmstripOnly: Boolean(interfaceConfig.filmStripOnly),
  64. _sections: interfaceConfig.SETTINGS_SECTIONS || []
  65. };
  66. }
  67. export default translate(connect(_mapStateToProps)(SettingsButton));