Fix: Minimize working after add a new handle with promptTemplate
This commit is contained in:
parent
c70de1e881
commit
b1f874ca03
2 changed files with 18 additions and 17 deletions
|
|
@ -14,7 +14,6 @@ import { cleanEdges } from "../../utils/reactflowUtils";
|
|||
import { nodeColors, nodeIconsLucide } from "../../utils/styleUtils";
|
||||
import { classNames, toTitleCase } from "../../utils/utils";
|
||||
import ParameterComponent from "./components/parameterComponent";
|
||||
import { Button } from "@mui/material";
|
||||
|
||||
export default function GenericNode({
|
||||
data: olddata,
|
||||
|
|
@ -37,8 +36,10 @@ export default function GenericNode({
|
|||
function countHandles(): void {
|
||||
numberOfInputs = Object.keys(data.node!.template)
|
||||
.filter((templateField) => templateField.charAt(0) !== "_").map((templateCamp) => {
|
||||
if (!data.node?.template[templateCamp].show) return false
|
||||
switch (data.node?.template[templateCamp].type) {
|
||||
const { template } = data.node!;
|
||||
if (template[templateCamp].input_types) return true
|
||||
if (!template[templateCamp].show) return false
|
||||
switch (template[templateCamp].type) {
|
||||
case "str":
|
||||
return false;
|
||||
case "bool":
|
||||
|
|
@ -84,7 +85,6 @@ export default function GenericNode({
|
|||
},
|
||||
});
|
||||
updateFlow(flow);
|
||||
console.log(myFlow)
|
||||
}
|
||||
countHandles();
|
||||
}, [data]);
|
||||
|
|
@ -115,7 +115,7 @@ export default function GenericNode({
|
|||
<div
|
||||
className={classNames(
|
||||
selected ? "border border-ring" : "border",
|
||||
showNode ? "w-96" : "w-24 h-24 rounded-full",
|
||||
showNode ? "w-96" : "w-26 h-26 rounded-full",
|
||||
"generic-node-div",
|
||||
)}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ export default function NodeToolbarComponent({
|
|||
>
|
||||
<div
|
||||
className={classNames(
|
||||
"relative -ml-px inline-flex items-center bg-background px-2 py-2 text-foreground shadow-md ring-1 ring-inset ring-ring transition-all duration-500 ease-in-out hover:bg-muted focus:z-10" +
|
||||
"relative -ml-px inline-flex items-center bg-background px-2 py-2 text-foreground shadow-md ring-1 ring-inset ring-ring transition-all duration-500 ease-in-out hover:bg-muted focus:z-10" + (!canMinimize() && " rounded-r-md ") +
|
||||
(nodeLength == 0
|
||||
? " text-muted-foreground"
|
||||
: " text-foreground")
|
||||
|
|
@ -129,17 +129,18 @@ export default function NodeToolbarComponent({
|
|||
</div>
|
||||
</ShadTooltip>
|
||||
|
||||
<ShadTooltip content={canMinimize() ? "Minimize" : "Only nodes with 1 or less input handles can minimize"} side="top">
|
||||
<button
|
||||
className="relative inline-flex items-center rounded-r-md bg-background px-2 py-2 text-foreground shadow-md ring-1 ring-inset ring-ring transition-all duration-500 ease-in-out hover:bg-muted focus:z-10"
|
||||
onClick={(event) => {
|
||||
if (canMinimize()) return setShowNode(prev => !prev);
|
||||
event.preventDefault();
|
||||
}}
|
||||
>
|
||||
<IconComponent name="Minus" className="h-4 w-4" />
|
||||
</button>
|
||||
</ShadTooltip>
|
||||
{canMinimize() && (
|
||||
<ShadTooltip content={"Minimize"} side="top">
|
||||
<button
|
||||
className="relative inline-flex items-center rounded-r-md bg-background px-2 py-2 text-foreground shadow-md ring-1 ring-inset ring-ring transition-all duration-500 ease-in-out hover:bg-muted focus:z-10"
|
||||
onClick={(event) => {
|
||||
setShowNode(prev => !prev);
|
||||
}}
|
||||
>
|
||||
<IconComponent name="Minus" className="h-4 w-4" />
|
||||
</button>
|
||||
</ShadTooltip>
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
</>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue