refactor: Update notification messages in CreateFromDSLModal and CreateFromScratchModal for dataset creation

feat/rag-pipeline
twwu 11 months ago
parent a52bf6211a
commit ddde576b4a

@ -100,7 +100,7 @@ const CreateFromDSLModal = ({
} }
if (!response) { if (!response) {
notify({ type: 'error', message: t('app.newApp.appCreateFailed') }) notify({ type: 'error', message: t('datasetPipeline.creation.errorTip') })
isCreatingRef.current = false isCreatingRef.current = false
return return
} }
@ -113,7 +113,7 @@ const CreateFromDSLModal = ({
notify({ notify({
type: status === DSLImportStatus.COMPLETED ? 'success' : 'warning', 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'), children: status === DSLImportStatus.COMPLETED_WITH_WARNINGS && t('app.newApp.appCreateDSLWarning'),
}) })
if (pipeline_id) if (pipeline_id)
@ -135,7 +135,7 @@ const CreateFromDSLModal = ({
isCreatingRef.current = false isCreatingRef.current = false
} }
else { else {
notify({ type: 'error', message: t('app.newApp.appCreateFailed') }) notify({ type: 'error', message: t('datasetPipeline.creation.errorTip') })
isCreatingRef.current = false isCreatingRef.current = false
} }
} }
@ -155,7 +155,7 @@ const CreateFromDSLModal = ({
const response = await importDSLConfirm(importId) const response = await importDSLConfirm(importId)
if (!response) { if (!response) {
notify({ type: 'error', message: t('app.newApp.appCreateFailed') }) notify({ type: 'error', message: t('datasetPipeline.creation.errorTip') })
return return
} }
@ -169,14 +169,14 @@ const CreateFromDSLModal = ({
notify({ notify({
type: 'success', type: 'success',
message: t('app.newApp.appCreated'), message: t('datasetPipeline.creation.successTip'),
}) })
if (pipeline_id) if (pipeline_id)
await handleCheckPluginDependencies(pipeline_id, true) await handleCheckPluginDependencies(pipeline_id, true)
push(`datasets/${dataset_id}/pipeline`) push(`datasets/${dataset_id}/pipeline`)
} }
else if (status === DSLImportStatus.FAILED) { 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 type { CreateFormData } from '@/models/pipeline'
import Modal from '@/app/components/base/modal' import Modal from '@/app/components/base/modal'
import { useRouter } from 'next/navigation' 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 = { type CreateFromScratchModalProps = {
show: boolean show: boolean
@ -18,6 +21,7 @@ const CreateFromScratchModal = ({
show, show,
onClose, onClose,
}: CreateFromScratchModalProps) => { }: CreateFromScratchModalProps) => {
const { t } = useTranslation()
const { push } = useRouter() const { push } = useRouter()
const [memberList, setMemberList] = useState<Member[]>([]) const [memberList, setMemberList] = useState<Member[]>([])
const { data: members } = useMembers() const { data: members } = useMembers()
@ -28,6 +32,7 @@ const CreateFromScratchModal = ({
}, [members]) }, [members])
const { mutateAsync: createEmptyDataset } = useCreatePipelineDataset() const { mutateAsync: createEmptyDataset } = useCreatePipelineDataset()
const resetDatasetList = useResetDatasetList()
const handleCreate = useCallback(async (payload: CreateFormData) => { const handleCreate = useCallback(async (payload: CreateFormData) => {
const { name, appIcon, description, permission, selectedMemberIDs } = payload const { name, appIcon, description, permission, selectedMemberIDs } = payload
@ -54,15 +59,28 @@ const CreateFromScratchModal = ({
request.partial_member_list = selectedMemberList request.partial_member_list = selectedMemberList
} }
await createEmptyDataset(request, { await createEmptyDataset(request, {
onSettled: (data) => { onSuccess: (data) => {
if (data) { if (data) {
const { id } = data const { id } = data
Toast.notify({
type: 'success',
message: t('datasetPipeline.creation.successTip'),
})
resetDatasetList()
push(`/datasets/${id}/pipeline`) push(`/datasets/${id}/pipeline`)
} }
},
onError: () => {
Toast.notify({
type: 'error',
message: t('datasetPipeline.creation.errorTip'),
})
},
onSettled: () => {
onClose?.() onClose?.()
}, },
}) })
}, [createEmptyDataset, memberList, onClose, push]) }, [createEmptyDataset, memberList, onClose, push, resetDatasetList, t])
return ( return (
<Modal <Modal

@ -70,7 +70,7 @@ const TemplateCard = ({
onSuccess: async (newDataset) => { onSuccess: async (newDataset) => {
Toast.notify({ Toast.notify({
type: 'success', type: 'success',
message: t('app.newApp.appCreated'), message: t('datasetPipeline.creation.successTip'),
}) })
resetDatasetList() resetDatasetList()
if (newDataset.pipeline_id) if (newDataset.pipeline_id)

Loading…
Cancel
Save