invite: merge InviteButton and InfoDialogButton on mobile

This commit is contained in:
Saúl Ibarra Corretgé 2020-03-24 12:18:25 +01:00 committed by Saúl Ibarra Corretgé
parent 579d08e27e
commit 8cd881945a
6 changed files with 19 additions and 65 deletions

View File

@ -8,12 +8,18 @@ import { IconAddPeople } from '../../../../base/icons';
import { connect } from '../../../../base/redux';
import { AbstractButton } from '../../../../base/toolbox';
import type { AbstractButtonProps } from '../../../../base/toolbox';
import { beginShareRoom } from '../../../../share-room';
import { setAddPeopleDialogVisible } from '../../../actions';
import { isAddPeopleEnabled, isDialOutEnabled } from '../../../functions';
type Props = AbstractButtonProps & {
/**
* Whether the (backend) add people feature is enabled or not.
*/
_addPeopleEnabled: boolean,
/**
* The Redux dispatch function.
*/
@ -36,7 +42,13 @@ class InviteButton extends AbstractButton<Props, *> {
* @returns {void}
*/
_handleClick() {
this.props.dispatch(setAddPeopleDialogVisible(true));
const { _addPeopleEnabled, dispatch } = this.props;
if (_addPeopleEnabled) {
dispatch(setAddPeopleDialogVisible(true));
} else {
dispatch(beginShareRoom());
}
}
}
@ -45,18 +57,15 @@ class InviteButton extends AbstractButton<Props, *> {
* props.
*
* @param {Object} state - The redux store/state.
* @param {Object} ownProps - The properties explicitly passed to the component
* instance.
* @private
* @returns {Object}
*/
function _mapStateToProps(state: Object, ownProps: Object) {
function _mapStateToProps(state: Object) {
const addPeopleEnabled = getFeatureFlag(state, INVITE_ENABLED, true)
&& (isAddPeopleEnabled(state) || isDialOutEnabled(state));
const { visible = Boolean(addPeopleEnabled) } = ownProps;
return {
visible
_addPeopleEnabled: addPeopleEnabled
};
}

View File

@ -1,3 +0,0 @@
// @flow
export * from './native';

View File

@ -1,39 +0,0 @@
// @flow
import type { Dispatch } from 'redux';
import { translate } from '../../../../base/i18n';
import { IconInfo } from '../../../../base/icons';
import { connect } from '../../../../base/redux';
import { AbstractButton } from '../../../../base/toolbox';
import type { AbstractButtonProps } from '../../../../base/toolbox';
import { beginShareRoom } from '../../../../share-room';
type Props = AbstractButtonProps & {
/**
* The Redux dispatch function.
*/
dispatch: Dispatch<any>
};
/**
* Implements an {@link AbstractButton} to open the info dialog of the meeting.
*/
class InfoDialogButton extends AbstractButton<Props, *> {
accessibilityLabel = 'info.accessibilityLabel';
icon = IconInfo;
label = 'info.label';
/**
* Handles clicking / pressing the button, and opens the appropriate dialog.
*
* @private
* @returns {void}
*/
_handleClick() {
this.props.dispatch(beginShareRoom());
}
}
export default translate(connect()(InfoDialogButton));

View File

@ -1,3 +0,0 @@
// @flow
export { default as InfoDialogButton } from './InfoDialogButton';

View File

@ -7,11 +7,11 @@ import Collapsible from 'react-native-collapsible';
import { ColorSchemeRegistry } from '../../../base/color-scheme';
import { BottomSheet, hideDialog, isDialogOpen } from '../../../base/dialog';
import { IconDragHandle } from '../../../base/icons';
import { CHAT_ENABLED, IOS_RECORDING_ENABLED, getFeatureFlag } from '../../../base/flags';
import { IOS_RECORDING_ENABLED, getFeatureFlag } from '../../../base/flags';
import { connect } from '../../../base/redux';
import { StyleType } from '../../../base/styles';
import { SharedDocumentButton } from '../../../etherpad';
import { InfoDialogButton, InviteButton } from '../../../invite';
import { InviteButton } from '../../../invite';
import { AudioRouteButton } from '../../../mobile/audio-mode';
import { LiveStreamButton, RecordButton } from '../../../recording';
import { RoomLockButton } from '../../../room-lock';
@ -36,11 +36,6 @@ type Props = {
*/
_bottomSheetStyles: StyleType,
/**
* Whether the chat feature has been enabled. The meeting info button will be displayed in its place when disabled.
*/
_chatEnabled: boolean,
/**
* True if the overflow menu is currently visible, false otherwise.
*/
@ -145,10 +140,6 @@ class OverflowMenu extends PureComponent<Props, State> {
<LiveStreamButton { ...buttonProps } />
<TileViewButton { ...buttonProps } />
<InviteButton { ...buttonProps } />
{
this.props._chatEnabled
&& <InfoDialogButton { ...buttonProps } />
}
<RaiseHandButton { ...buttonProps } />
<SharedDocumentButton { ...buttonProps } />
<HelpButton { ...buttonProps } />
@ -249,7 +240,6 @@ class OverflowMenu extends PureComponent<Props, State> {
function _mapStateToProps(state) {
return {
_bottomSheetStyles: ColorSchemeRegistry.get(state, 'BottomSheet'),
_chatEnabled: getFeatureFlag(state, CHAT_ENABLED, true),
_isOpen: isDialogOpen(state, OverflowMenu_),
_recordingEnabled: Platform.OS !== 'ios' || getFeatureFlag(state, IOS_RECORDING_ENABLED)
};

View File

@ -9,7 +9,7 @@ import { Container } from '../../../base/react';
import { connect } from '../../../base/redux';
import { StyleType } from '../../../base/styles';
import { ChatButton } from '../../../chat';
import { InfoDialogButton } from '../../../invite';
import { InviteButton } from '../../../invite';
import { isToolboxVisible } from '../../functions';
@ -122,7 +122,7 @@ class Toolbox extends PureComponent<Props> {
}
{
!_chatEnabled
&& <InfoDialogButton
&& <InviteButton
styles = { buttonStyles }
toggledStyles = { toggledButtonStyles } />
}