2018-03-28 00:49:22 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import { connect } from 'react-redux';
|
2018-05-22 14:23:03 +00:00
|
|
|
import type { Dispatch } from 'redux';
|
2018-03-28 00:49:22 +00:00
|
|
|
|
2019-01-09 14:25:33 +00:00
|
|
|
import { translate } from '../../base/i18n';
|
2018-05-10 23:01:55 +00:00
|
|
|
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';
|
2018-05-10 23:01:55 +00:00
|
|
|
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
|
|
|
|
|
|
|
/**
|
2019-02-26 10:41:57 +00:00
|
|
|
* Whether or not the feature to invite people to join the
|
2018-05-01 04:43:47 +00:00
|
|
|
* 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
|
|
|
|
|
|
|
/**
|
2019-02-26 10:41:57 +00:00
|
|
|
* Opens the add people dialog.
|
2018-03-28 00:49:22 +00:00
|
|
|
*/
|
2019-02-26 10:41:57 +00:00
|
|
|
_onOpenAddPeopleDialog: Function,
|
2018-05-01 04:43:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Begins the UI procedure to share the conference/room URL.
|
|
|
|
*/
|
|
|
|
_onShareRoom: Function
|
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, *> {
|
2018-06-07 20:32:18 +00:00
|
|
|
accessibilityLabel = 'toolbar.accessibilityLabel.shareRoom';
|
2018-04-18 14:34:40 +00:00
|
|
|
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 {
|
2019-02-26 10:41:57 +00:00
|
|
|
_addPeopleEnabled,
|
|
|
|
_onOpenAddPeopleDialog,
|
2018-04-18 14:34:40 +00:00
|
|
|
_onShareRoom
|
2018-03-28 00:49:22 +00:00
|
|
|
} = this.props;
|
|
|
|
|
2019-02-26 10:41:57 +00:00
|
|
|
if (_addPeopleEnabled) {
|
|
|
|
_onOpenAddPeopleDialog();
|
|
|
|
} else {
|
|
|
|
_onShareRoom();
|
|
|
|
}
|
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 {{
|
2019-02-26 10:41:57 +00:00
|
|
|
* _onOpenAddPeopleDialog,
|
2018-05-01 04:43:47 +00:00
|
|
|
* _onShareRoom
|
2018-03-28 00:49:22 +00:00
|
|
|
* }}
|
|
|
|
* @private
|
|
|
|
*/
|
2019-03-19 15:42:25 +00:00
|
|
|
function _mapDispatchToProps(dispatch: Dispatch<any>) {
|
2018-03-28 00:49:22 +00:00
|
|
|
return {
|
2019-02-26 10:41:57 +00:00
|
|
|
|
2018-03-28 00:49:22 +00:00
|
|
|
/**
|
2019-02-26 10:41:57 +00:00
|
|
|
* Opens the add people dialog.
|
2018-03-28 00:49:22 +00:00
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
* @type {Function}
|
|
|
|
*/
|
2019-02-26 10:41:57 +00:00
|
|
|
_onOpenAddPeopleDialog() {
|
|
|
|
dispatch(setAddPeopleDialogVisible(true));
|
2018-05-01 04:43:47 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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 {{
|
2019-02-26 10:41:57 +00:00
|
|
|
* _addPeopleEnabled: boolean
|
2018-05-01 04:43:47 +00:00
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
function _mapStateToProps(state) {
|
|
|
|
return {
|
2019-02-26 10:41:57 +00:00
|
|
|
_addPeopleEnabled: isAddPeopleEnabled(state) || isDialOutEnabled(state)
|
2018-05-01 04:43:47 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-01-09 14:25:33 +00:00
|
|
|
export default translate(
|
|
|
|
connect(_mapStateToProps, _mapDispatchToProps)(InviteButton));
|