feat(core): Allow transferring workflows from any project to any team project (#9534)

This commit is contained in:
Danny Martini
2024-06-03 16:57:04 +02:00
committed by GitHub
parent 68420ca6be
commit d6db8cbf23
14 changed files with 572 additions and 29 deletions

View File

@@ -40,6 +40,7 @@ import { ApplicationError } from 'n8n-workflow';
import { In, type FindOptionsRelations } from '@n8n/typeorm';
import type { Project } from '@/databases/entities/Project';
import { ProjectRelationRepository } from '@/databases/repositories/projectRelation.repository';
import { z } from 'zod';
@RestController('/workflows')
export class WorkflowsController {
@@ -460,4 +461,16 @@ export class WorkflowsController {
workflow,
});
}
@Put('/:workflowId/transfer')
@ProjectScope('workflow:move')
async transfer(req: WorkflowRequest.Transfer) {
const body = z.object({ destinationProjectId: z.string() }).parse(req.body);
return await this.enterpriseWorkflowService.transferOne(
req.user,
req.params.workflowId,
body.destinationProjectId,
);
}
}