fix(core): Fix issue that GET /workflows/:id does not return tags (#3522)

This commit is contained in:
Ricardo Espinoza 2022-06-18 00:45:18 -04:00 committed by GitHub
parent 1bef4df75f
commit f75f5d711f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View file

@ -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<number[]> {
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'],
});
}

View file

@ -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());