123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- // @flow
-
- import React, { Component } from 'react';
- import { connect } from 'react-redux';
-
- import { beginShareRoom } from '../../share-room';
- import { ToolbarButton } from '../../toolbox';
-
- import { beginAddPeople } from '../actions';
- import { isAddPeopleEnabled, isDialOutEnabled } from '../functions';
-
- /**
- * The indicator which determines (at bundle time) whether there should be a
- * {@code ToolbarButton} 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;
-
- /**
- * The type of {@link EnterPictureInPictureToobarButton}'s React
- * {@code Component} props.
- */
- type Props = {
-
- /**
- * Whether or not the feature to directly invite people into the
- * conference is available.
- */
- _addPeopleEnabled: boolean,
-
- /**
- * Whether or not the feature to dial out to number to join the
- * conference is available.
- */
- _dialOutEnabled: boolean,
-
- /**
- * Launches native invite dialog.
- *
- * @protected
- */
- _onAddPeople: Function,
-
- /**
- * Begins the UI procedure to share the conference/room URL.
- */
- _onShareRoom: Function
- };
-
- /**
- * Implements a {@link ToolbarButton} to enter Picture-in-Picture.
- */
- class InviteButton extends Component<Props> {
-
- /**
- * Implements React's {@link Component#render()}.
- *
- * @inheritdoc
- * @returns {ReactElement}
- */
- render() {
- const {
- _addPeopleEnabled,
- _dialOutEnabled,
- _onAddPeople,
- _onShareRoom,
- ...props
- } = this.props;
-
- if (_addPeopleEnabled || _dialOutEnabled) {
- return (
- <ToolbarButton
- iconName = { 'link' }
- onClick = { _onAddPeople }
- { ...props } />
- );
- }
-
- if (_SHARE_ROOM_TOOLBAR_BUTTON) {
- return (
- <ToolbarButton
- iconName = 'link'
- onClick = { _onShareRoom }
- { ...props } />
- );
- }
-
- return null;
- }
- }
-
- /**
- * Maps redux actions to {@link InviteButton}'s React
- * {@code Component} props.
- *
- * @param {Function} dispatch - The redux action {@code dispatch} function.
- * @returns {{
- * _onAddPeople,
- * _onShareRoom
- * }}
- * @private
- */
- function _mapDispatchToProps(dispatch) {
- return {
- /**
- * Launches native invite dialog.
- *
- * @private
- * @returns {void}
- * @type {Function}
- */
- _onAddPeople() {
- dispatch(beginAddPeople());
- },
-
- /**
- * 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 {{
- * }}
- */
- 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);
|