From 264f7c21396886ed2ccc27470782aaed94fd8b4e Mon Sep 17 00:00:00 2001 From: Joel Date: Tue, 10 Sep 2024 10:59:13 +0800 Subject: [PATCH] fix: file show type error --- .../workflow/nodes/_base/components/variable/utils.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/web/app/components/workflow/nodes/_base/components/variable/utils.ts b/web/app/components/workflow/nodes/_base/components/variable/utils.ts index eaa35d9951..5a7e7886fa 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/utils.ts +++ b/web/app/components/workflow/nodes/_base/components/variable/utils.ts @@ -52,18 +52,18 @@ const inputVarTypeToVarType = (type: InputVarType): VarType => { } as any)[type] || VarType.string } -const findExceptVarInObject = (obj: any, filterVar: (payload: Var, selector: ValueSelector) => boolean, value_selector: ValueSelector): Var => { +const findExceptVarInObject = (obj: any, filterVar: (payload: Var, selector: ValueSelector) => boolean, value_selector: ValueSelector, isFile?: boolean): Var => { const { children } = obj const res: Var = { variable: obj.variable, - type: VarType.object, + type: isFile ? VarType.file : VarType.object, children: children.filter((item: Var) => { const { children } = item const currSelector = [...value_selector, item.variable] if (!children) return filterVar(item, currSelector) - const obj = findExceptVarInObject(item, filterVar, currSelector) + const obj = findExceptVarInObject(item, filterVar, currSelector, false) // File doesn't contains file children return obj.children && obj.children?.length > 0 }), } @@ -302,7 +302,6 @@ const formatItem = ( } const selector = [id] - res.vars = res.vars.filter((v) => { const isCurrentMatched = filterVar(v, (() => { const variableArr = v.variable.split('.') @@ -330,7 +329,7 @@ const formatItem = ( if (!children) return false - const obj = findExceptVarInObject(isFile ? { ...v, children } : v, filterVar, selector) + const obj = findExceptVarInObject(isFile ? { ...v, children } : v, filterVar, selector, isFile) return obj?.children && obj?.children.length > 0 }).map((v) => { const isFile = v.type === VarType.file @@ -352,7 +351,7 @@ const formatItem = ( if (!children) return v - return findExceptVarInObject(isFile ? { ...v, children } : v, filterVar, selector) + return findExceptVarInObject(isFile ? { ...v, children } : v, filterVar, selector, isFile) }) return res