mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
feat: Resolve parentFolder when retrieving workflow (#14656)
This commit is contained in:
@@ -23,7 +23,7 @@ export class Folder extends WithTimestampsAndStringId {
|
|||||||
@Column()
|
@Column()
|
||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
@Column({ nullable: true, select: false })
|
@Column({ nullable: true })
|
||||||
parentFolderId: string | null;
|
parentFolderId: string | null;
|
||||||
|
|
||||||
@ManyToOne(() => Folder, { nullable: true, onDelete: 'CASCADE' })
|
@ManyToOne(() => Folder, { nullable: true, onDelete: 'CASCADE' })
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ export class WorkflowsController {
|
|||||||
workflowId,
|
workflowId,
|
||||||
req.user,
|
req.user,
|
||||||
['workflow:read'],
|
['workflow:read'],
|
||||||
{ includeTags: !this.globalConfig.tags.disabled },
|
{ includeTags: !this.globalConfig.tags.disabled, includeParentFolder: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!workflow) {
|
if (!workflow) {
|
||||||
|
|||||||
@@ -513,6 +513,55 @@ describe('GET /workflows/:workflowId', () => {
|
|||||||
tags: [expect.objectContaining({ id: tag.id, name: tag.name })],
|
tags: [expect.objectContaining({ id: tag.id, name: tag.name })],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should return parent folder', async () => {
|
||||||
|
const personalProject = await projectRepository.getPersonalProjectForUserOrFail(owner.id);
|
||||||
|
|
||||||
|
const folder1 = await createFolder(personalProject, { name: 'Folder 1' });
|
||||||
|
|
||||||
|
const folder2 = await createFolder(personalProject, {
|
||||||
|
name: 'Folder 2',
|
||||||
|
parentFolder: folder1,
|
||||||
|
});
|
||||||
|
|
||||||
|
const workflow1 = await createWorkflow({ parentFolder: folder2 }, owner);
|
||||||
|
|
||||||
|
const workflow2 = await createWorkflow({}, owner);
|
||||||
|
|
||||||
|
const workflow3 = await createWorkflow({ parentFolder: folder1 }, owner);
|
||||||
|
|
||||||
|
const workflowInNestedFolderWithGrantParent = await authOwnerAgent
|
||||||
|
.get(`/workflows/${workflow1.id}`)
|
||||||
|
.expect(200);
|
||||||
|
|
||||||
|
expect(workflowInNestedFolderWithGrantParent.body.data).toMatchObject({
|
||||||
|
parentFolder: expect.objectContaining({
|
||||||
|
id: folder2.id,
|
||||||
|
name: folder2.name,
|
||||||
|
parentFolderId: folder1.id,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
const workflowInProjectRoot = await authOwnerAgent
|
||||||
|
.get(`/workflows/${workflow2.id}`)
|
||||||
|
.expect(200);
|
||||||
|
|
||||||
|
expect(workflowInProjectRoot.body.data).toMatchObject({
|
||||||
|
parentFolder: null,
|
||||||
|
});
|
||||||
|
|
||||||
|
const workflowInNestedFolder = await authOwnerAgent
|
||||||
|
.get(`/workflows/${workflow3.id}`)
|
||||||
|
.expect(200);
|
||||||
|
|
||||||
|
expect(workflowInNestedFolder.body.data).toMatchObject({
|
||||||
|
parentFolder: expect.objectContaining({
|
||||||
|
id: folder1.id,
|
||||||
|
name: folder1.name,
|
||||||
|
parentFolderId: null,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('GET /workflows', () => {
|
describe('GET /workflows', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user