mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-02 03:55:55 +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;
|
||||
|
||||
@@ -493,6 +493,9 @@ const enUS = {
|
||||
defaultPipelineCannotDelete: 'Default pipeline cannot be deleted',
|
||||
deleteSuccess: 'Deleted successfully',
|
||||
deleteError: 'Delete failed: ',
|
||||
copyConfirmTitle: 'Confirm Copy',
|
||||
copyConfirmation:
|
||||
'Are you sure you want to copy this pipeline? This will create a new pipeline with all configurations.',
|
||||
extensions: {
|
||||
title: 'Extensions',
|
||||
loadError: 'Failed to load plugins',
|
||||
|
||||
@@ -496,6 +496,9 @@ const jaJP = {
|
||||
defaultPipelineCannotDelete: 'デフォルトパイプラインは削除できません',
|
||||
deleteSuccess: '削除に成功しました',
|
||||
deleteError: '削除に失敗しました:',
|
||||
copyConfirmTitle: 'コピーの確認',
|
||||
copyConfirmation:
|
||||
'このパイプラインをコピーしますか?すべての設定を含む新しいパイプラインが作成されます。',
|
||||
extensions: {
|
||||
title: 'プラグイン統合',
|
||||
loadError: 'プラグインリストの読み込みに失敗しました',
|
||||
|
||||
@@ -475,6 +475,9 @@ const zhHans = {
|
||||
defaultPipelineCannotDelete: '默认流水线不可删除',
|
||||
deleteSuccess: '删除成功',
|
||||
deleteError: '删除失败:',
|
||||
copyConfirmTitle: '确认复制',
|
||||
copyConfirmation:
|
||||
'确定要复制这个流水线吗?复制将创建一个包含完整配置的新流水线。',
|
||||
extensions: {
|
||||
title: '扩展集成',
|
||||
loadError: '加载插件列表失败',
|
||||
|
||||
@@ -473,6 +473,9 @@ const zhHant = {
|
||||
defaultPipelineCannotDelete: '預設流程線不可刪除',
|
||||
deleteSuccess: '刪除成功',
|
||||
deleteError: '刪除失敗:',
|
||||
copyConfirmTitle: '確認複製',
|
||||
copyConfirmation:
|
||||
'確定要複製這個流程線嗎?複製將創建一個包含完整配置的新流程線。',
|
||||
extensions: {
|
||||
title: '擴展集成',
|
||||
loadError: '載入插件清單失敗',
|
||||
|
||||
Reference in New Issue
Block a user