From 98eafd704b9d0c2c7e19bcb5ac6cb6b60c71e348 Mon Sep 17 00:00:00 2001 From: Junyan Qin Date: Sat, 10 May 2025 12:28:44 +0800 Subject: [PATCH] feat: pipeline deletion --- .../pipeline-form/PipelineFormComponent.tsx | 87 ++++++++++++++++++- web/src/app/home/pipelines/page.tsx | 4 + 2 files changed, 88 insertions(+), 3 deletions(-) diff --git a/web/src/app/home/pipelines/components/pipeline-form/PipelineFormComponent.tsx b/web/src/app/home/pipelines/components/pipeline-form/PipelineFormComponent.tsx index 99169da3..a50c012a 100644 --- a/web/src/app/home/pipelines/components/pipeline-form/PipelineFormComponent.tsx +++ b/web/src/app/home/pipelines/components/pipeline-form/PipelineFormComponent.tsx @@ -22,15 +22,25 @@ import { FormMessage, } from '@/components/ui/form'; import { toast } from 'sonner'; +import { + Dialog, + DialogContent, + DialogHeader, + DialogTitle, + DialogDescription, + DialogFooter, +} from '@/components/ui/dialog'; export default function PipelineFormComponent({ initValues, + isDefaultPipeline, onFinish, onNewPipelineCreated, isEditMode, pipelineId, }: { pipelineId?: string; + isDefaultPipeline: boolean; isEditMode: boolean; disableForm: boolean; // 这里的写法很不安全不规范,未来流水线需要重新整理 @@ -84,6 +94,7 @@ export default function PipelineFormComponent({ useState(); const [outputConfigTabSchema, setOutputConfigTabSchema] = useState(); + const [showDeleteConfirmModal, setShowDeleteConfirmModal] = useState(false); const form = useForm({ resolver: zodResolver(formSchema), @@ -258,8 +269,51 @@ export default function PipelineFormComponent({ ); } + function deletePipeline() { + httpClient + .deletePipeline(pipelineId || '') + .then(() => { + onFinish(); + toast.success('删除成功'); + }) + .catch((err) => { + toast.error('删除失败:' + err.message); + }); + } + return (
+ + + + 删除确认 + + + 你确定要删除这个流水线吗?已绑定此流水线的机器人将无法使用。 + + + + + + + +
@@ -355,9 +409,36 @@ export default function PipelineFormComponent({
-
- - + )} + + +
diff --git a/web/src/app/home/pipelines/page.tsx b/web/src/app/home/pipelines/page.tsx index 99964b1f..03031bdd 100644 --- a/web/src/app/home/pipelines/page.tsx +++ b/web/src/app/home/pipelines/page.tsx @@ -28,6 +28,8 @@ export default function PluginConfigPage() { output: {}, }); const [disableForm, setDisableForm] = useState(false); + const [selectedPipelineIsDefault, setSelectedPipelineIsDefault] = + useState(false); useEffect(() => { getPipelines(); @@ -81,6 +83,7 @@ export default function PluginConfigPage() { safety: value.pipeline.config.safety, trigger: value.pipeline.config.trigger, }); + setSelectedPipelineIsDefault(value.pipeline.is_default ?? false); setDisableForm(false); }); } @@ -111,6 +114,7 @@ export default function PluginConfigPage() { pipelineId={selectedPipelineId} disableForm={disableForm} initValues={selectedPipelineFormValue} + isDefaultPipeline={selectedPipelineIsDefault} />