From 3b3d22ea099551130e4cdac4d840c05264ce1aff Mon Sep 17 00:00:00 2001 From: ricardo Date: Wed, 15 Jun 2022 13:36:22 -0400 Subject: [PATCH] :bug: Fix GET /workflows/:id not returning tags --- .../PublicApi/v1/handlers/workflows/workflows.service.ts | 7 ++++++- packages/cli/test/integration/publicApi/workflows.test.ts | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/PublicApi/v1/handlers/workflows/workflows.service.ts b/packages/cli/src/PublicApi/v1/handlers/workflows/workflows.service.ts index e50dc3e4b8efb..440a83b615a9a 100644 --- a/packages/cli/src/PublicApi/v1/handlers/workflows/workflows.service.ts +++ b/packages/cli/src/PublicApi/v1/handlers/workflows/workflows.service.ts @@ -8,6 +8,11 @@ import { WorkflowEntity } from '../../../../databases/entities/WorkflowEntity'; import { SharedWorkflow } from '../../../../databases/entities/SharedWorkflow'; import { isInstanceOwner } from '../users/users.service'; import { Role } from '../../../../databases/entities/Role'; +import config from '../../../../../config'; + +function insertIf(condition: boolean, elements: string[]): string[] { + return condition ? elements : []; +} export async function getSharedWorkflowIds(user: User): Promise { const sharedWorkflows = await Db.collections.SharedWorkflow.find({ @@ -26,7 +31,7 @@ export async function getSharedWorkflow( ...(!isInstanceOwner(user) && { user }), ...(workflowId && { workflow: { id: workflowId } }), }, - relations: ['workflow'], + relations: [...insertIf(!config.getEnv('workflowTagsDisabled'), ['workflow.tags']), 'workflow'], }); } diff --git a/packages/cli/test/integration/publicApi/workflows.test.ts b/packages/cli/test/integration/publicApi/workflows.test.ts index 933ff7f3f5688..c4c0dc670f75e 100644 --- a/packages/cli/test/integration/publicApi/workflows.test.ts +++ b/packages/cli/test/integration/publicApi/workflows.test.ts @@ -413,7 +413,7 @@ test('GET /workflows/:id should retrieve workflow', async () => { expect(response.statusCode).toBe(200); - const { id, connections, active, staticData, nodes, settings, name, createdAt, updatedAt } = + const { id, connections, active, staticData, nodes, settings, name, createdAt, updatedAt, tags } = response.body; expect(id).toEqual(workflow.id); @@ -422,6 +422,7 @@ test('GET /workflows/:id should retrieve workflow', async () => { expect(active).toBe(false); expect(staticData).toEqual(workflow.staticData); expect(nodes).toEqual(workflow.nodes); + expect(tags).toEqual([]); expect(settings).toEqual(workflow.settings); expect(createdAt).toEqual(workflow.createdAt.toISOString()); expect(updatedAt).toEqual(workflow.updatedAt.toISOString());