fix: Fix problem saving workflow when tags disabled (#3792)

*  Add @AfterLoad nullCheck for WorkflowEntity tags

*  Make tags optional in Entity

* Fix workflows api typing issue

Co-authored-by: Omar Ajoue <krynble@gmail.com>
This commit is contained in:
brianinoa 2022-08-02 17:18:57 +02:00 committed by GitHub
parent 2cab8e7779
commit f0dddaa2a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 4 deletions

View file

@ -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 {

View file

@ -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,
});

View file

@ -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,
});

View file

@ -112,7 +112,7 @@ export class WorkflowEntity implements IWorkflowDb {
referencedColumnName: 'id',
},
})
tags: TagEntity[];
tags?: TagEntity[];
@OneToMany(() => SharedWorkflow, (sharedWorkflow) => sharedWorkflow.workflow)
shared: SharedWorkflow[];