Skip to content

Commit

Permalink
fix: Fix problem saving workflow when tags disabled (#3792)
Browse files Browse the repository at this point in the history
* ⚡ Add @AfterLoad nullCheck for WorkflowEntity tags

* ⚡ Make tags optional in Entity

* Fix workflows api typing issue

Co-authored-by: Omar Ajoue <krynble@gmail.com>
  • Loading branch information
brianinoa and krynble authored Aug 2, 2022
1 parent 2cab8e7 commit f0dddaa
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/cli/src/Interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/api/workflows.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/databases/entities/WorkflowEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class WorkflowEntity implements IWorkflowDb {
referencedColumnName: 'id',
},
})
tags: TagEntity[];
tags?: TagEntity[];

@OneToMany(() => SharedWorkflow, (sharedWorkflow) => sharedWorkflow.workflow)
shared: SharedWorkflow[];
Expand Down

0 comments on commit f0dddaa

Please sign in to comment.