2020-04-01 07:47:51 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import React, { useState, useEffect } from 'react';
|
|
|
|
|
|
|
|
import { setPassword as setPass } from '../../../base/conference';
|
|
|
|
import { Dialog } from '../../../base/dialog';
|
|
|
|
import { translate } from '../../../base/i18n';
|
|
|
|
import { isLocalParticipantModerator } from '../../../base/participants';
|
|
|
|
import { connect } from '../../../base/redux';
|
2020-06-17 10:53:46 +00:00
|
|
|
import { E2EESection } from '../../../e2ee/components';
|
2020-05-20 08:25:31 +00:00
|
|
|
import { LobbySection } from '../../../lobby';
|
2020-04-01 07:47:51 +00:00
|
|
|
|
|
|
|
import Header from './Header';
|
|
|
|
import PasswordSection from './PasswordSection';
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not the current user can modify the current password.
|
|
|
|
*/
|
|
|
|
_canEditPassword: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The JitsiConference for which to display a lock state and change the
|
|
|
|
* password.
|
|
|
|
*/
|
|
|
|
_conference: Object,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The value for how the conference is locked (or undefined if not locked)
|
|
|
|
* as defined by room-lock constants.
|
|
|
|
*/
|
|
|
|
_locked: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The current known password for the JitsiConference.
|
|
|
|
*/
|
|
|
|
_password: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The number of digits to be used in the password.
|
|
|
|
*/
|
|
|
|
_passwordNumberOfDigits: ?number,
|
|
|
|
|
2020-06-18 17:25:49 +00:00
|
|
|
/**
|
|
|
|
* Indicates whether e2ee will be displayed or not.
|
|
|
|
*/
|
|
|
|
_showE2ee: boolean,
|
|
|
|
|
2020-04-01 07:47:51 +00:00
|
|
|
/**
|
|
|
|
* Action that sets the conference password.
|
|
|
|
*/
|
|
|
|
setPassword: Function,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoked to obtain translated strings.
|
|
|
|
*/
|
|
|
|
t: Function
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Component that renders the security options dialog.
|
|
|
|
*
|
|
|
|
* @returns {React$Element<any>}
|
|
|
|
*/
|
|
|
|
function SecurityDialog({
|
|
|
|
_canEditPassword,
|
|
|
|
_conference,
|
|
|
|
_locked,
|
|
|
|
_password,
|
|
|
|
_passwordNumberOfDigits,
|
2020-06-18 17:25:49 +00:00
|
|
|
_showE2ee,
|
2020-05-20 08:25:31 +00:00
|
|
|
setPassword
|
2020-04-01 07:47:51 +00:00
|
|
|
}: Props) {
|
|
|
|
const [ passwordEditEnabled, setPasswordEditEnabled ] = useState(false);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (passwordEditEnabled && _password) {
|
|
|
|
setPasswordEditEnabled(false);
|
|
|
|
}
|
|
|
|
}, [ _password ]);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Dialog
|
|
|
|
customHeader = { Header }
|
|
|
|
hideCancelButton = { true }
|
|
|
|
submitDisabled = { true }
|
|
|
|
titleKey = 'security.securityOptions'
|
|
|
|
width = { 'small' }>
|
|
|
|
<div className = 'security-dialog'>
|
2020-05-20 08:25:31 +00:00
|
|
|
<LobbySection />
|
2020-04-01 07:47:51 +00:00
|
|
|
<PasswordSection
|
|
|
|
canEditPassword = { _canEditPassword }
|
|
|
|
conference = { _conference }
|
|
|
|
locked = { _locked }
|
|
|
|
password = { _password }
|
|
|
|
passwordEditEnabled = { passwordEditEnabled }
|
|
|
|
passwordNumberOfDigits = { _passwordNumberOfDigits }
|
|
|
|
setPassword = { setPassword }
|
|
|
|
setPasswordEditEnabled = { setPasswordEditEnabled } />
|
2020-06-18 17:25:49 +00:00
|
|
|
{
|
|
|
|
_showE2ee ? <>
|
|
|
|
<div className = 'separator-line' />
|
|
|
|
<E2EESection />
|
|
|
|
</> : null
|
|
|
|
}
|
|
|
|
|
2020-04-01 07:47:51 +00:00
|
|
|
</div>
|
|
|
|
</Dialog>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps (parts of) the Redux state to the associated props for the
|
|
|
|
* {@code SecurityDialog} component.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @private
|
|
|
|
* @returns {Props}
|
|
|
|
*/
|
|
|
|
function mapStateToProps(state) {
|
|
|
|
const {
|
|
|
|
conference,
|
2020-06-18 17:25:49 +00:00
|
|
|
e2eeSupported,
|
2020-04-01 07:47:51 +00:00
|
|
|
locked,
|
|
|
|
password
|
|
|
|
} = state['features/base/conference'];
|
2020-11-05 18:23:49 +00:00
|
|
|
const { roomPasswordNumberOfDigits } = state['features/base/config'];
|
2020-04-01 07:47:51 +00:00
|
|
|
|
|
|
|
return {
|
2020-11-05 18:23:49 +00:00
|
|
|
_canEditPassword: isLocalParticipantModerator(state),
|
2020-04-01 07:47:51 +00:00
|
|
|
_conference: conference,
|
|
|
|
_dialIn: state['features/invite'],
|
|
|
|
_locked: locked,
|
2020-06-18 17:25:49 +00:00
|
|
|
_password: password,
|
2020-07-21 15:17:43 +00:00
|
|
|
_passwordNumberOfDigits: roomPasswordNumberOfDigits,
|
2020-06-18 17:25:49 +00:00
|
|
|
_showE2ee: Boolean(e2eeSupported)
|
2020-04-01 07:47:51 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
const mapDispatchToProps = { setPassword: setPass };
|
|
|
|
|
|
|
|
export default translate(connect(mapStateToProps, mapDispatchToProps)(SecurityDialog));
|