| const request = { | const request = { | ||||
| template_id: pipeline.id, | template_id: pipeline.id, | ||||
| name, | name, | ||||
| icon: { | |||||
| icon_info: { | |||||
| icon_type: appIcon.type, | icon_type: appIcon.type, | ||||
| icon: appIcon.type === 'image' ? appIcon.fileId : appIcon.icon, | icon: appIcon.type === 'image' ? appIcon.fileId : appIcon.icon, | ||||
| icon_background: appIcon.type === 'image' ? undefined : appIcon.background, | icon_background: appIcon.type === 'image' ? undefined : appIcon.background, |
| 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, | ||||
| usePipelineTemplateById, | usePipelineTemplateById, | ||||
| import type { CreateDatasetReq } from '@/models/datasets' | import type { CreateDatasetReq } from '@/models/datasets' | ||||
| import { useCreatePipelineDataset } from '@/service/knowledge/use-create-dataset' | import { useCreatePipelineDataset } from '@/service/knowledge/use-create-dataset' | ||||
| import CreateModal from './create-modal' | import CreateModal from './create-modal' | ||||
| import { useInvalid } from '@/service/use-base' | |||||
| type TemplateCardProps = { | type TemplateCardProps = { | ||||
| pipeline: PipelineTemplate | pipeline: PipelineTemplate | ||||
| }, []) | }, []) | ||||
| const { mutateAsync: deletePipeline } = useDeleteTemplate() | const { mutateAsync: deletePipeline } = useDeleteTemplate() | ||||
| const invalidCustomizedTemplateList = useInvalid([...PipelineTemplateListQueryKeyPrefix, 'customized']) | |||||
| const onConfirmDelete = useCallback(async () => { | const onConfirmDelete = useCallback(async () => { | ||||
| await deletePipeline(pipeline.id, { | await deletePipeline(pipeline.id, { | ||||
| onSettled: () => { | |||||
| onSuccess: () => { | |||||
| invalidCustomizedTemplateList() | |||||
| setShowConfirmDelete(false) | setShowConfirmDelete(false) | ||||
| }, | }, | ||||
| }) | }) | ||||
| }, [pipeline.id, deletePipeline]) | |||||
| }, [pipeline.id, deletePipeline, invalidCustomizedTemplateList]) | |||||
| return ( | return ( | ||||
| <div className='group relative flex h-[132px] cursor-pointer flex-col rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-on-panel-item-bg pb-3 shadow-xs shadow-shadow-shadow-3'> | <div className='group relative flex h-[132px] cursor-pointer flex-col rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-on-panel-item-bg pb-3 shadow-xs shadow-shadow-shadow-3'> |
| export type UpdateTemplateInfoRequest = { | export type UpdateTemplateInfoRequest = { | ||||
| template_id: string | template_id: string | ||||
| name: string | name: string | ||||
| icon: IconInfo | |||||
| icon_info: IconInfo | |||||
| description: string | description: string | ||||
| } | } | ||||
| mutationKey: [NAME_SPACE, 'template', 'update'], | mutationKey: [NAME_SPACE, 'template', 'update'], | ||||
| mutationFn: (request: UpdateTemplateInfoRequest) => { | mutationFn: (request: UpdateTemplateInfoRequest) => { | ||||
| const { template_id, ...rest } = request | const { template_id, ...rest } = request | ||||
| return patch<UpdateTemplateInfoResponse>(`/rag/customized/templates/${template_id}`, { | |||||
| return patch<UpdateTemplateInfoResponse>(`/rag/pipeline/customized/templates/${template_id}`, { | |||||
| body: rest, | body: rest, | ||||
| }) | }) | ||||
| }, | }, | ||||
| return useMutation({ | return useMutation({ | ||||
| mutationKey: [NAME_SPACE, 'template', 'delete'], | mutationKey: [NAME_SPACE, 'template', 'delete'], | ||||
| mutationFn: (templateId: string) => { | mutationFn: (templateId: string) => { | ||||
| return del<DeleteTemplateResponse>(`/rag/customized/templates/${templateId}`) | |||||
| return del<DeleteTemplateResponse>(`/rag/pipeline/customized/templates/${templateId}`) | |||||
| }, | }, | ||||
| ...mutationOptions, | ...mutationOptions, | ||||
| }) | }) | ||||
| return useMutation({ | return useMutation({ | ||||
| mutationKey: [NAME_SPACE, 'dsl-export'], | mutationKey: [NAME_SPACE, 'dsl-export'], | ||||
| mutationFn: (templateId: string) => { | mutationFn: (templateId: string) => { | ||||
| return get<ExportTemplateDSLResponse>(`/rag/customized/templates/${templateId}`) | |||||
| return post<ExportTemplateDSLResponse>(`/rag/pipeline/customized/templates/${templateId}`) | |||||
| }, | }, | ||||
| ...mutationOptions, | ...mutationOptions, | ||||
| }) | }) |