2018-03-28 00:49:22 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
2018-05-10 23:01:55 +00:00
|
|
|
import { AbstractButton } from '../../base/toolbox';
|
|
|
|
import type { AbstractButtonProps } from '../../base/toolbox';
|
|
|
|
import { beginShareRoom } from '../../share-room';
|
|
|
|
|
|
|
|
import { beginAddPeople } from '../actions';
|
|
|
|
import { isAddPeopleEnabled, isDialOutEnabled } from '../functions';
|
2018-05-01 04:43:47 +00:00
|
|
|
|
2018-04-18 14:34:40 +00:00
|
|
|
type Props = AbstractButtonProps & {
|
2018-03-28 00:49:22 +00:00
|
|
|
|
|
|
|
/**
|
2018-05-01 04:43:47 +00:00
|
|
|
* Whether or not the feature to directly invite people into the
|
|
|
|
* conference is available.
|
2018-03-28 00:49:22 +00:00
|
|
|
*/
|
2018-05-01 04:43:47 +00:00
|
|
|
_addPeopleEnabled: boolean,
|
2018-03-28 00:49:22 +00:00
|
|
|
|
|
|
|
/**
|
2018-05-01 04:43:47 +00:00
|
|
|
* Whether or not the feature to dial out to number to join the
|
|
|
|
* conference is available.
|
2018-03-28 00:49:22 +00:00
|
|
|
*/
|
2018-05-01 04:43:47 +00:00
|
|
|
_dialOutEnabled: boolean,
|
2018-03-28 00:49:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Launches native invite dialog.
|
|
|
|
*
|
|
|
|
* @protected
|
|
|
|
*/
|
2018-05-01 04:43:47 +00:00
|
|
|
_onAddPeople: Function,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Begins the UI procedure to share the conference/room URL.
|
|
|
|
*/
|
|
|
|
_onShareRoom: Function
|
2018-03-28 00:49:22 +00:00
|
|
|
};
|
|
|
|
|
2018-04-18 14:34:40 +00:00
|
|
|
/**
|
|
|
|
* The indicator which determines (at bundle time) whether there should be a
|
|
|
|
* button in {@code Toolbox} to expose the functionality of the feature
|
|
|
|
* share-room in the user interface of the app.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
const _SHARE_ROOM_TOOLBAR_BUTTON = true;
|
|
|
|
|
2018-03-28 00:49:22 +00:00
|
|
|
/**
|
2018-05-16 21:49:03 +00:00
|
|
|
* Implements an {@link AbstractButton} to enter add/invite people to the
|
|
|
|
* current call/conference/meeting.
|
2018-03-28 00:49:22 +00:00
|
|
|
*/
|
2018-04-18 14:34:40 +00:00
|
|
|
class InviteButton extends AbstractButton<Props, *> {
|
|
|
|
accessibilityLabel = 'Share room';
|
|
|
|
iconName = 'icon-link';
|
|
|
|
label = 'toolbar.shareRoom';
|
2018-03-28 00:49:22 +00:00
|
|
|
|
|
|
|
/**
|
2018-04-18 14:34:40 +00:00
|
|
|
* Handles clicking / pressing the button, and opens the appropriate dialog.
|
2018-03-28 00:49:22 +00:00
|
|
|
*
|
2018-04-18 14:34:40 +00:00
|
|
|
* @private
|
|
|
|
* @returns {void}
|
2018-03-28 00:49:22 +00:00
|
|
|
*/
|
2018-04-18 14:34:40 +00:00
|
|
|
_handleClick() {
|
2018-03-28 00:49:22 +00:00
|
|
|
const {
|
2018-05-01 04:43:47 +00:00
|
|
|
_addPeopleEnabled,
|
|
|
|
_dialOutEnabled,
|
|
|
|
_onAddPeople,
|
2018-04-18 14:34:40 +00:00
|
|
|
_onShareRoom
|
2018-03-28 00:49:22 +00:00
|
|
|
} = this.props;
|
|
|
|
|
2018-05-07 03:39:20 +00:00
|
|
|
if (_addPeopleEnabled || _dialOutEnabled) {
|
2018-04-18 14:34:40 +00:00
|
|
|
_onAddPeople();
|
|
|
|
} else if (_SHARE_ROOM_TOOLBAR_BUTTON) {
|
|
|
|
_onShareRoom();
|
2018-03-28 00:49:22 +00:00
|
|
|
}
|
2018-04-18 14:34:40 +00:00
|
|
|
}
|
2018-03-28 00:49:22 +00:00
|
|
|
|
2018-04-18 14:34:40 +00:00
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {React$Node}
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
const { _addPeopleEnabled, _dialOutEnabled } = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
_SHARE_ROOM_TOOLBAR_BUTTON
|
|
|
|
|| _addPeopleEnabled
|
|
|
|
|| _dialOutEnabled
|
|
|
|
? super.render()
|
|
|
|
: null);
|
2018-03-28 00:49:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps redux actions to {@link InviteButton}'s React
|
|
|
|
* {@code Component} props.
|
|
|
|
*
|
|
|
|
* @param {Function} dispatch - The redux action {@code dispatch} function.
|
|
|
|
* @returns {{
|
2018-05-01 04:43:47 +00:00
|
|
|
* _onAddPeople,
|
|
|
|
* _onShareRoom
|
2018-03-28 00:49:22 +00:00
|
|
|
* }}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
function _mapDispatchToProps(dispatch) {
|
|
|
|
return {
|
|
|
|
/**
|
|
|
|
* Launches native invite dialog.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
* @type {Function}
|
|
|
|
*/
|
2018-05-01 04:43:47 +00:00
|
|
|
_onAddPeople() {
|
|
|
|
dispatch(beginAddPeople());
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Begins the UI procedure to share the conference/room URL.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
* @type {Function}
|
|
|
|
*/
|
|
|
|
_onShareRoom() {
|
|
|
|
dispatch(beginShareRoom());
|
2018-03-28 00:49:22 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-05-01 04:43:47 +00:00
|
|
|
/**
|
|
|
|
* Maps (parts of) the redux state to {@link Toolbox}'s React {@code Component}
|
|
|
|
* props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The redux store/state.
|
|
|
|
* @private
|
|
|
|
* @returns {{
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
function _mapStateToProps(state) {
|
|
|
|
return {
|
|
|
|
/**
|
|
|
|
* Whether or not the feature to directly invite people into the
|
|
|
|
* conference is available.
|
|
|
|
*
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
_addPeopleEnabled: isAddPeopleEnabled(state),
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not the feature to dial out to number to join the
|
|
|
|
* conference is available.
|
|
|
|
*
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
_dialOutEnabled: isDialOutEnabled(state)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(_mapStateToProps, _mapDispatchToProps)(InviteButton);
|