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

119 lines
2.8 KiB
JavaScript
Raw Normal View History

// @flow
import { connect } from 'react-redux';
2018-05-22 14:23:03 +00:00
import type { Dispatch } from 'redux';
2019-01-09 14:25:33 +00:00
import { translate } from '../../base/i18n';
import { AbstractButton } from '../../base/toolbox';
import type { AbstractButtonProps } from '../../base/toolbox';
import { beginShareRoom } from '../../share-room';
2019-02-26 10:41:57 +00:00
import { setAddPeopleDialogVisible } from '../actions';
import { isAddPeopleEnabled, isDialOutEnabled } from '../functions';
type Props = AbstractButtonProps & {
/**
2019-02-26 10:41:57 +00:00
* Whether or not the feature to invite people to join the
* conference is available.
*/
_addPeopleEnabled: boolean,
/**
2019-02-26 10:41:57 +00:00
* Opens the add people dialog.
*/
2019-02-26 10:41:57 +00:00
_onOpenAddPeopleDialog: Function,
/**
* Begins the UI procedure to share the conference/room URL.
*/
_onShareRoom: Function
};
/**
2018-05-16 21:49:03 +00:00
* Implements an {@link AbstractButton} to enter add/invite people to the
* current call/conference/meeting.
*/
class InviteButton extends AbstractButton<Props, *> {
fix(i18n) Accessiblity labels translations (#3071) * fix(toolbar): accessibilityLabel should be translatable. This commit adds a helper property to get the accessibilityLabel of an item, providing a translation if one is available. This mimics the behavior of label and tooltip. * fix(toolbar) 'hangup' button accessibilityLabel i18n * fix(toolbar) 'mute' button accessibilityLabel i18n * fix(toolbar) 'videomute' button accessibilityLabel i18n * fix(toolbar) 'moreActions' button accessibilityLabel i18n * fix(toolbar) 'shareRoom' button accessibilityLabel i18n * fix(toolbar) 'audioRoute' button accessibilityLabel i18n * fix(toolbar) 'toggleCamera' button accessibilityLabel i18n * fix(toolbar) 'audioOnly' button accessibilityLabel i18n * fix(toolbar) 'roomLock' button accessibilityLabel i18n * fix(toolbar) 'pip' button accessibilityLabel i18n * fix(toolbar) 'invite' button accessibilityLabel i18n * fix(toolbar) 'raiseHand' button accessibilityLabel i18n * fix(toolbar) 'chat' button accessibilityLabel i18n * fix(toolbar) 'shareYourScreen' button accessibilityLabel i18n * fix(toolbar) 'fullScreen' button accessibilityLabel i18n * fix(toolbar) 'sharedvideo' button accessibilityLabel i18n * fix(toolbar) 'document' button accessibilityLabel i18n * fix(toolbar) 'speakerStats' button accessibilityLabel i18n * fix(toolbar) 'feedback' button accessibilityLabel i18n * fix(toolbar) 'shortcuts' button accessibilityLabel i18n * fix(toolbar) 'recording' button accessibilityLabel i18n * fix(toolbar) 'settings' button accessibilityLabel i18n * fix(welcomepage) accessibilityLabels i18n * fix(toolbar) 'info' button accessibilityLabel i18n * fix(i18n): Add translation to various aria-label property values. * fix(i18n): Differentiate between overflow menu and button.
2018-06-07 20:32:18 +00:00
accessibilityLabel = 'toolbar.accessibilityLabel.shareRoom';
iconName = 'icon-link';
label = 'toolbar.shareRoom';
/**
* Handles clicking / pressing the button, and opens the appropriate dialog.
*
* @private
* @returns {void}
*/
_handleClick() {
const {
2019-02-26 10:41:57 +00:00
_addPeopleEnabled,
_onOpenAddPeopleDialog,
_onShareRoom
} = this.props;
2019-02-26 10:41:57 +00:00
if (_addPeopleEnabled) {
_onOpenAddPeopleDialog();
} else {
_onShareRoom();
}
}
}
/**
* Maps redux actions to {@link InviteButton}'s React
* {@code Component} props.
*
* @param {Function} dispatch - The redux action {@code dispatch} function.
* @returns {{
2019-02-26 10:41:57 +00:00
* _onOpenAddPeopleDialog,
* _onShareRoom
* }}
* @private
*/
2018-05-22 14:23:03 +00:00
function _mapDispatchToProps(dispatch: Dispatch<*>) {
return {
2019-02-26 10:41:57 +00:00
/**
2019-02-26 10:41:57 +00:00
* Opens the add people dialog.
*
* @private
* @returns {void}
* @type {Function}
*/
2019-02-26 10:41:57 +00:00
_onOpenAddPeopleDialog() {
dispatch(setAddPeopleDialogVisible(true));
},
/**
* Begins the UI procedure to share the conference/room URL.
*
* @private
* @returns {void}
* @type {Function}
*/
_onShareRoom() {
dispatch(beginShareRoom());
}
};
}
/**
* Maps (parts of) the redux state to {@link Toolbox}'s React {@code Component}
* props.
*
* @param {Object} state - The redux store/state.
* @private
* @returns {{
2019-02-26 10:41:57 +00:00
* _addPeopleEnabled: boolean
* }}
*/
function _mapStateToProps(state) {
return {
2019-02-26 10:41:57 +00:00
_addPeopleEnabled: isAddPeopleEnabled(state) || isDialOutEnabled(state)
};
}
2019-01-09 14:25:33 +00:00
export default translate(
connect(_mapStateToProps, _mapDispatchToProps)(InviteButton));