🐛 fix(parameterComponent): remove unnecessary if condition and code block
🐛 fix(utils): remove unnecessary if condition and code block ✨ feat(parameterComponent): add fallback logic to display a custom component when no grouped objects are found
This commit is contained in:
parent
9736dab3c7
commit
75e19b4339
2 changed files with 20 additions and 9 deletions
|
|
@ -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 (
|
||||
<div
|
||||
ref={ref}
|
||||
|
|
|
|||
|
|
@ -256,6 +256,8 @@ export function groupByFamilyCustom(data, baseClasses, left, type, flow) {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
const groupedResult = {};
|
||||
|
||||
arrOfType.forEach((item) => {
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue