Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add icons and login #1062

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion modern/src/login/LoginPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
import makeStyles from '@mui/styles/makeStyles';
import CloseIcon from '@mui/icons-material/Close';
import LockOpenIcon from '@mui/icons-material/LockOpen';
import VisibilityOffIcon from '@mui/icons-material/VisibilityOff';
import { useTheme } from '@mui/material/styles';
import { useDispatch, useSelector } from 'react-redux';
import { useNavigate } from 'react-router-dom';
Expand Down Expand Up @@ -57,6 +58,11 @@ const LoginPage = () => {
const [email, setEmail] = usePersistedState('loginEmail', '');
const [password, setPassword] = useState('');

const [showPassword, setShowPassword] = useState(false);
const handleClickShowPassword = () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please inline these callbacks.

setShowPassword(!showPassword);
};

const registrationEnabled = useSelector((state) => state.session.server.registration);
const languageEnabled = useSelector((state) => !state.session.server.attributes['ui.disableLoginLanguage']);
const emailEnabled = useSelector((state) => state.session.server.emailEnabled);
Expand Down Expand Up @@ -160,11 +166,18 @@ const LoginPage = () => {
label={t('userPassword')}
name="password"
value={password}
type="password"
type={showPassword ? 'text' : 'password'}
autoComplete="current-password"
autoFocus={!!email}
onChange={(e) => setPassword(e.target.value)}
onKeyUp={handleSpecialKey}
InputProps={{
endAdornment: (
<IconButton onClick={handleClickShowPassword}>
<VisibilityOffIcon />
</IconButton>
),
}}
/>
<Button
onClick={handlePasswordLogin}
Expand Down
13 changes: 13 additions & 0 deletions modern/src/login/RegisterPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
import makeStyles from '@mui/styles/makeStyles';
import { useNavigate } from 'react-router-dom';
import ArrowBackIcon from '@mui/icons-material/ArrowBack';
import VisibilityOffIcon from '@mui/icons-material/VisibilityOff';
import LoginLayout from './LoginLayout';
import { useTranslation } from '../common/components/LocalizationProvider';
import { snackBarDurationShortMs } from '../common/util/duration';
Expand Down Expand Up @@ -38,6 +39,11 @@ const RegisterPage = () => {
const [password, setPassword] = useState('');
const [snackbarOpen, setSnackbarOpen] = useState(false);

const [showPassword, setShowPassword] = useState(false);
const handleClickShowPassword = () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and this

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ps from what it translates for me I understand that I must add the lines that you are showing me,
but I already have that added to the code

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, you should remove them and inline the code. There's no point to have separate methods with just one line implementation.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change is missing in RegisterPage.js

type={showPassword ? 'text' : 'password'}

setShowPassword(!showPassword);
};

const handleSubmit = useCatch(async () => {
const response = await fetch('/api/users', {
method: 'POST',
Expand Down Expand Up @@ -88,6 +94,13 @@ const RegisterPage = () => {
type="password"
autoComplete="current-password"
onChange={(event) => setPassword(event.target.value)}
InputProps={{
endAdornment: (
<IconButton onClick={handleClickShowPassword}>
<VisibilityOffIcon />
</IconButton>
),
}}
/>
<Button
variant="contained"
Expand Down