Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

chore(photos):unify-components-for-credentials

Aswin Asok9d27dd9389bf
diff --git a/web/apps/photos/src/components/auth/CredentialsForm.tsx b/web/apps/photos/src/components/auth/CredentialsForm.tsx
index 3257c7fa54..abd0ccdefb 100644
--- a/web/apps/photos/src/components/auth/CredentialsForm.tsx
+++ b/web/apps/photos/src/components/auth/CredentialsForm.tsx
@@ -1,10 +1,15 @@
import { styled } from "@mui/material";
+import type { VerifyMasterPasswordPresentationProps } from "ente-accounts/components/VerifyMasterPasswordForm";
import type { CredentialsPresentationProps } from "ente-accounts/pages/credentials";
import { pt } from "ente-base/i18n";
import { t } from "i18next";
import type React from "react";
+import { Button } from "./Button";
+import { Form } from "./Form";
+import { FormFields } from "./FormFields";
import { FormFooter } from "./FormFooter";
import { ScreenHeader } from "./ScreenHeader";
+import { TextField } from "./TextField";
import { TextLink } from "./TextLink";
export function CredentialsForm({
@@ -41,6 +46,51 @@ export function CredentialsForm({
);
}
+export function PasswordForm({
+ userEmail,
+ password,
+ passwordError,
+ isSubmitting,
+ submitButtonTitle,
+ onPasswordChange,
+ onSubmit,
+}: VerifyMasterPasswordPresentationProps): React.JSX.Element {
+ return (
+ <Form onSubmit={onSubmit}>
+ <HiddenEmail
+ name="email"
+ type="email"
+ autoComplete="username"
+ value={userEmail}
+ readOnly
+ tabIndex={-1}
+ />
+ <FormFields>
+ <TextField
+ name="password"
+ value={password}
+ onChange={onPasswordChange}
+ type="password"
+ autoComplete="current-password"
+ label={t("password")}
+ showPasswordToggle
+ autoFocus
+ disabled={isSubmitting}
+ error={Boolean(passwordError)}
+ helperText={passwordError}
+ />
+ </FormFields>
+ <FormFooter>
+ <Button fullWidth type="submit" loading={isSubmitting}>
+ {submitButtonTitle}
+ </Button>
+ </FormFooter>
+ </Form>
+ );
+}
+
+const HiddenEmail = styled("input")({ display: "none" });
+
const Email = styled("strong")({
color: "var(--photos-auth-text)",
wordBreak: "break-word",
diff --git a/web/apps/photos/src/components/auth/PasswordForm.tsx b/web/apps/photos/src/components/auth/PasswordForm.tsx
deleted file mode 100644
index cce1dbb03a..0000000000
--- a/web/apps/photos/src/components/auth/PasswordForm.tsx
+++ /dev/null
@@ -1,54 +0,0 @@
-import { styled } from "@mui/material";
-import type { VerifyMasterPasswordPresentationProps } from "ente-accounts/components/VerifyMasterPasswordForm";
-import { t } from "i18next";
-import type React from "react";
-import { Button } from "./Button";
-import { Form } from "./Form";
-import { FormFields } from "./FormFields";
-import { FormFooter } from "./FormFooter";
-import { TextField } from "./TextField";
-
-export function PasswordForm({
- userEmail,
- password,
- passwordError,
- isSubmitting,
- submitButtonTitle,
- onPasswordChange,
- onSubmit,
-}: VerifyMasterPasswordPresentationProps): React.JSX.Element {
- return (
- <Form onSubmit={onSubmit}>
- <HiddenEmail
- name="email"
- type="email"
- autoComplete="username"
- value={userEmail}
- readOnly
- tabIndex={-1}
- />
- <FormFields>
- <TextField
- name="password"
- value={password}
- onChange={onPasswordChange}
- type="password"
- autoComplete="current-password"
- label={t("password")}
- showPasswordToggle
- autoFocus
- disabled={isSubmitting}
- error={Boolean(passwordError)}
- helperText={passwordError}
- />
- </FormFields>
- <FormFooter>
- <Button fullWidth type="submit" loading={isSubmitting}>
- {submitButtonTitle}
- </Button>
- </FormFooter>
- </Form>
- );
-}
-
-const HiddenEmail = styled("input")({ display: "none" });
diff --git a/web/apps/photos/src/pages/credentials.tsx b/web/apps/photos/src/pages/credentials.tsx
index 892c8691dd..b256709f69 100644
--- a/web/apps/photos/src/pages/credentials.tsx
+++ b/web/apps/photos/src/pages/credentials.tsx
@@ -1,6 +1,8 @@
-import { CredentialsForm } from "@/components/auth/CredentialsForm";
+import {
+ CredentialsForm,
+ PasswordForm,
+} from "@/components/auth/CredentialsForm";
import { PasskeyVerificationForm } from "@/components/auth/PasskeyVerificationForm";
-import { PasswordForm } from "@/components/auth/PasswordForm";
import { PhotosAuthShell } from "@/components/PhotosAuthShell";
import { featureFlags } from "@/featureFlags";
import type { VerifyingPasskeyPresentationProps } from "ente-accounts/components/LoginComponents";