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

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