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

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