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.

OverflowMenuButton.js 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import { openSheet } from '../../../base/dialog';
  2. import { getFeatureFlag, OVERFLOW_MENU_ENABLED } from '../../../base/flags';
  3. import { translate } from '../../../base/i18n';
  4. import { IconHorizontalPoints } from '../../../base/icons';
  5. import { connect } from '../../../base/redux';
  6. import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
  7. import OverflowMenu from './OverflowMenu';
  8. /**
  9. * The type of the React {@code Component} props of {@link OverflowMenuButton}.
  10. */
  11. type Props = AbstractButtonProps & {
  12. /**
  13. * The redux {@code dispatch} function.
  14. */
  15. dispatch: Function
  16. };
  17. /**
  18. * An implementation of a button for showing the {@code OverflowMenu}.
  19. */
  20. class OverflowMenuButton extends AbstractButton<Props, *> {
  21. accessibilityLabel = 'toolbar.accessibilityLabel.moreActions';
  22. icon = IconHorizontalPoints;
  23. label = 'toolbar.moreActions';
  24. /**
  25. * Handles clicking / pressing this {@code OverflowMenuButton}.
  26. *
  27. * @protected
  28. * @returns {void}
  29. */
  30. _handleClick() {
  31. this.props.dispatch(openSheet(OverflowMenu));
  32. }
  33. }
  34. /**
  35. * Maps (parts of) the redux state to the associated props for the
  36. * {@code OverflowMenuButton} component.
  37. *
  38. * @param {Object} state - The Redux state.
  39. * @private
  40. * @returns {Props}
  41. */
  42. function _mapStateToProps(state): Object {
  43. const enabledFlag = getFeatureFlag(state, OVERFLOW_MENU_ENABLED, true);
  44. return {
  45. visible: enabledFlag
  46. };
  47. }
  48. export default translate(connect(_mapStateToProps)(OverflowMenuButton));