diff --git a/web/app/components/datasets/create-from-pipeline/list/template-card/index.tsx b/web/app/components/datasets/create-from-pipeline/list/template-card/index.tsx index 74bbdded9d..a8d4081993 100644 --- a/web/app/components/datasets/create-from-pipeline/list/template-card/index.tsx +++ b/web/app/components/datasets/create-from-pipeline/list/template-card/index.tsx @@ -52,34 +52,35 @@ const TemplateCard = ({ }, []) const handleUseTemplate = useCallback(async (payload: Omit) => { - try { - const { data: pipelineTemplateInfo } = await getPipelineTemplateInfo() - if (!pipelineTemplateInfo) { - Toast.notify({ - type: 'error', - message: t('datasetPipeline.creation.errorTip'), - }) - return - } - const request = { - ...payload, - yaml_content: pipelineTemplateInfo.export_data, - } - const newDataset = await createEmptyDataset(request) - Toast.notify({ - type: 'success', - message: t('app.newApp.appCreated'), - }) - if (newDataset.pipeline_id) - await handleCheckPluginDependencies(newDataset.pipeline_id, true) - push(`dataset/${newDataset.id}/pipeline`) - } - catch { + const { data: pipelineTemplateInfo } = await getPipelineTemplateInfo() + if (!pipelineTemplateInfo) { Toast.notify({ type: 'error', message: t('datasetPipeline.creation.errorTip'), }) + return } + const request = { + ...payload, + yaml_content: pipelineTemplateInfo.export_data, + } + await createEmptyDataset(request, { + onSuccess: async (newDataset) => { + Toast.notify({ + type: 'success', + message: t('app.newApp.appCreated'), + }) + if (newDataset.pipeline_id) + await handleCheckPluginDependencies(newDataset.pipeline_id, true) + push(`/datasets/${newDataset.id}/pipeline`) + }, + onError: () => { + Toast.notify({ + type: 'error', + message: t('datasetPipeline.creation.errorTip'), + }) + }, + }) }, [getPipelineTemplateInfo, createEmptyDataset, t, handleCheckPluginDependencies, push]) const handleShowTemplateDetails = useCallback(() => { diff --git a/web/service/use-pipeline.ts b/web/service/use-pipeline.ts index a141a04ca9..e45d705e4c 100644 --- a/web/service/use-pipeline.ts +++ b/web/service/use-pipeline.ts @@ -127,7 +127,7 @@ export const useCheckPipelineDependencies = ( return useMutation({ mutationKey: [NAME_SPACE, 'check-dependencies'], mutationFn: (pipelineId: string) => { - return post(`/rag/pipelines/imports/${pipelineId}/check-dependencies`) + return get(`/rag/pipelines/imports/${pipelineId}/check-dependencies`) }, ...mutationOptions, })