fix(lobby) Make password hidden by default (#12295)

This commit is contained in:
Robert Pintilii 2022-10-04 13:52:37 +03:00 committed by GitHub
parent 3e744c5ffe
commit 7d7bf987a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 72 additions and 4 deletions

View File

@ -28,7 +28,7 @@
color: #6FB1EA; color: #6FB1EA;
} }
& > :first-child:not(:last-child) { & > :not(:last-child) {
margin-right: 24px; margin-right: 24px;
} }
} }

View File

@ -270,6 +270,7 @@
"gracefulShutdown": "Our service is currently down for maintenance. Please try again later.", "gracefulShutdown": "Our service is currently down for maintenance. Please try again later.",
"grantModeratorDialog": "Are you sure you want to grant moderator rights to {{participantName}}?", "grantModeratorDialog": "Are you sure you want to grant moderator rights to {{participantName}}?",
"grantModeratorTitle": "Grant moderator rights", "grantModeratorTitle": "Grant moderator rights",
"hide": "Hide",
"hideShareAudioHelper": "Don't show this dialog again", "hideShareAudioHelper": "Don't show this dialog again",
"incorrectPassword": "Incorrect username or password", "incorrectPassword": "Incorrect username or password",
"incorrectRoomLockPassword": "Incorrect password", "incorrectRoomLockPassword": "Incorrect password",
@ -387,6 +388,7 @@
"shareYourScreenDisabled": "Screen sharing disabled.", "shareYourScreenDisabled": "Screen sharing disabled.",
"sharedVideoDialogError": "Error: Invalid URL", "sharedVideoDialogError": "Error: Invalid URL",
"sharedVideoLinkPlaceholder": "YouTube link or direct video link", "sharedVideoLinkPlaceholder": "YouTube link or direct video link",
"show": "Show",
"start": "Start ", "start": "Start ",
"startLiveStreaming": "Start live stream", "startLiveStreaming": "Start live stream",
"startRecording": "Start recording", "startRecording": "Start recording",

View File

@ -38,6 +38,11 @@ interface Props extends WithTranslation {
* The number of digits to be used in the password. * The number of digits to be used in the password.
*/ */
passwordNumberOfDigits?: number; passwordNumberOfDigits?: number;
/**
* Whether or not the password should be visible.
*/
visible: boolean;
} }
/** /**
@ -117,7 +122,7 @@ class PasswordForm extends Component<Props, State> {
<span className = 'info-password-field info-value'> <span className = 'info-password-field info-value'>
{locked === LOCKED_LOCALLY ? ( {locked === LOCKED_LOCALLY ? (
<div className = 'info-password-local'> <div className = 'info-password-local'>
{this.props.password} {this.props.visible ? this.props.password : '******' }
</div> </div>
) : ( ) : (
<div className = 'info-password-remote'> <div className = 'info-password-remote'>
@ -156,6 +161,7 @@ class PasswordForm extends Component<Props, State> {
onChange = { this._onEnteredPasswordChange } onChange = { this._onEnteredPasswordChange }
onKeyPress = { this._onKeyPress } onKeyPress = { this._onKeyPress }
placeholder = { placeHolderText } placeholder = { placeHolderText }
type = 'password'
value = { this.state.enteredPassword } /> value = { this.state.enteredPassword } />
</div> </div>
); );

View File

@ -1,9 +1,10 @@
/* eslint-disable react/jsx-no-bind */ /* eslint-disable react/jsx-no-bind */
import React, { useRef } from 'react'; import React, { useRef, useState } from 'react';
import { WithTranslation } from 'react-i18next'; import { WithTranslation } from 'react-i18next';
import { translate } from '../../../../base/i18n/functions'; import { translate } from '../../../../base/i18n/functions';
import { copyText } from '../../../../base/util/copyText'; import { copyText } from '../../../../base/util/copyText';
import { LOCKED_LOCALLY } from '../../../../room-lock/constants';
import { NOTIFY_CLICK_MODE } from '../../../../toolbox/constants'; import { NOTIFY_CLICK_MODE } from '../../../../toolbox/constants';
import PasswordForm from './PasswordForm'; import PasswordForm from './PasswordForm';
@ -82,6 +83,7 @@ function PasswordSection({
t }: Props) { t }: Props) {
const formRef = useRef<HTMLDivElement>(null); const formRef = useRef<HTMLDivElement>(null);
const [ passwordVisible, setPasswordVisible ] = useState(false);
/** /**
* Callback invoked to set a password on the current JitsiConference. * Callback invoked to set a password on the current JitsiConference.
@ -229,6 +231,52 @@ function PasswordSection({
} }
} }
/**
* Callback invoked to show the current password.
*
* @returns {void}
*/
function onPasswordShow() {
setPasswordVisible(true);
}
/**
* Callback invoked to show the current password.
*
* @param {Object} e - The key event to handle.
*
* @returns {void}
*/
function onPasswordShowKeyPressHandler(e: React.KeyboardEvent) {
if (e.key === ' ' || e.key === 'Enter') {
e.preventDefault();
setPasswordVisible(true);
}
}
/**
* Callback invoked to hide the current password.
*
* @returns {void}
*/
function onPasswordHide() {
setPasswordVisible(false);
}
/**
* Callback invoked to hide the current password.
*
* @param {Object} e - The key event to handle.
*
* @returns {void}
*/
function onPasswordHideKeyPressHandler(e: React.KeyboardEvent) {
if (e.key === ' ' || e.key === 'Enter') {
e.preventDefault();
setPasswordVisible(false);
}
}
/** /**
* Method that renders the password action(s) based on the current * Method that renders the password action(s) based on the current
* locked-status of the conference. * locked-status of the conference.
@ -282,6 +330,17 @@ function PasswordSection({
tabIndex = { 0 }>{ t('dialog.copy') }</a> tabIndex = { 0 }>{ t('dialog.copy') }</a>
</> : null </> : null
} }
{locked === LOCKED_LOCALLY && (
<a
aria-label = { t(passwordVisible ? 'dialog.hide' : 'dialog.show') }
onClick = { passwordVisible ? onPasswordHide : onPasswordShow }
onKeyPress = { passwordVisible
? onPasswordHideKeyPressHandler
: onPasswordShowKeyPressHandler
}
role = 'button'
tabIndex = { 0 }>{t(passwordVisible ? 'dialog.hide' : 'dialog.show')}</a>
)}
</> </>
); );
} }
@ -311,7 +370,8 @@ function PasswordSection({
locked = { locked } locked = { locked }
onSubmit = { onPasswordSubmit } onSubmit = { onPasswordSubmit }
password = { password } password = { password }
passwordNumberOfDigits = { passwordNumberOfDigits } /> passwordNumberOfDigits = { passwordNumberOfDigits }
visible = { passwordVisible } />
</div> </div>
<div className = 'security-dialog password-actions'> <div className = 'security-dialog password-actions'>
{ renderPasswordActions() } { renderPasswordActions() }