From 75e19b4339fc193eee7815bacf7583437fb22dd6 Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Tue, 25 Jul 2023 12:48:24 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(parameterComponent):=20remov?= =?UTF-8?q?e=20unnecessary=20if=20condition=20and=20code=20block=20?= =?UTF-8?q?=F0=9F=90=9B=20fix(utils):=20remove=20unnecessary=20if=20condit?= =?UTF-8?q?ion=20and=20code=20block=20=E2=9C=A8=20feat(parameterComponent)?= =?UTF-8?q?:=20add=20fallback=20logic=20to=20display=20a=20custom=20compon?= =?UTF-8?q?ent=20when=20no=20grouped=20objects=20are=20found?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/parameterComponent/index.tsx | 12 ++++-------- src/frontend/src/utils/utils.ts | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx index bc5368bf1..714d61bb9 100644 --- a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx @@ -107,6 +107,7 @@ export default function ParameterComponent({ let groupedObj = groupByFamily(myData, tooltipTitle, left, data.type, flow); if (groupedObj?.length === 0 && flow && flow.length > 0) { + groupedObj = groupByFamilyCustom( myData, tooltipTitle, @@ -114,16 +115,10 @@ export default function ParameterComponent({ data.type, flow ); - - if (groupedObj?.length === 0) { - groupedObj.push({ - family: "custom_components", - type: "", - component: "Please try adding a custom component.", - }); - } } + + if (groupedObj) { refNumberComponents.current = groupedObj[0]?.type?.length; @@ -180,6 +175,7 @@ export default function ParameterComponent({ useEffect(() => { renderTooltips(); }, [tooltipTitle, flow]); + return (
{ @@ -269,8 +271,10 @@ export function groupByFamilyCustom(data, baseClasses, left, type, flow) { } }); + const result = Object.values(groupedResult); + if (left === false) { let resultFiltered = []; flow.forEach((element) => { @@ -283,12 +287,23 @@ export function groupByFamilyCustom(data, baseClasses, left, type, flow) { resultFiltered.push({ family: "custom_components", type: n, - component: element["data"]["node"]["display_name"], + component: element["data"]["node"]["display_name"] }); }); } }); }); + + if(resultFiltered.length === 0) { + Object.keys(groupedResult).forEach((el) => { + resultFiltered.push({ + family: "custom_components", + type: groupedResult[el].type, + component: nodeNames["custom_components"] + }) + }) + } + return resultFiltered; } else { return result;