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.

fix(web): center auth bootstrap loading and replace install status redirects (#45415)

yyh6af3edd8c47d
diff --git a/web/app/forgot-password/ForgotPasswordForm.tsx b/web/app/forgot-password/ForgotPasswordForm.tsx
index ac89007fe7b..0c189a55469 100644
--- a/web/app/forgot-password/ForgotPasswordForm.tsx
+++ b/web/app/forgot-password/ForgotPasswordForm.tsx
@@ -59,7 +59,7 @@ const ForgotPasswordForm = () => {
}, [])
return loading ? (
- <LoadingPlaceholder />
+ <LoadingPlaceholder className="grow" />
) : (
<>
<div className="sm:mx-auto sm:w-full sm:max-w-md">
diff --git a/web/app/install/installForm.spec.tsx b/web/app/install/installForm.spec.tsx
index 7c4089a17aa..07a0a7c4fe6 100644
--- a/web/app/install/installForm.spec.tsx
+++ b/web/app/install/installForm.spec.tsx
@@ -10,11 +10,10 @@ import InstallForm from './installForm'
const render = (ui: ReactElement) => renderWithConsoleQuery(ui)
-const mockPush = vi.fn()
const mockReplace = vi.fn()
vi.mock('@/next/navigation', () => ({
- useRouter: () => ({ push: mockPush, replace: mockReplace }),
+ useRouter: () => ({ replace: mockReplace }),
}))
vi.mock('@/service/console', async (importOriginal) => {
@@ -101,9 +100,8 @@ describe('InstallForm', () => {
render(<InstallForm />)
- await waitFor(() => expect(mockPush).toHaveBeenCalledWith('/init'))
+ await waitFor(() => expect(mockReplace).toHaveBeenCalledWith('/init'))
expect(screen.queryByLabelText('login.email')).not.toBeInTheDocument()
- expect(mockReplace).not.toHaveBeenCalled()
})
it('revalidates cached bootstrap state before displaying or redirecting', async () => {
@@ -118,18 +116,18 @@ describe('InstallForm', () => {
renderWithConsoleQuery(<InstallForm />, { queryClient })
- expect(mockPush).not.toHaveBeenCalled()
+ expect(mockReplace).not.toHaveBeenCalled()
expect(mockFetchInitValidateStatus).not.toHaveBeenCalled()
expect(screen.queryByLabelText('login.email')).not.toBeInTheDocument()
await act(async () => setupStatus.resolve({ step: 'not_started' }))
await waitFor(() => expect(mockFetchInitValidateStatus).toHaveBeenCalledTimes(1))
- expect(mockPush).not.toHaveBeenCalled()
+ expect(mockReplace).not.toHaveBeenCalled()
expect(screen.queryByLabelText('login.email')).not.toBeInTheDocument()
await act(async () => initStatus.resolve({ status: 'finished' }))
expect(await screen.findByLabelText('login.email')).toBeInTheDocument()
- expect(mockPush).not.toHaveBeenCalled()
+ expect(mockReplace).not.toHaveBeenCalled()
expect(queryClient.getQueryData(consoleQuery.setup.get.queryKey())).toEqual({
step: 'not_started',
})
@@ -154,7 +152,7 @@ describe('InstallForm', () => {
expect(await screen.findByRole('alert')).toHaveTextContent('Bootstrap unavailable')
expect(screen.queryByLabelText('login.email')).not.toBeInTheDocument()
- expect(mockPush).not.toHaveBeenCalled()
+ expect(mockReplace).not.toHaveBeenCalled()
expect(failedCheck).toHaveBeenCalledTimes(1)
if (stage === 'setup') expect(mockFetchInitValidateStatus).not.toHaveBeenCalled()
} finally {
@@ -339,7 +337,7 @@ describe('InstallForm', () => {
render(<InstallForm />)
await waitFor(() => {
- expect(mockPush).toHaveBeenCalledWith('/signin')
+ expect(mockReplace).toHaveBeenCalledWith('/signin')
})
expect(mockFetchInitValidateStatus).not.toHaveBeenCalled()
expect(screen.queryByLabelText('login.email')).not.toBeInTheDocument()
diff --git a/web/app/install/installForm.tsx b/web/app/install/installForm.tsx
index f355a45e17a..e7ef582a23a 100644
--- a/web/app/install/installForm.tsx
+++ b/web/app/install/installForm.tsx
@@ -41,7 +41,7 @@ const InstallForm = () => {
const { t, i18n } = useTranslation(['login'])
const pageTitle = t(($) => $.setAdminAccount, { ns: 'login' })
useDocumentTitle(pageTitle)
- const { push, replace } = useRouter()
+ const { replace } = useRouter()
const queryClient = useQueryClient()
const [isSubmitting, setIsSubmitting] = React.useState(false)
const setupStatus = useQuery(
@@ -102,16 +102,16 @@ const InstallForm = () => {
useEffect(() => {
if (!setupStatus.isSuccess || setupStatus.isFetching) return
if (setupStatus.data.step === 'finished') {
- push('/signin')
+ replace('/signin')
} else if (
initStatus.isSuccess &&
!initStatus.isFetching &&
initStatus.data.status === 'not_started'
) {
- push('/init')
+ replace('/init')
}
}, [
- push,
+ replace,
setupStatus.isSuccess,
setupStatus.isFetching,
setupStatus.data,
@@ -129,7 +129,7 @@ const InstallForm = () => {
initStatus.data.status !== 'not_started'
return !canSetup ? (
- <LoadingPlaceholder />
+ <LoadingPlaceholder className="grow" />
) : (
<>
<div className="sm:mx-auto sm:w-full sm:max-w-md">