mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-12 08:46:02 +00:00
fix: pipeline duplication bug
This commit is contained in:
@@ -52,6 +52,7 @@ export default function PipelineFormComponent({
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
|
||||
const [showCopyConfirm, setShowCopyConfirm] = useState(false);
|
||||
const [isDefaultPipeline, setIsDefaultPipeline] = useState<boolean>(false);
|
||||
|
||||
const formSchema = isEditMode
|
||||
@@ -345,25 +346,17 @@ export default function PipelineFormComponent({
|
||||
};
|
||||
|
||||
const handleCopy = () => {
|
||||
setShowCopyConfirm(true);
|
||||
};
|
||||
|
||||
const confirmCopy = () => {
|
||||
if (pipelineId) {
|
||||
let newPipelineName = '';
|
||||
httpClient
|
||||
.getPipeline(pipelineId)
|
||||
.then((resp) => {
|
||||
const originalPipeline = resp.pipeline;
|
||||
newPipelineName = `${originalPipeline.name}${t(
|
||||
'pipelines.copySuffix',
|
||||
)}`;
|
||||
const newPipeline: Pipeline = {
|
||||
name: newPipelineName,
|
||||
description: originalPipeline.description,
|
||||
config: originalPipeline.config,
|
||||
};
|
||||
return httpClient.createPipeline(newPipeline);
|
||||
})
|
||||
.copyPipeline(pipelineId)
|
||||
.then(() => {
|
||||
onFinish();
|
||||
toast.success(`${t('common.copySuccess')}: ${newPipelineName}`);
|
||||
toast.success(t('common.copySuccess'));
|
||||
setShowCopyConfirm(false);
|
||||
onCancel();
|
||||
})
|
||||
.catch((err) => {
|
||||
@@ -547,6 +540,22 @@ export default function PipelineFormComponent({
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
{/* 复制确认对话框 */}
|
||||
<Dialog open={showCopyConfirm} onOpenChange={setShowCopyConfirm}>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>{t('pipelines.copyConfirmTitle')}</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="py-4">{t('pipelines.copyConfirmation')}</div>
|
||||
<DialogFooter>
|
||||
<Button variant="outline" onClick={() => setShowCopyConfirm(false)}>
|
||||
{t('common.cancel')}
|
||||
</Button>
|
||||
<Button onClick={confirmCopy}>{t('common.confirm')}</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -172,6 +172,10 @@ export class BackendClient extends BaseHttpClient {
|
||||
return this.delete(`/api/v1/pipelines/${uuid}`);
|
||||
}
|
||||
|
||||
public copyPipeline(uuid: string): Promise<{ uuid: string }> {
|
||||
return this.post(`/api/v1/pipelines/${uuid}/copy`);
|
||||
}
|
||||
|
||||
public getPipelineExtensions(uuid: string): Promise<{
|
||||
enable_all_plugins: boolean;
|
||||
enable_all_mcp_servers: boolean;
|
||||
|
||||
Reference in New Issue
Block a user