mirror of https://github.com/langgenius/dify.git
refactor: Update notification messages in CreateFromDSLModal and CreateFromScratchModal for dataset creation
This commit is contained in:
parent
a52bf6211a
commit
ddde576b4a
|
|
@ -100,7 +100,7 @@ const CreateFromDSLModal = ({
|
|||
}
|
||||
|
||||
if (!response) {
|
||||
notify({ type: 'error', message: t('app.newApp.appCreateFailed') })
|
||||
notify({ type: 'error', message: t('datasetPipeline.creation.errorTip') })
|
||||
isCreatingRef.current = false
|
||||
return
|
||||
}
|
||||
|
|
@ -113,7 +113,7 @@ const CreateFromDSLModal = ({
|
|||
|
||||
notify({
|
||||
type: status === DSLImportStatus.COMPLETED ? 'success' : 'warning',
|
||||
message: t(status === DSLImportStatus.COMPLETED ? 'app.newApp.appCreated' : 'app.newApp.caution'),
|
||||
message: t(status === DSLImportStatus.COMPLETED ? 'datasetPipeline.creation.successTip' : 'datasetPipeline.creation.caution'),
|
||||
children: status === DSLImportStatus.COMPLETED_WITH_WARNINGS && t('app.newApp.appCreateDSLWarning'),
|
||||
})
|
||||
if (pipeline_id)
|
||||
|
|
@ -135,7 +135,7 @@ const CreateFromDSLModal = ({
|
|||
isCreatingRef.current = false
|
||||
}
|
||||
else {
|
||||
notify({ type: 'error', message: t('app.newApp.appCreateFailed') })
|
||||
notify({ type: 'error', message: t('datasetPipeline.creation.errorTip') })
|
||||
isCreatingRef.current = false
|
||||
}
|
||||
}
|
||||
|
|
@ -155,7 +155,7 @@ const CreateFromDSLModal = ({
|
|||
const response = await importDSLConfirm(importId)
|
||||
|
||||
if (!response) {
|
||||
notify({ type: 'error', message: t('app.newApp.appCreateFailed') })
|
||||
notify({ type: 'error', message: t('datasetPipeline.creation.errorTip') })
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -169,14 +169,14 @@ const CreateFromDSLModal = ({
|
|||
|
||||
notify({
|
||||
type: 'success',
|
||||
message: t('app.newApp.appCreated'),
|
||||
message: t('datasetPipeline.creation.successTip'),
|
||||
})
|
||||
if (pipeline_id)
|
||||
await handleCheckPluginDependencies(pipeline_id, true)
|
||||
push(`datasets/${dataset_id}/pipeline`)
|
||||
}
|
||||
else if (status === DSLImportStatus.FAILED) {
|
||||
notify({ type: 'error', message: t('app.newApp.appCreateFailed') })
|
||||
notify({ type: 'error', message: t('datasetPipeline.creation.errorTip') })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@ import CreateForm from '../create-form'
|
|||
import type { CreateFormData } from '@/models/pipeline'
|
||||
import Modal from '@/app/components/base/modal'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import Toast from '@/app/components/base/toast'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useResetDatasetList } from '@/service/knowledge/use-dataset'
|
||||
|
||||
type CreateFromScratchModalProps = {
|
||||
show: boolean
|
||||
|
|
@ -18,6 +21,7 @@ const CreateFromScratchModal = ({
|
|||
show,
|
||||
onClose,
|
||||
}: CreateFromScratchModalProps) => {
|
||||
const { t } = useTranslation()
|
||||
const { push } = useRouter()
|
||||
const [memberList, setMemberList] = useState<Member[]>([])
|
||||
const { data: members } = useMembers()
|
||||
|
|
@ -28,6 +32,7 @@ const CreateFromScratchModal = ({
|
|||
}, [members])
|
||||
|
||||
const { mutateAsync: createEmptyDataset } = useCreatePipelineDataset()
|
||||
const resetDatasetList = useResetDatasetList()
|
||||
|
||||
const handleCreate = useCallback(async (payload: CreateFormData) => {
|
||||
const { name, appIcon, description, permission, selectedMemberIDs } = payload
|
||||
|
|
@ -54,15 +59,28 @@ const CreateFromScratchModal = ({
|
|||
request.partial_member_list = selectedMemberList
|
||||
}
|
||||
await createEmptyDataset(request, {
|
||||
onSettled: (data) => {
|
||||
onSuccess: (data) => {
|
||||
if (data) {
|
||||
const { id } = data
|
||||
Toast.notify({
|
||||
type: 'success',
|
||||
message: t('datasetPipeline.creation.successTip'),
|
||||
})
|
||||
resetDatasetList()
|
||||
push(`/datasets/${id}/pipeline`)
|
||||
}
|
||||
},
|
||||
onError: () => {
|
||||
Toast.notify({
|
||||
type: 'error',
|
||||
message: t('datasetPipeline.creation.errorTip'),
|
||||
})
|
||||
},
|
||||
onSettled: () => {
|
||||
onClose?.()
|
||||
},
|
||||
})
|
||||
}, [createEmptyDataset, memberList, onClose, push])
|
||||
}, [createEmptyDataset, memberList, onClose, push, resetDatasetList, t])
|
||||
|
||||
return (
|
||||
<Modal
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ const TemplateCard = ({
|
|||
onSuccess: async (newDataset) => {
|
||||
Toast.notify({
|
||||
type: 'success',
|
||||
message: t('app.newApp.appCreated'),
|
||||
message: t('datasetPipeline.creation.successTip'),
|
||||
})
|
||||
resetDatasetList()
|
||||
if (newDataset.pipeline_id)
|
||||
|
|
|
|||
Loading…
Reference in New Issue