jiti-meet/react/features/invite/components/add-people-dialog/native/InviteButton.js

64 lines
1.8 KiB
JavaScript
Raw Normal View History

2019-04-02 13:16:52 +00:00
// @flow
import type { Dispatch } from 'redux';
import { getFeatureFlag, INVITE_ENABLED } from '../../../../base/flags';
2019-04-02 13:16:52 +00:00
import { translate } from '../../../../base/i18n';
2019-08-30 16:39:06 +00:00
import { IconAddPeople } from '../../../../base/icons';
2019-04-02 13:16:52 +00:00
import { connect } from '../../../../base/redux';
import { AbstractButton } from '../../../../base/toolbox';
import type { AbstractButtonProps } from '../../../../base/toolbox';
import { setAddPeopleDialogVisible } from '../../../actions';
import { isAddPeopleEnabled, isDialOutEnabled } from '../../../functions';
type Props = AbstractButtonProps & {
/**
* The Redux dispatch function.
*/
dispatch: Dispatch<any>
};
/**
* Implements an {@link AbstractButton} to enter add/invite people to the
* current call/conference/meeting.
*/
class InviteButton extends AbstractButton<Props, *> {
accessibilityLabel = 'toolbar.accessibilityLabel.shareRoom';
2019-08-30 16:39:06 +00:00
icon = IconAddPeople;
2019-04-02 13:16:52 +00:00
label = 'toolbar.shareRoom';
/**
* Handles clicking / pressing the button, and opens the appropriate dialog.
*
* @private
* @returns {void}
*/
_handleClick() {
this.props.dispatch(setAddPeopleDialogVisible(true));
}
}
/**
* Maps (parts of) the redux state to {@link InviteButton}'s React {@code Component}
* props.
*
* @param {Object} state - The redux store/state.
* @param {Object} ownProps - The properties explicitly passed to the component
* instance.
2019-04-02 13:16:52 +00:00
* @private
* @returns {Object}
2019-04-02 13:16:52 +00:00
*/
function _mapStateToProps(state: Object, ownProps: Object) {
const addPeopleEnabled = getFeatureFlag(state, INVITE_ENABLED, true)
&& (isAddPeopleEnabled(state) || isDialOutEnabled(state));
const { visible = Boolean(addPeopleEnabled) } = ownProps;
2019-04-02 13:16:52 +00:00
return {
visible
2019-04-02 13:16:52 +00:00
};
}
export default translate(connect(_mapStateToProps)(InviteButton));