2022-08-04 08:26:13 +00:00
|
|
|
/* eslint-disable lines-around-comment */
|
2022-09-27 07:10:28 +00:00
|
|
|
import React, { useEffect, useState } from 'react';
|
2020-04-01 07:47:51 +00:00
|
|
|
|
2022-09-05 11:24:13 +00:00
|
|
|
import { IState } from '../../../../app/types';
|
2022-10-19 08:42:54 +00:00
|
|
|
import { setPassword as setPass } from '../../../../base/conference/actions';
|
2022-08-08 08:12:22 +00:00
|
|
|
import { isLocalParticipantModerator } from '../../../../base/participants/functions';
|
2022-09-05 11:24:13 +00:00
|
|
|
import { connect } from '../../../../base/redux/functions';
|
2022-10-10 09:12:02 +00:00
|
|
|
import Dialog from '../../../../base/ui/components/web/Dialog';
|
2022-08-04 08:26:13 +00:00
|
|
|
// @ts-ignore
|
2021-04-09 12:30:25 +00:00
|
|
|
import { E2EESection } from '../../../../e2ee/components';
|
2022-08-04 08:26:13 +00:00
|
|
|
// @ts-ignore
|
2021-04-09 12:30:25 +00:00
|
|
|
import { LobbySection } from '../../../../lobby';
|
2020-04-01 07:47:51 +00:00
|
|
|
|
|
|
|
import PasswordSection from './PasswordSection';
|
|
|
|
|
2022-08-04 08:26:13 +00:00
|
|
|
export interface NotifyClick {
|
|
|
|
key: string;
|
|
|
|
preventExecution: boolean;
|
|
|
|
}
|
|
|
|
|
2020-04-01 07:47:51 +00:00
|
|
|
type Props = {
|
|
|
|
|
2022-01-04 11:21:00 +00:00
|
|
|
/**
|
|
|
|
* Toolbar buttons which have their click exposed through the API.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
_buttonsWithNotifyClick: Array<string | NotifyClick>;
|
2022-01-04 11:21:00 +00:00
|
|
|
|
2020-04-01 07:47:51 +00:00
|
|
|
/**
|
|
|
|
* Whether or not the current user can modify the current password.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
_canEditPassword: boolean;
|
2020-04-01 07:47:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The JitsiConference for which to display a lock state and change the
|
|
|
|
* password.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
_conference: Object;
|
2020-04-01 07:47:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The value for how the conference is locked (or undefined if not locked)
|
|
|
|
* as defined by room-lock constants.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
_locked: string;
|
2020-04-01 07:47:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The current known password for the JitsiConference.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
_password: string;
|
2020-04-01 07:47:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The number of digits to be used in the password.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
_passwordNumberOfDigits?: number;
|
2020-04-01 07:47:51 +00:00
|
|
|
|
2020-06-18 17:25:49 +00:00
|
|
|
/**
|
|
|
|
* Indicates whether e2ee will be displayed or not.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
_showE2ee: boolean;
|
2020-06-18 17:25:49 +00:00
|
|
|
|
2020-04-01 07:47:51 +00:00
|
|
|
/**
|
|
|
|
* Action that sets the conference password.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
setPassword: Function;
|
2020-04-01 07:47:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Component that renders the security options dialog.
|
|
|
|
*
|
|
|
|
* @returns {React$Element<any>}
|
|
|
|
*/
|
|
|
|
function SecurityDialog({
|
2022-01-04 11:21:00 +00:00
|
|
|
_buttonsWithNotifyClick,
|
2020-04-01 07:47:51 +00:00
|
|
|
_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
|
2022-10-10 09:12:02 +00:00
|
|
|
cancel = {{ hidden: true }}
|
|
|
|
ok = {{ hidden: true }}
|
|
|
|
titleKey = 'security.title'>
|
2020-04-01 07:47:51 +00:00
|
|
|
<div className = 'security-dialog'>
|
2020-05-20 08:25:31 +00:00
|
|
|
<LobbySection />
|
2020-04-01 07:47:51 +00:00
|
|
|
<PasswordSection
|
2022-01-04 11:21:00 +00:00
|
|
|
buttonsWithNotifyClick = { _buttonsWithNotifyClick }
|
2020-04-01 07:47:51 +00:00
|
|
|
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}
|
|
|
|
*/
|
2022-09-05 11:24:13 +00:00
|
|
|
function mapStateToProps(state: IState) {
|
2020-04-01 07:47:51 +00:00
|
|
|
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'];
|
2022-01-04 11:21:00 +00:00
|
|
|
const { roomPasswordNumberOfDigits, buttonsWithNotifyClick } = state['features/base/config'];
|
2020-04-01 07:47:51 +00:00
|
|
|
|
2021-06-04 07:23:17 +00:00
|
|
|
const showE2ee = Boolean(e2eeSupported) && isLocalParticipantModerator(state);
|
|
|
|
|
2020-04-01 07:47:51 +00:00
|
|
|
return {
|
2022-01-04 11:21:00 +00:00
|
|
|
_buttonsWithNotifyClick: buttonsWithNotifyClick,
|
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,
|
2021-06-04 07:23:17 +00:00
|
|
|
_showE2ee: showE2ee
|
2020-04-01 07:47:51 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
const mapDispatchToProps = { setPassword: setPass };
|
|
|
|
|
2021-06-10 12:48:44 +00:00
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(SecurityDialog);
|