2022-06-20 14:53:19 +00:00
|
|
|
import { openSheet } from '../../../base/dialog';
|
2022-09-27 07:10:28 +00:00
|
|
|
import { OVERFLOW_MENU_ENABLED, getFeatureFlag } from '../../../base/flags';
|
2018-05-15 11:18:42 +00:00
|
|
|
import { translate } from '../../../base/i18n';
|
2022-11-08 10:24:32 +00:00
|
|
|
import { IconDotsHorizontal } from '../../../base/icons';
|
2019-03-21 16:38:29 +00:00
|
|
|
import { connect } from '../../../base/redux';
|
2020-07-24 12:14:33 +00:00
|
|
|
import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
|
2018-05-15 11:18:42 +00:00
|
|
|
|
|
|
|
import OverflowMenu from './OverflowMenu';
|
|
|
|
|
2018-05-16 21:49:03 +00:00
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} props of {@link OverflowMenuButton}.
|
|
|
|
*/
|
2018-05-15 11:18:42 +00:00
|
|
|
type Props = AbstractButtonProps & {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The redux {@code dispatch} function.
|
|
|
|
*/
|
|
|
|
dispatch: Function
|
2018-05-16 21:49:03 +00:00
|
|
|
};
|
2018-05-15 11:18:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* An implementation of a button for showing the {@code OverflowMenu}.
|
|
|
|
*/
|
|
|
|
class OverflowMenuButton extends AbstractButton<Props, *> {
|
2018-06-07 20:32:18 +00:00
|
|
|
accessibilityLabel = 'toolbar.accessibilityLabel.moreActions';
|
2022-11-08 10:24:32 +00:00
|
|
|
icon = IconDotsHorizontal;
|
2018-05-15 11:18:42 +00:00
|
|
|
label = 'toolbar.moreActions';
|
|
|
|
|
|
|
|
/**
|
2018-05-16 21:49:03 +00:00
|
|
|
* Handles clicking / pressing this {@code OverflowMenuButton}.
|
2018-05-15 11:18:42 +00:00
|
|
|
*
|
2018-05-16 21:49:03 +00:00
|
|
|
* @protected
|
2018-05-15 11:18:42 +00:00
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_handleClick() {
|
2022-06-20 14:53:19 +00:00
|
|
|
this.props.dispatch(openSheet(OverflowMenu));
|
2018-05-15 11:18:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-04 13:32:09 +00: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));
|