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): avoid redundant document enable success toast (#44594)

ZengLiangliange7dcb19c056e
diff --git a/web/app/components/datasets/common/document-status-with-action/__tests__/auto-disabled-document.spec.tsx b/web/app/components/datasets/common/document-status-with-action/__tests__/auto-disabled-document.spec.tsx
index f7ea3df60a4..8eac22bdced 100644
--- a/web/app/components/datasets/common/document-status-with-action/__tests__/auto-disabled-document.spec.tsx
+++ b/web/app/components/datasets/common/document-status-with-action/__tests__/auto-disabled-document.spec.tsx
@@ -4,7 +4,15 @@ import { renderWithConsoleQuery as render } from '@/test/console/query-data'
import { createDeferred } from '@/test/deferred'
import AutoDisabledDocument from '../auto-disabled-document'
-const { getLogs, enable } = vi.hoisted(() => ({ getLogs: vi.fn(), enable: vi.fn() }))
+const { getLogs, enable, successToast } = vi.hoisted(() => ({
+ getLogs: vi.fn(),
+ enable: vi.fn(),
+ successToast: vi.fn(),
+}))
+vi.mock('@/app/notifications', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('@/app/notifications')>()),
+ toast: { success: successToast },
+}))
vi.mock('@/service/console', async (importOriginal) => {
const actual = await importOriginal<typeof import('@/service/console')>()
const { withConsoleResponses } = await import('@/test/console/service-responses')
@@ -35,6 +43,7 @@ it('offers enable only after disabled documents load, then refreshes their statu
await waitFor(() =>
expect(screen.queryByRole('button', { name: 'dataset.enable' })).not.toBeInTheDocument(),
)
+ expect(successToast).not.toHaveBeenCalled()
})
it('does not offer enable when no documents were automatically disabled', async () => {
diff --git a/web/app/components/datasets/common/document-status-with-action/auto-disabled-document.tsx b/web/app/components/datasets/common/document-status-with-action/auto-disabled-document.tsx
index e5574167473..9a0d2f9b628 100644
--- a/web/app/components/datasets/common/document-status-with-action/auto-disabled-document.tsx
+++ b/web/app/components/datasets/common/document-status-with-action/auto-disabled-document.tsx
@@ -3,7 +3,6 @@ import type { FC } from 'react'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import * as React from 'react'
import { useTranslation } from 'react-i18next'
-import { toast } from '@/app/notifications'
import { consoleQuery } from '@/service/console'
import StatusWithAction from './status-with-action'
@@ -30,7 +29,6 @@ const AutoDisabledDocument: FC<Props> = ({ datasetId }) => {
query: { document_id: documentIds },
})
queryClient.invalidateQueries({ queryKey: autoDisableLogsQuery.queryKey })
- toast.success(t(($) => $['actionMsg.modifiedSuccessfully'], { ns: 'common' }))
}
return (