mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 18:41:14 +00:00
feat(core): Update POST /workflows to link folder (no-changelog) (#13449)
This commit is contained in:
@@ -46,6 +46,7 @@ import { License } from '@/license';
|
||||
import { listQueryMiddleware } from '@/middlewares';
|
||||
import { AuthenticatedRequest } from '@/requests';
|
||||
import * as ResponseHelper from '@/response-helper';
|
||||
import { FolderService } from '@/services/folder.service';
|
||||
import { NamingService } from '@/services/naming.service';
|
||||
import { ProjectService } from '@/services/project.service.ee';
|
||||
import { TagService } from '@/services/tag.service';
|
||||
@@ -82,6 +83,7 @@ export class WorkflowsController {
|
||||
private readonly projectRelationRepository: ProjectRelationRepository,
|
||||
private readonly eventService: EventService,
|
||||
private readonly globalConfig: GlobalConfig,
|
||||
private readonly folderService: FolderService,
|
||||
) {}
|
||||
|
||||
@Post('/')
|
||||
@@ -133,7 +135,7 @@ export class WorkflowsController {
|
||||
const savedWorkflow = await Db.transaction(async (transactionManager) => {
|
||||
const workflow = await transactionManager.save<WorkflowEntity>(newWorkflow);
|
||||
|
||||
const { projectId } = req.body;
|
||||
const { projectId, parentFolderId } = req.body;
|
||||
project =
|
||||
projectId === undefined
|
||||
? await this.projectRepository.getPersonalProjectForUser(req.user.id, transactionManager)
|
||||
@@ -155,6 +157,17 @@ export class WorkflowsController {
|
||||
throw new ApplicationError('No personal project found');
|
||||
}
|
||||
|
||||
if (parentFolderId) {
|
||||
try {
|
||||
const parentFolder = await this.folderService.getFolderInProject(
|
||||
parentFolderId,
|
||||
project.id,
|
||||
transactionManager,
|
||||
);
|
||||
await transactionManager.update(WorkflowEntity, { id: workflow.id }, { parentFolder });
|
||||
} catch {}
|
||||
}
|
||||
|
||||
const newSharedWorkflow = this.sharedWorkflowRepository.create({
|
||||
role: 'workflow:owner',
|
||||
projectId: project.id,
|
||||
@@ -167,7 +180,7 @@ export class WorkflowsController {
|
||||
workflow.id,
|
||||
req.user,
|
||||
['workflow:read'],
|
||||
{ em: transactionManager, includeTags: true },
|
||||
{ em: transactionManager, includeTags: true, includeParentFolder: true },
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user