mirror of
https://github.com/langgenius/dify.git
synced 2026-05-05 18:08:07 +08:00
refactor(web): migrate tools/MCP/external-knowledge toast usage to UI toast and add i18n (#33797)
This commit is contained in:
@ -164,7 +164,7 @@ describe('ExternalKnowledgeBaseConnector', () => {
|
||||
// Verify success notification
|
||||
expect(mockNotify).toHaveBeenCalledWith({
|
||||
type: 'success',
|
||||
title: 'External Knowledge Base Connected Successfully',
|
||||
title: 'dataset.externalKnowledgeForm.connectedSuccess',
|
||||
})
|
||||
|
||||
// Verify navigation back
|
||||
@ -206,7 +206,7 @@ describe('ExternalKnowledgeBaseConnector', () => {
|
||||
await waitFor(() => {
|
||||
expect(mockNotify).toHaveBeenCalledWith({
|
||||
type: 'error',
|
||||
title: 'Failed to connect External Knowledge Base',
|
||||
title: 'dataset.externalKnowledgeForm.connectedFailed',
|
||||
})
|
||||
})
|
||||
|
||||
@ -228,7 +228,7 @@ describe('ExternalKnowledgeBaseConnector', () => {
|
||||
await waitFor(() => {
|
||||
expect(mockNotify).toHaveBeenCalledWith({
|
||||
type: 'error',
|
||||
title: 'Failed to connect External Knowledge Base',
|
||||
title: 'dataset.externalKnowledgeForm.connectedFailed',
|
||||
})
|
||||
})
|
||||
|
||||
@ -274,7 +274,7 @@ describe('ExternalKnowledgeBaseConnector', () => {
|
||||
await waitFor(() => {
|
||||
expect(mockNotify).toHaveBeenCalledWith({
|
||||
type: 'success',
|
||||
title: 'External Knowledge Base Connected Successfully',
|
||||
title: 'dataset.externalKnowledgeForm.connectedSuccess',
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
import type { CreateKnowledgeBaseReq } from '@/app/components/datasets/external-knowledge-base/create/declarations'
|
||||
import * as React from 'react'
|
||||
import { useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { trackEvent } from '@/app/components/base/amplitude'
|
||||
import { toast } from '@/app/components/base/ui/toast'
|
||||
import ExternalKnowledgeBaseCreate from '@/app/components/datasets/external-knowledge-base/create'
|
||||
@ -12,13 +13,14 @@ import { createExternalKnowledgeBase } from '@/service/datasets'
|
||||
const ExternalKnowledgeBaseConnector = () => {
|
||||
const [loading, setLoading] = useState(false)
|
||||
const router = useRouter()
|
||||
const { t } = useTranslation()
|
||||
|
||||
const handleConnect = async (formValue: CreateKnowledgeBaseReq) => {
|
||||
try {
|
||||
setLoading(true)
|
||||
const result = await createExternalKnowledgeBase({ body: formValue })
|
||||
if (result && result.id) {
|
||||
toast.add({ type: 'success', title: 'External Knowledge Base Connected Successfully' })
|
||||
toast.add({ type: 'success', title: t('externalKnowledgeForm.connectedSuccess', { ns: 'dataset' }) })
|
||||
trackEvent('create_external_knowledge_base', {
|
||||
provider: formValue.provider,
|
||||
name: formValue.name,
|
||||
@ -29,7 +31,7 @@ const ExternalKnowledgeBaseConnector = () => {
|
||||
}
|
||||
catch (error) {
|
||||
console.error('Error creating external knowledge base:', error)
|
||||
toast.add({ type: 'error', title: 'Failed to connect External Knowledge Base' })
|
||||
toast.add({ type: 'error', title: t('externalKnowledgeForm.connectedFailed', { ns: 'dataset' }) })
|
||||
}
|
||||
setLoading(false)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user