🐛 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);
|
let groupedObj = groupByFamily(myData, tooltipTitle, left, data.type, flow);
|
||||||
|
|
||||||
if (groupedObj?.length === 0 && flow && flow.length > 0) {
|
if (groupedObj?.length === 0 && flow && flow.length > 0) {
|
||||||
|
|
||||||
groupedObj = groupByFamilyCustom(
|
groupedObj = groupByFamilyCustom(
|
||||||
myData,
|
myData,
|
||||||
tooltipTitle,
|
tooltipTitle,
|
||||||
|
|
@ -114,16 +115,10 @@ export default function ParameterComponent({
|
||||||
data.type,
|
data.type,
|
||||||
flow
|
flow
|
||||||
);
|
);
|
||||||
|
|
||||||
if (groupedObj?.length === 0) {
|
|
||||||
groupedObj.push({
|
|
||||||
family: "custom_components",
|
|
||||||
type: "",
|
|
||||||
component: "Please try adding a custom component.",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (groupedObj) {
|
if (groupedObj) {
|
||||||
refNumberComponents.current = groupedObj[0]?.type?.length;
|
refNumberComponents.current = groupedObj[0]?.type?.length;
|
||||||
|
|
||||||
|
|
@ -180,6 +175,7 @@ export default function ParameterComponent({
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
renderTooltips();
|
renderTooltips();
|
||||||
}, [tooltipTitle, flow]);
|
}, [tooltipTitle, flow]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
ref={ref}
|
ref={ref}
|
||||||
|
|
|
||||||
|
|
@ -256,6 +256,8 @@ export function groupByFamilyCustom(data, baseClasses, left, type, flow) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const groupedResult = {};
|
const groupedResult = {};
|
||||||
|
|
||||||
arrOfType.forEach((item) => {
|
arrOfType.forEach((item) => {
|
||||||
|
|
@ -269,8 +271,10 @@ export function groupByFamilyCustom(data, baseClasses, left, type, flow) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const result = Object.values(groupedResult);
|
const result = Object.values(groupedResult);
|
||||||
|
|
||||||
|
|
||||||
if (left === false) {
|
if (left === false) {
|
||||||
let resultFiltered = [];
|
let resultFiltered = [];
|
||||||
flow.forEach((element) => {
|
flow.forEach((element) => {
|
||||||
|
|
@ -283,12 +287,23 @@ export function groupByFamilyCustom(data, baseClasses, left, type, flow) {
|
||||||
resultFiltered.push({
|
resultFiltered.push({
|
||||||
family: "custom_components",
|
family: "custom_components",
|
||||||
type: n,
|
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;
|
return resultFiltered;
|
||||||
} else {
|
} else {
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue