From 0564651f6f66b1d3ac4b053fd5b64b99ee68cfcb Mon Sep 17 00:00:00 2001 From: zxhlyh Date: Wed, 11 Jun 2025 10:40:32 +0800 Subject: [PATCH] publish as customized pipeline --- .../list/customized-list.tsx | 2 +- .../publish-as-knowledge-pipeline-modal.tsx | 150 ++++++++++++++++++ .../rag-pipeline-header/publisher/popup.tsx | 53 ++++++- .../rag-pipeline/hooks/use-pipeline-init.ts | 5 +- .../components/rag-pipeline/store/index.ts | 2 + web/i18n/en-US/pipeline.ts | 6 + web/i18n/zh-Hans/pipeline.ts | 6 + web/models/pipeline.ts | 2 +- web/service/use-pipeline.ts | 22 ++- 9 files changed, 238 insertions(+), 10 deletions(-) create mode 100644 web/app/components/rag-pipeline/components/publish-as-knowledge-pipeline-modal.tsx diff --git a/web/app/components/datasets/create-from-pipeline/list/customized-list.tsx b/web/app/components/datasets/create-from-pipeline/list/customized-list.tsx index 6959b2e2cd..9ffdf45f1c 100644 --- a/web/app/components/datasets/create-from-pipeline/list/customized-list.tsx +++ b/web/app/components/datasets/create-from-pipeline/list/customized-list.tsx @@ -3,7 +3,7 @@ import { usePipelineTemplateList } from '@/service/use-pipeline' const CustomizedList = () => { const { data: pipelineList, isLoading } = usePipelineTemplateList({ type: 'customized' }) - const list = pipelineList?.pipelines + const list = pipelineList?.pipeline_templates if (isLoading || !list) return null diff --git a/web/app/components/rag-pipeline/components/publish-as-knowledge-pipeline-modal.tsx b/web/app/components/rag-pipeline/components/publish-as-knowledge-pipeline-modal.tsx new file mode 100644 index 0000000000..7471ead7dc --- /dev/null +++ b/web/app/components/rag-pipeline/components/publish-as-knowledge-pipeline-modal.tsx @@ -0,0 +1,150 @@ +'use client' +import { useCallback, useState } from 'react' +import { useTranslation } from 'react-i18next' +import { RiCloseLine } from '@remixicon/react' +import AppIconPicker from '@/app/components/base/app-icon-picker' +import type { AppIconSelection } from '@/app/components/base/app-icon-picker' +import Modal from '@/app/components/base/modal' +import Button from '@/app/components/base/button' +import Input from '@/app/components/base/input' +import Textarea from '@/app/components/base/textarea' +import AppIcon from '@/app/components/base/app-icon' +import { noop } from 'lodash-es' +import { useStore } from '@/app/components/workflow/store' +import type { IconInfo } from '@/models/datasets' + +type PublishAsKnowledgePipelineModalProps = { + confirmDisabled?: boolean + onCancel: () => void + onConfirm: ( + name: string, + icon: IconInfo, + description?: string, + ) => Promise +} +const PublishAsKnowledgePipelineModal = ({ + confirmDisabled, + onCancel, + onConfirm, +}: PublishAsKnowledgePipelineModalProps) => { + const { t } = useTranslation() + const knowledgeName = useStore(s => s.knowledgeName) + const knowledgeIcon = useStore(s => s.knowledgeIcon) + const [pipelineName, setPipelineName] = useState(knowledgeName!) + const [pipelineIcon, setPipelineIcon] = useState(knowledgeIcon!) + const [description, setDescription] = useState('') + const [showAppIconPicker, setShowAppIconPicker] = useState(false) + + const handleSelectIcon = useCallback((item: AppIconSelection) => { + if (item.type === 'image') { + setPipelineIcon({ + icon_type: 'image', + icon_url: item.url, + icon_background: '', + icon: '', + }) + } + + if (item.type === 'emoji') { + setPipelineIcon({ + icon_type: 'emoji', + icon: item.icon, + icon_background: item.background, + icon_url: '', + }) + } + setShowAppIconPicker(false) + }, []) + const handleCloseIconPicker = useCallback(() => { + setPipelineIcon({ + icon_type: pipelineIcon.icon_type, + icon: pipelineIcon.icon, + icon_background: pipelineIcon.icon_background, + icon_url: pipelineIcon.icon_url, + }) + setShowAppIconPicker(false) + }, [pipelineIcon]) + + const handleConfirm = () => { + if (confirmDisabled) + return + + onConfirm( + pipelineName?.trim() || '', + pipelineIcon, + description?.trim(), + ) + } + + return ( + <> + +
+ {t('pipeline.common.publishAs')} +
+ +
+
+
+
+
+
+ {t('pipeline.common.publishAsPipeline.name')} +
+ setPipelineName(e.target.value)} + placeholder={t('pipeline.common.publishAsPipeline.namePlaceholder') || ''} + /> +
+ { setShowAppIconPicker(true) }} + className='mt-2 shrink-0 cursor-pointer' + iconType={pipelineIcon?.icon_type} + icon={pipelineIcon?.icon} + background={pipelineIcon?.icon_background} + imageUrl={pipelineIcon?.icon_url} + /> +
+
+
+ {t('pipeline.common.publishAsPipeline.description')} +
+