2020-04-01 07:47:51 +00:00
|
|
|
// @flow
|
|
|
|
|
2021-04-09 12:30:25 +00:00
|
|
|
import type { Dispatch } from 'redux';
|
|
|
|
|
2020-04-01 07:47:51 +00:00
|
|
|
import { createToolbarEvent, sendAnalytics } from '../../../analytics';
|
2021-05-14 13:01:43 +00:00
|
|
|
import {
|
|
|
|
LOBBY_MODE_ENABLED,
|
|
|
|
MEETING_PASSWORD_ENABLED,
|
2022-09-27 07:10:28 +00:00
|
|
|
SECURITY_OPTIONS_ENABLED,
|
|
|
|
getFeatureFlag
|
2021-05-14 13:01:43 +00:00
|
|
|
} from '../../../base/flags';
|
2020-06-17 09:17:58 +00:00
|
|
|
import { IconSecurityOff, IconSecurityOn } from '../../../base/icons';
|
2021-05-14 13:01:43 +00:00
|
|
|
import { isLocalParticipantModerator } from '../../../base/participants';
|
2020-07-24 12:14:33 +00:00
|
|
|
import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
|
2020-04-01 07:47:51 +00:00
|
|
|
|
2021-12-10 16:23:27 +00:00
|
|
|
export type Props = AbstractButtonProps & {
|
2020-04-01 07:47:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the shared document is being edited or not.
|
|
|
|
*/
|
|
|
|
_locked: boolean,
|
|
|
|
|
|
|
|
/**
|
2021-04-09 12:30:25 +00:00
|
|
|
* The redux {@code dispatch} function.
|
2020-04-01 07:47:51 +00:00
|
|
|
*/
|
2021-04-09 12:30:25 +00:00
|
|
|
dispatch: Dispatch<any>
|
2020-04-01 07:47:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-12-10 16:23:27 +00:00
|
|
|
* Implements an {@link AbstractButton} to open the security dialog/screen.
|
2020-04-01 07:47:51 +00:00
|
|
|
*/
|
2021-12-10 16:23:27 +00:00
|
|
|
export default class AbstractSecurityDialogButton<P: Props, S:*>
|
|
|
|
extends AbstractButton<P, S> {
|
2020-04-01 07:47:51 +00:00
|
|
|
accessibilityLabel = 'toolbar.accessibilityLabel.security';
|
2020-06-17 09:17:58 +00:00
|
|
|
icon = IconSecurityOff;
|
2020-04-01 07:47:51 +00:00
|
|
|
label = 'toolbar.security';
|
2020-06-17 09:17:58 +00:00
|
|
|
toggledIcon = IconSecurityOn;
|
2021-07-08 13:42:07 +00:00
|
|
|
tooltip = 'toolbar.security';
|
2020-04-01 07:47:51 +00:00
|
|
|
|
|
|
|
/**
|
2021-12-10 16:23:27 +00:00
|
|
|
* Helper function to be implemented by subclasses, which should be used
|
|
|
|
* to handle the security button being clicked / pressed.
|
|
|
|
*
|
|
|
|
* @protected
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_handleClickSecurityButton() {
|
|
|
|
// To be implemented by subclass.
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles clicking / pressing the button.
|
2020-04-01 07:47:51 +00:00
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_handleClick() {
|
2022-01-04 11:21:00 +00:00
|
|
|
const { _locked } = this.props;
|
2021-09-14 07:07:20 +00:00
|
|
|
|
|
|
|
sendAnalytics(createToolbarEvent('toggle.security', { enable: !_locked }));
|
2021-12-10 16:23:27 +00:00
|
|
|
this._handleClickSecurityButton();
|
2020-04-01 07:47:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether this button is in toggled state or not.
|
|
|
|
*
|
|
|
|
* @override
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
_isToggled() {
|
|
|
|
return this.props._locked;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps part of the redux state to the component's props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The redux store/state.
|
|
|
|
* @returns {Props}
|
|
|
|
*/
|
2021-12-10 16:23:27 +00:00
|
|
|
export function _mapStateToProps(state: Object) {
|
2021-05-14 13:01:43 +00:00
|
|
|
const { conference } = state['features/base/conference'];
|
|
|
|
const { hideLobbyButton } = state['features/base/config'];
|
2020-04-01 07:47:51 +00:00
|
|
|
const { locked } = state['features/base/conference'];
|
2020-05-20 08:25:31 +00:00
|
|
|
const { lobbyEnabled } = state['features/lobby'];
|
2021-05-14 13:01:43 +00:00
|
|
|
const lobbySupported = conference && conference.isLobbySupported();
|
|
|
|
const lobby = lobbySupported && isLocalParticipantModerator(state) && !hideLobbyButton;
|
|
|
|
const enabledFlag = getFeatureFlag(state, SECURITY_OPTIONS_ENABLED, true);
|
|
|
|
const enabledLobbyModeFlag = getFeatureFlag(state, LOBBY_MODE_ENABLED, true) && lobby;
|
|
|
|
const enabledMeetingPassFlag = getFeatureFlag(state, MEETING_PASSWORD_ENABLED, true);
|
2020-04-01 07:47:51 +00:00
|
|
|
|
|
|
|
return {
|
2021-05-14 13:01:43 +00:00
|
|
|
_locked: locked || lobbyEnabled,
|
2022-04-12 07:22:36 +00:00
|
|
|
visible: enabledFlag && (enabledLobbyModeFlag || enabledMeetingPassFlag)
|
2020-04-01 07:47:51 +00:00
|
|
|
};
|
|
|
|
}
|