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.

refactor: replace useInvalid with useInvalidCustomizedTemplateList (#25924)

Wu Tianweicd90b2ca9e49
diff --git a/web/app/components/datasets/create-from-pipeline/list/template-card/edit-pipeline-info.tsx b/web/app/components/datasets/create-from-pipeline/list/template-card/edit-pipeline-info.tsx
index 91ff41cb1ae..411611bcfca 100644
--- a/web/app/components/datasets/create-from-pipeline/list/template-card/edit-pipeline-info.tsx
+++ b/web/app/components/datasets/create-from-pipeline/list/template-card/edit-pipeline-info.tsx
@@ -9,8 +9,7 @@ import Button from '@/app/components/base/button'
import { useTranslation } from 'react-i18next'
import Toast from '@/app/components/base/toast'
import type { PipelineTemplate } from '@/models/pipeline'
-import { PipelineTemplateListQueryKeyPrefix, useUpdateTemplateInfo } from '@/service/use-pipeline'
-import { useInvalid } from '@/service/use-base'
+import { useInvalidCustomizedTemplateList, useUpdateTemplateInfo } from '@/service/use-pipeline'
type EditPipelineInfoProps = {
onClose: () => void
@@ -63,7 +62,7 @@ const EditPipelineInfo = ({
}, [])
const { mutateAsync: updatePipeline } = useUpdateTemplateInfo()
- const invalidCustomizedTemplateList = useInvalid([...PipelineTemplateListQueryKeyPrefix, 'customized'])
+ const invalidCustomizedTemplateList = useInvalidCustomizedTemplateList()
const handleSave = useCallback(async () => {
if (!name) {
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 8320425bf3c..cde3bc0e004 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
@@ -5,9 +5,9 @@ import EditPipelineInfo from './edit-pipeline-info'
import type { PipelineTemplate } from '@/models/pipeline'
import Confirm from '@/app/components/base/confirm'
import {
- PipelineTemplateListQueryKeyPrefix,
useDeleteTemplate,
useExportTemplateDSL,
+ useInvalidCustomizedTemplateList,
usePipelineTemplateById,
} from '@/service/use-pipeline'
import { downloadFile } from '@/utils/format'
@@ -18,7 +18,6 @@ import Details from './details'
import Content from './content'
import Actions from './actions'
import { useCreatePipelineDatasetFromCustomized } from '@/service/knowledge/use-create-dataset'
-import { useInvalid } from '@/service/use-base'
import { useInvalidDatasetList } from '@/service/knowledge/use-dataset'
type TemplateCardProps = {
@@ -128,7 +127,7 @@ const TemplateCard = ({
}, [])
const { mutateAsync: deletePipeline } = useDeleteTemplate()
- const invalidCustomizedTemplateList = useInvalid([...PipelineTemplateListQueryKeyPrefix, 'customized'])
+ const invalidCustomizedTemplateList = useInvalidCustomizedTemplateList()
const onConfirmDelete = useCallback(async () => {
await deletePipeline(pipeline.id, {
diff --git a/web/app/components/rag-pipeline/components/rag-pipeline-header/publisher/popup.tsx b/web/app/components/rag-pipeline/components/rag-pipeline-header/publisher/popup.tsx
index c8ef6c3601a..c50f027e99e 100644
--- a/web/app/components/rag-pipeline/components/rag-pipeline-header/publisher/popup.tsx
+++ b/web/app/components/rag-pipeline/components/rag-pipeline-header/publisher/popup.tsx
@@ -33,6 +33,7 @@ import { useDatasetDetailContextWithSelector } from '@/context/dataset-detail'
import { useInvalid } from '@/service/use-base'
import {
publishedPipelineInfoQueryKeyPrefix,
+ useInvalidCustomizedTemplateList,
usePublishAsCustomizedPipeline,
} from '@/service/use-pipeline'
import Confirm from '@/app/components/base/confirm'
@@ -158,6 +159,8 @@ const Popup = () => {
push(`/datasets/${datasetId}/documents/create-from-pipeline`)
}, [datasetId, push])
+ const invalidCustomizedTemplateList = useInvalidCustomizedTemplateList()
+
const handlePublishAsKnowledgePipeline = useCallback(async (
name: string,
icon: IconInfo,
@@ -189,6 +192,7 @@ const Popup = () => {
</div>
),
})
+ invalidCustomizedTemplateList()
}
catch {
notify({ type: 'error', message: t('datasetPipeline.publishTemplate.error.message') })
diff --git a/web/service/use-pipeline.ts b/web/service/use-pipeline.ts
index 9938bee9d06..870fb5bc84b 100644
--- a/web/service/use-pipeline.ts
+++ b/web/service/use-pipeline.ts
@@ -48,6 +48,10 @@ export const usePipelineTemplateList = (params: PipelineTemplateListParams) => {
})
}
+export const useInvalidCustomizedTemplateList = () => {
+ return useInvalid([...PipelineTemplateListQueryKeyPrefix, 'customized'])
+}
+
export const usePipelineTemplateById = (params: PipelineTemplateByIdRequest, enabled: boolean) => {
const { template_id, type } = params
return useQuery<PipelineTemplateByIdResponse>({