From f0dddaa2a585715b35e26b16e1003e1683ab9402 Mon Sep 17 00:00:00 2001 From: brianinoa <54530642+brianinoa@users.noreply.github.com> Date: Tue, 2 Aug 2022 17:18:57 +0200 Subject: [PATCH] fix: Fix problem saving workflow when tags disabled (#3792) * :zap: Add @AfterLoad nullCheck for WorkflowEntity tags * :zap: Make tags optional in Entity * Fix workflows api typing issue Co-authored-by: Omar Ajoue --- packages/cli/src/Interfaces.ts | 2 +- packages/cli/src/Server.ts | 2 +- packages/cli/src/api/workflows.api.ts | 2 +- packages/cli/src/databases/entities/WorkflowEntity.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/Interfaces.ts b/packages/cli/src/Interfaces.ts index aa4150c7ffbc2..64f7c0a473a2a 100644 --- a/packages/cli/src/Interfaces.ts +++ b/packages/cli/src/Interfaces.ts @@ -144,7 +144,7 @@ export interface IWorkflowBase extends IWorkflowBaseWorkflow { // Almost identical to editor-ui.Interfaces.ts export interface IWorkflowDb extends IWorkflowBase { id: number | string; - tags: ITagDb[]; + tags?: ITagDb[]; } export interface IWorkflowToImport extends IWorkflowBase { diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index 9a18f5d132db1..b9698f44f19b5 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -993,7 +993,7 @@ class App { ); } - if (updatedWorkflow.tags.length && tags?.length) { + if (updatedWorkflow.tags?.length && tags?.length) { updatedWorkflow.tags = TagHelpers.sortByRequestOrder(updatedWorkflow.tags, { requestOrder: tags, }); diff --git a/packages/cli/src/api/workflows.api.ts b/packages/cli/src/api/workflows.api.ts index 3afd63f8b7f24..076715751dafe 100644 --- a/packages/cli/src/api/workflows.api.ts +++ b/packages/cli/src/api/workflows.api.ts @@ -69,7 +69,7 @@ workflowsController.post( throw new ResponseHelper.ResponseError('Failed to save workflow'); } - if (tagIds && !config.getEnv('workflowTagsDisabled')) { + if (tagIds && !config.getEnv('workflowTagsDisabled') && savedWorkflow.tags) { savedWorkflow.tags = TagHelpers.sortByRequestOrder(savedWorkflow.tags, { requestOrder: tagIds, }); diff --git a/packages/cli/src/databases/entities/WorkflowEntity.ts b/packages/cli/src/databases/entities/WorkflowEntity.ts index b3e0427ee2d2f..94a1183a9df99 100644 --- a/packages/cli/src/databases/entities/WorkflowEntity.ts +++ b/packages/cli/src/databases/entities/WorkflowEntity.ts @@ -112,7 +112,7 @@ export class WorkflowEntity implements IWorkflowDb { referencedColumnName: 'id', }, }) - tags: TagEntity[]; + tags?: TagEntity[]; @OneToMany(() => SharedWorkflow, (sharedWorkflow) => sharedWorkflow.workflow) shared: SharedWorkflow[];