Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

refactor(web): migrate webapp password fields to dify ui (#40223)

yyh2917d1d51cba
diff --git a/oxlint-suppressions.json b/oxlint-suppressions.json
index bda51f3b8c8..5994cc2013b 100644
--- a/oxlint-suppressions.json
+++ b/oxlint-suppressions.json
@@ -126,11 +126,6 @@
"count": 1
}
},
- "web/app/(shareLayout)/webapp-signin/components/mail-and-password-auth.tsx": {
- "no-restricted-imports": {
- "count": 1
- }
- },
"web/app/(shareLayout)/webapp-signin/normalForm.tsx": {
"jsx_a11y/click-events-have-key-events": {
"count": 2
diff --git a/web/app/(shareLayout)/webapp-signin/components/__tests__/mail-and-password-auth.spec.tsx b/web/app/(shareLayout)/webapp-signin/components/__tests__/mail-and-password-auth.spec.tsx
index c8a7bda9c00..cffa0687b4b 100644
--- a/web/app/(shareLayout)/webapp-signin/components/__tests__/mail-and-password-auth.spec.tsx
+++ b/web/app/(shareLayout)/webapp-signin/components/__tests__/mail-and-password-auth.spec.tsx
@@ -73,4 +73,14 @@ describe('MailAndPasswordAuth', () => {
expect(webAppLoginMock).toHaveBeenCalledTimes(1)
})
})
+
+ it('keeps the password field name separate from the recovery link', () => {
+ render(<MailAndPasswordAuth isEmailSetup />)
+
+ expect(screen.getByLabelText('login.password', { exact: true })).toHaveAttribute(
+ 'name',
+ 'password',
+ )
+ expect(screen.getByRole('link', { name: 'login.forget' })).toBeInTheDocument()
+ })
})
diff --git a/web/app/(shareLayout)/webapp-signin/components/mail-and-password-auth.tsx b/web/app/(shareLayout)/webapp-signin/components/mail-and-password-auth.tsx
index f52a78f100a..0c3caa4c110 100644
--- a/web/app/(shareLayout)/webapp-signin/components/mail-and-password-auth.tsx
+++ b/web/app/(shareLayout)/webapp-signin/components/mail-and-password-auth.tsx
@@ -1,10 +1,11 @@
'use client'
import { Button } from '@langgenius/dify-ui/button'
+import { Field, FieldControl, FieldLabel } from '@langgenius/dify-ui/field'
+import { Form } from '@langgenius/dify-ui/form'
import { toast } from '@langgenius/dify-ui/toast'
import { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { resolveWebAppLoginRedirect } from '@/app/(shareLayout)/webapp-signin/login-redirect'
-import Input from '@/app/components/base/input'
import { emailRegex } from '@/config'
import { useLocale } from '@/context/i18n'
import { useWebAppStore } from '@/context/web-app-context'
@@ -100,21 +101,19 @@ export default function MailAndPasswordAuth({ isEmailSetup }: MailAndPasswordAut
}
return (
- <form
- onSubmit={(event) => {
- event.preventDefault()
+ <Form
+ onFormSubmit={() => {
void handleEmailPasswordLogin()
}}
>
- <div className="mb-3">
- <label htmlFor="email" className="my-2 system-md-semibold text-text-secondary">
+ <Field name="email" className="mb-3 block">
+ <FieldLabel className="my-2 py-0 text-sm leading-5 font-semibold text-text-secondary">
{t(($) => $.email, { ns: 'login' })}
- </label>
+ </FieldLabel>
<div className="mt-1">
- <Input
- name="email"
+ <FieldControl
value={email}
- onChange={(e) => setEmail(e.target.value)}
+ onValueChange={setEmail}
id="email"
type="email"
autoComplete="email"
@@ -122,13 +121,13 @@ export default function MailAndPasswordAuth({ isEmailSetup }: MailAndPasswordAut
placeholder={t(($) => $.emailPlaceholder, { ns: 'login' }) || ''}
/>
</div>
- </div>
+ </Field>
- <div className="mb-3">
- <label htmlFor="password" className="my-2 flex items-center justify-between">
- <span className="system-md-semibold text-text-secondary">
+ <Field name="password" className="mb-3 block">
+ <div className="my-2 flex items-center justify-between">
+ <FieldLabel className="py-0 text-sm leading-5 font-semibold text-text-secondary">
{t(($) => $.password, { ns: 'login' })}
- </span>
+ </FieldLabel>
<Link
href={`/webapp-reset-password?${searchParams.toString()}`}
className={`system-xs-regular ${isEmailSetup ? 'text-components-button-secondary-accent-text' : 'pointer-events-none text-components-button-secondary-accent-text-disabled'}`}
@@ -137,12 +136,11 @@ export default function MailAndPasswordAuth({ isEmailSetup }: MailAndPasswordAut
>
{t(($) => $.forget, { ns: 'login' })}
</Link>
- </label>
+ </div>
<div className="relative mt-1">
- <Input
- name="password"
+ <FieldControl
value={password}
- onChange={(e) => setPassword(e.target.value)}
+ onValueChange={setPassword}
id="password"
type={showPassword ? 'text' : 'password'}
autoComplete="current-password"
@@ -155,7 +153,7 @@ export default function MailAndPasswordAuth({ isEmailSetup }: MailAndPasswordAut
</Button>
</div>
</div>
- </div>
+ </Field>
<div className="mb-2">
<Button
@@ -167,6 +165,6 @@ export default function MailAndPasswordAuth({ isEmailSetup }: MailAndPasswordAut
{t(($) => $.signBtn, { ns: 'login' })}
</Button>
</div>
- </form>
+ </Form>
)
}