Refactor code to improve performance and readability
This commit is contained in:
parent
5a5a5bba55
commit
b83ffc87b2
1 changed files with 43 additions and 58 deletions
|
|
@ -138,7 +138,8 @@ export default function GenericNode({
|
|||
const iconColor = nodeColors[types[data.type]];
|
||||
const iconName =
|
||||
iconElement || (data.node?.flow ? "group_components" : name);
|
||||
const iconClassName = `generic-node-icon ${!showNode ? " absolute inset-x-6 h-12 w-12 " : ""
|
||||
const iconClassName = `generic-node-icon ${
|
||||
!showNode ? " absolute inset-x-6 h-12 w-12 " : ""
|
||||
}`;
|
||||
if (iconElement && isEmoji) {
|
||||
return nodeIconFragment(iconElement);
|
||||
|
|
@ -389,27 +390,12 @@ export default function GenericNode({
|
|||
})}
|
||||
data={data}
|
||||
color={
|
||||
data.node?.template[templateField].input_types &&
|
||||
data.node?.template[templateField].input_types!
|
||||
.length > 0
|
||||
? nodeColors[
|
||||
data.node?.template[templateField]
|
||||
.input_types![data.node?.template[templateField]
|
||||
.input_types!.length - 1]
|
||||
] ??
|
||||
nodeColors[
|
||||
types[
|
||||
data.node?.template[templateField]
|
||||
.input_types![data.node?.template[templateField]
|
||||
.input_types!.length - 1]
|
||||
]
|
||||
]
|
||||
: nodeColors[
|
||||
data.node?.template[templateField].type!
|
||||
] ??
|
||||
nodeColors[
|
||||
types[data.node?.template[templateField].type!]
|
||||
] ??
|
||||
nodeColors[
|
||||
data.node?.template[templateField].type!
|
||||
] ??
|
||||
nodeColors.unknown
|
||||
}
|
||||
title={getFieldTitle(
|
||||
|
|
@ -475,6 +461,12 @@ export default function GenericNode({
|
|||
<Button
|
||||
variant="secondary"
|
||||
className={"group h-9 px-1.5"}
|
||||
onClick={() => {
|
||||
if (buildStatus === BuildStatus.BUILDING || isBuilding)
|
||||
return;
|
||||
setValidationStatus(null);
|
||||
buildFlow({ nodeId: data.id });
|
||||
}}
|
||||
>
|
||||
<div>
|
||||
<ShadTooltip
|
||||
|
|
@ -497,12 +489,7 @@ export default function GenericNode({
|
|||
}
|
||||
side="bottom"
|
||||
>
|
||||
<div onClick={() => {
|
||||
if (buildStatus === BuildStatus.BUILDING || isBuilding)
|
||||
return;
|
||||
setValidationStatus(null);
|
||||
buildFlow({ nodeId: data.id });
|
||||
}} className="generic-node-status-position flex items-center justify-center">
|
||||
<div className="generic-node-status-position flex items-center justify-center">
|
||||
{renderIconStatus(buildStatus, validationStatus)}
|
||||
</div>
|
||||
</ShadTooltip>
|
||||
|
|
@ -621,14 +608,12 @@ export default function GenericNode({
|
|||
.length > 0
|
||||
? nodeColors[
|
||||
data.node?.template[templateField]
|
||||
.input_types![data.node?.template[templateField]
|
||||
.input_types!.length - 1]
|
||||
.input_types![0]
|
||||
] ??
|
||||
nodeColors[
|
||||
types[
|
||||
data.node?.template[templateField]
|
||||
.input_types![data.node?.template[templateField]
|
||||
.input_types!.length - 1]
|
||||
.input_types![0]
|
||||
]
|
||||
]
|
||||
: nodeColors[
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue