| import { useTranslation } from 'react-i18next' | import { useTranslation } from 'react-i18next' | ||||
| import Toast from '@/app/components/base/toast' | import Toast from '@/app/components/base/toast' | ||||
| import type { PipelineTemplate } from '@/models/pipeline' | 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 = { | type EditPipelineInfoProps = { | ||||
| onClose: () => void | onClose: () => void | ||||
| }, []) | }, []) | ||||
| const { mutateAsync: updatePipeline } = useUpdateTemplateInfo() | const { mutateAsync: updatePipeline } = useUpdateTemplateInfo() | ||||
| const invalidCustomizedTemplateList = useInvalid([...PipelineTemplateListQueryKeyPrefix, 'customized']) | |||||
| const invalidCustomizedTemplateList = useInvalidCustomizedTemplateList() | |||||
| const handleSave = useCallback(async () => { | const handleSave = useCallback(async () => { | ||||
| if (!name) { | if (!name) { |
| import type { PipelineTemplate } from '@/models/pipeline' | import type { PipelineTemplate } from '@/models/pipeline' | ||||
| import Confirm from '@/app/components/base/confirm' | import Confirm from '@/app/components/base/confirm' | ||||
| import { | import { | ||||
| PipelineTemplateListQueryKeyPrefix, | |||||
| useDeleteTemplate, | useDeleteTemplate, | ||||
| useExportTemplateDSL, | useExportTemplateDSL, | ||||
| useInvalidCustomizedTemplateList, | |||||
| usePipelineTemplateById, | usePipelineTemplateById, | ||||
| } from '@/service/use-pipeline' | } from '@/service/use-pipeline' | ||||
| import { downloadFile } from '@/utils/format' | import { downloadFile } from '@/utils/format' | ||||
| import Content from './content' | import Content from './content' | ||||
| import Actions from './actions' | import Actions from './actions' | ||||
| import { useCreatePipelineDatasetFromCustomized } from '@/service/knowledge/use-create-dataset' | import { useCreatePipelineDatasetFromCustomized } from '@/service/knowledge/use-create-dataset' | ||||
| import { useInvalid } from '@/service/use-base' | |||||
| import { useInvalidDatasetList } from '@/service/knowledge/use-dataset' | import { useInvalidDatasetList } from '@/service/knowledge/use-dataset' | ||||
| type TemplateCardProps = { | type TemplateCardProps = { | ||||
| }, []) | }, []) | ||||
| const { mutateAsync: deletePipeline } = useDeleteTemplate() | const { mutateAsync: deletePipeline } = useDeleteTemplate() | ||||
| const invalidCustomizedTemplateList = useInvalid([...PipelineTemplateListQueryKeyPrefix, 'customized']) | |||||
| const invalidCustomizedTemplateList = useInvalidCustomizedTemplateList() | |||||
| const onConfirmDelete = useCallback(async () => { | const onConfirmDelete = useCallback(async () => { | ||||
| await deletePipeline(pipeline.id, { | await deletePipeline(pipeline.id, { |
| import { useInvalid } from '@/service/use-base' | import { useInvalid } from '@/service/use-base' | ||||
| import { | import { | ||||
| publishedPipelineInfoQueryKeyPrefix, | publishedPipelineInfoQueryKeyPrefix, | ||||
| useInvalidCustomizedTemplateList, | |||||
| usePublishAsCustomizedPipeline, | usePublishAsCustomizedPipeline, | ||||
| } from '@/service/use-pipeline' | } from '@/service/use-pipeline' | ||||
| import Confirm from '@/app/components/base/confirm' | import Confirm from '@/app/components/base/confirm' | ||||
| push(`/datasets/${datasetId}/documents/create-from-pipeline`) | push(`/datasets/${datasetId}/documents/create-from-pipeline`) | ||||
| }, [datasetId, push]) | }, [datasetId, push]) | ||||
| const invalidCustomizedTemplateList = useInvalidCustomizedTemplateList() | |||||
| const handlePublishAsKnowledgePipeline = useCallback(async ( | const handlePublishAsKnowledgePipeline = useCallback(async ( | ||||
| name: string, | name: string, | ||||
| icon: IconInfo, | icon: IconInfo, | ||||
| </div> | </div> | ||||
| ), | ), | ||||
| }) | }) | ||||
| invalidCustomizedTemplateList() | |||||
| } | } | ||||
| catch { | catch { | ||||
| notify({ type: 'error', message: t('datasetPipeline.publishTemplate.error.message') }) | notify({ type: 'error', message: t('datasetPipeline.publishTemplate.error.message') }) |
| }) | }) | ||||
| } | } | ||||
| export const useInvalidCustomizedTemplateList = () => { | |||||
| return useInvalid([...PipelineTemplateListQueryKeyPrefix, 'customized']) | |||||
| } | |||||
| export const usePipelineTemplateById = (params: PipelineTemplateByIdRequest, enabled: boolean) => { | export const usePipelineTemplateById = (params: PipelineTemplateByIdRequest, enabled: boolean) => { | ||||
| const { template_id, type } = params | const { template_id, type } = params | ||||
| return useQuery<PipelineTemplateByIdResponse>({ | return useQuery<PipelineTemplateByIdResponse>({ |