2023-03-21 09:47:52 +02:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
|
2023-03-31 14:04:33 +03:00
|
|
|
import { openSheet } from '../../../base/dialog/actions';
|
|
|
|
|
import { OVERFLOW_MENU_ENABLED } from '../../../base/flags/constants';
|
|
|
|
|
import { getFeatureFlag } from '../../../base/flags/functions';
|
2023-04-03 13:49:19 +03:00
|
|
|
import { translate } from '../../../base/i18n/functions';
|
|
|
|
|
import { IconDotsHorizontal } from '../../../base/icons/svg';
|
|
|
|
|
import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton';
|
2018-05-15 13:18:42 +02:00
|
|
|
|
|
|
|
|
import OverflowMenu from './OverflowMenu';
|
|
|
|
|
|
2018-05-16 16:49:03 -05:00
|
|
|
/**
|
|
|
|
|
* The type of the React {@code Component} props of {@link OverflowMenuButton}.
|
|
|
|
|
*/
|
2018-05-15 13:18:42 +02:00
|
|
|
type Props = AbstractButtonProps & {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The redux {@code dispatch} function.
|
|
|
|
|
*/
|
|
|
|
|
dispatch: Function
|
2018-05-16 16:49:03 -05:00
|
|
|
};
|
2018-05-15 13:18:42 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* An implementation of a button for showing the {@code OverflowMenu}.
|
|
|
|
|
*/
|
|
|
|
|
class OverflowMenuButton extends AbstractButton<Props, *> {
|
2018-06-07 22:32:18 +02:00
|
|
|
accessibilityLabel = 'toolbar.accessibilityLabel.moreActions';
|
2022-11-08 12:24:32 +02:00
|
|
|
icon = IconDotsHorizontal;
|
2018-05-15 13:18:42 +02:00
|
|
|
label = 'toolbar.moreActions';
|
|
|
|
|
|
|
|
|
|
/**
|
2018-05-16 16:49:03 -05:00
|
|
|
* Handles clicking / pressing this {@code OverflowMenuButton}.
|
2018-05-15 13:18:42 +02:00
|
|
|
*
|
2018-05-16 16:49:03 -05:00
|
|
|
* @protected
|
2018-05-15 13:18:42 +02:00
|
|
|
* @returns {void}
|
|
|
|
|
*/
|
|
|
|
|
_handleClick() {
|
2022-06-20 16:53:19 +02:00
|
|
|
this.props.dispatch(openSheet(OverflowMenu));
|
2018-05-15 13:18:42 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-04 15:32:09 +02:00
|
|
|
/**
|
|
|
|
|
* Maps (parts of) the redux state to the associated props for the
|
|
|
|
|
* {@code OverflowMenuButton} component.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
|
* @private
|
|
|
|
|
* @returns {Props}
|
|
|
|
|
*/
|
|
|
|
|
function _mapStateToProps(state): Object {
|
|
|
|
|
const enabledFlag = getFeatureFlag(state, OVERFLOW_MENU_ENABLED, true);
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
visible: enabledFlag
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default translate(connect(_mapStateToProps)(OverflowMenuButton));
|