π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Update
Manav Rathi9114fbca27ac
diff --git a/web/packages/accounts/components/SetPasswordForm.tsx b/web/packages/accounts/components/SetPasswordForm.tsxindex 4c407b8137..90c65b951a 100644--- a/web/packages/accounts/components/SetPasswordForm.tsx+++ b/web/packages/accounts/components/SetPasswordForm.tsx@@ -1,10 +1,10 @@import { Box, Input, TextField, Typography } from "@mui/material";import { isWeakPassword } from "ente-accounts/utils/password";import { LoadingButton } from "ente-base/components/mui/LoadingButton";-import ShowHidePassword from "ente-shared/components/Form/ShowHidePassword";+import { ShowHidePasswordInputAdornment } from "ente-base/components/mui/PasswordInputAdornment";import { Formik } from "formik";import { t } from "i18next";-import React, { useState } from "react";+import { useCallback, useState } from "react";import { Trans } from "react-i18next";import * as Yup from "yup";import { PasswordStrengthHint } from "./PasswordStrength";@@ -30,15 +30,10 @@ function SetPasswordForm(props: SetPasswordFormProps) {const [loading, setLoading] = useState(false);const [showPassword, setShowPassword] = useState(false);- const handleClickShowPassword = () => {- setShowPassword(!showPassword);- };-- const handleMouseDownPassword = (- event: React.MouseEvent<HTMLButtonElement>,- ) => {- event.preventDefault();- };+ const handleToggleShowHidePassword = useCallback(+ () => setShowPassword((show) => !show),+ [],+ );const onSubmit = async (values: SetPasswordFormValues,@@ -111,14 +106,9 @@ function SetPasswordForm(props: SetPasswordFormProps) {slotProps={{input: {endAdornment: (- <ShowHidePassword+ <ShowHidePasswordInputAdornmentshowPassword={showPassword}- handleClickShowPassword={- handleClickShowPassword- }- handleMouseDownPassword={- handleMouseDownPassword- }+ onToggle={handleToggleShowHidePassword}/>),},diff --git a/web/packages/accounts/components/SignUpContents.tsx b/web/packages/accounts/components/SignUpContents.tsxindex d5e6f56faa..8078ac780e 100644--- a/web/packages/accounts/components/SignUpContents.tsx+++ b/web/packages/accounts/components/SignUpContents.tsx@@ -17,12 +17,12 @@ import { generateKeyAndSRPAttributes } from "ente-accounts/services/srp";import { sendOTT } from "ente-accounts/services/user";import { isWeakPassword } from "ente-accounts/utils/password";import { LinkButton } from "ente-base/components/LinkButton";+import { ShowHidePasswordInputAdornment } from "ente-base/components/MUI/PasswordInputAdornment";import { LoadingButton } from "ente-base/components/mui/LoadingButton";import { isMuseumHTTPError } from "ente-base/http";import log from "ente-base/log";import { setLSUser } from "ente-shared//storage/localStorage";import { VerticallyCentered } from "ente-shared/components/Container";-import ShowHidePassword from "ente-shared/components/Form/ShowHidePassword";import {generateAndSaveIntermediateKeyAttributes,saveKeyInSessionStore,@@ -68,13 +68,10 @@ export const SignUpContents: React.FC<SignUpContentsProps> = ({const [loading, setLoading] = useState(false);const [showPassword, setShowPassword] = useState(false);- const handleShowPassword = useCallback(() => setShowPassword((show) => !show), []);-- const handleMouseDownPassword = (- event: React.MouseEvent<HTMLButtonElement>,- ) => {- event.preventDefault();- };+ const handleToggleShowHidePassword = useCallback(+ () => setShowPassword((show) => !show),+ [],+ );const registerUser = async ({ email, passphrase, confirm, referral }: FormValues,@@ -183,13 +180,10 @@ export const SignUpContents: React.FC<SignUpContentsProps> = ({slotProps={{input: {endAdornment: (- <ShowHidePassword+ <ShowHidePasswordInputAdornmentshowPassword={showPassword}- handleClickShowPassword={- handleShowPassword- }- handleMouseDownPassword={- handleMouseDownPassword+ onToggle={+ handleToggleShowHidePassword}/>),diff --git a/web/packages/base/components/mui/PasswordInputAdornment.tsx b/web/packages/base/components/mui/PasswordInputAdornment.tsxnew file mode 100644index 0000000000..08c4771bc6--- /dev/null+++ b/web/packages/base/components/mui/PasswordInputAdornment.tsx@@ -0,0 +1,49 @@+import VisibilityIcon from "@mui/icons-material/Visibility";+import VisibilityOffIcon from "@mui/icons-material/VisibilityOff";+import { IconButton, InputAdornment } from "@mui/material";+import { t } from "i18next";+import React from "react";++interface ShowHidePasswordInputAdornmentProps {+ /**+ * When `true`, the password is being shown.+ */+ showPassword: boolean;+ /**+ * Called when the user wants to toggle the state of {@link showPassword}.+ */+ onToggle: () => void;+}++/**+ * A MUI {@link InputAdornment} that can be used at the trailing edge of a+ * password input field to allow the user to toggle the visibility of the+ * password.+ */+export const ShowHidePasswordInputAdornment: React.FC<+ ShowHidePasswordInputAdornmentProps+> = ({ showPassword, onToggle: onToggle }) => {+ // Prevent password field from losing focus when the input adornment is+ // clicked by ignoring both the mouse up and down events. This is the+ // approach mentioned in the MUI docs.+ // https://mui.com/material-ui/react-text-field/#input-adornments+ const preventDefault = (event: React.MouseEvent<HTMLButtonElement>) => {+ event.preventDefault();+ };++ return (+ <InputAdornment position="end">+ <IconButton+ tabIndex={-1}+ color="secondary"+ aria-label={t("show_or_hide_password")}+ onClick={onToggle}+ onMouseUp={preventDefault}+ onMouseDown={preventDefault}+ edge="end"+ >+ {showPassword ? <VisibilityOffIcon /> : <VisibilityIcon />}+ </IconButton>+ </InputAdornment>+ );+};diff --git a/web/packages/base/locales/en-US/translation.json b/web/packages/base/locales/en-US/translation.jsonindex 631c829cac..16ae6f92fd 100644--- a/web/packages/base/locales/en-US/translation.json+++ b/web/packages/base/locales/en-US/translation.json@@ -40,6 +40,7 @@"referral_source_hint": "How did you hear about Ente? (optional)","referral_source_info": "We don't track app installs, It'd help us if you told us where you found us!","password_mismatch_error": "Passwords don't match",+ "show_or_hide_password": "Show or hide password","welcome_to_ente_title": "Welcome to <a/>","welcome_to_ente_subtitle": "End to end encrypted photo storage and sharing","new_album": "New album",diff --git a/web/packages/shared/components/Form/ShowHidePassword.tsx b/web/packages/shared/components/Form/ShowHidePassword.tsxdeleted file mode 100644index 0f3a7d3b5c..0000000000--- a/web/packages/shared/components/Form/ShowHidePassword.tsx+++ /dev/null@@ -1,32 +0,0 @@-import VisibilityIcon from "@mui/icons-material/Visibility";-import VisibilityOffIcon from "@mui/icons-material/VisibilityOff";-import { IconButton, InputAdornment } from "@mui/material";-import React from "react";--interface Iprops {- showPassword: boolean;- handleClickShowPassword: () => void;- handleMouseDownPassword: (- event: React.MouseEvent<HTMLButtonElement>,- ) => void;-}-const ShowHidePassword = ({- showPassword,- handleClickShowPassword,- handleMouseDownPassword,-}: Iprops) => (- <InputAdornment position="end">- <IconButton- tabIndex={-1}- color="secondary"- aria-label="toggle password visibility"- onClick={handleClickShowPassword}- onMouseDown={handleMouseDownPassword}- edge="end"- >- {showPassword ? <VisibilityOffIcon /> : <VisibilityIcon />}- </IconButton>- </InputAdornment>-);--export default ShowHidePassword;diff --git a/web/packages/shared/components/SingleInputForm.tsx b/web/packages/shared/components/SingleInputForm.tsxindex ba9d2de6d2..e05627e40d 100644--- a/web/packages/shared/components/SingleInputForm.tsx+++ b/web/packages/shared/components/SingleInputForm.tsx@@ -2,11 +2,11 @@ import { FormHelperText } from "@mui/material";import TextField from "@mui/material/TextField";import { FocusVisibleButton } from "ente-base/components/mui/FocusVisibleButton";import { LoadingButton } from "ente-base/components/mui/LoadingButton";+import { ShowHidePasswordInputAdornment } from "ente-base/components/mui/PasswordInputAdornment";import { FlexWrapper } from "ente-shared/components/Container";-import ShowHidePassword from "ente-shared/components/Form/ShowHidePassword";import { Formik, type FormikHelpers, type FormikState } from "formik";import { t } from "i18next";-import React, { useMemo, useState } from "react";+import { useCallback, useMemo, useState } from "react";import * as Yup from "yup";interface formValues {@@ -64,6 +64,11 @@ export default function SingleInputForm(props: SingleInputFormProps) {const [loading, SetLoading] = useState(false);const [showPassword, setShowPassword] = useState(false);+ const handleToggleShowHidePassword = useCallback(+ () => setShowPassword((show) => !show),+ [],+ );+const submitForm = async (values: formValues,{ setFieldError, resetForm }: FormikHelpers<formValues>,@@ -77,16 +82,6 @@ export default function SingleInputForm(props: SingleInputFormProps) {SetLoading(false);};- const handleClickShowPassword = () => {- setShowPassword(!showPassword);- };-- const handleMouseDownPassword = (- event: React.MouseEvent<HTMLButtonElement>,- ) => {- event.preventDefault();- };-const validationSchema = useMemo(() => {switch (props.fieldType) {case "text":@@ -148,14 +143,9 @@ export default function SingleInputForm(props: SingleInputFormProps) {: "on",endAdornment: props.fieldType ==="password" && (- <ShowHidePassword+ <ShowHidePasswordInputAdornmentshowPassword={showPassword}- handleClickShowPassword={- handleClickShowPassword- }- handleMouseDownPassword={- handleMouseDownPassword- }+ onToggle={handleToggleShowHidePassword}/>),},