Fix: Minimize working after add a new handle with promptTemplate

This commit is contained in:
igorrCarvalho 2023-09-13 18:17:01 -03:00
commit b1f874ca03
2 changed files with 18 additions and 17 deletions

View file

@ -14,7 +14,6 @@ import { cleanEdges } from "../../utils/reactflowUtils";
import { nodeColors, nodeIconsLucide } from "../../utils/styleUtils"; import { nodeColors, nodeIconsLucide } from "../../utils/styleUtils";
import { classNames, toTitleCase } from "../../utils/utils"; import { classNames, toTitleCase } from "../../utils/utils";
import ParameterComponent from "./components/parameterComponent"; import ParameterComponent from "./components/parameterComponent";
import { Button } from "@mui/material";
export default function GenericNode({ export default function GenericNode({
data: olddata, data: olddata,
@ -37,8 +36,10 @@ export default function GenericNode({
function countHandles(): void { function countHandles(): void {
numberOfInputs = Object.keys(data.node!.template) numberOfInputs = Object.keys(data.node!.template)
.filter((templateField) => templateField.charAt(0) !== "_").map((templateCamp) => { .filter((templateField) => templateField.charAt(0) !== "_").map((templateCamp) => {
if (!data.node?.template[templateCamp].show) return false const { template } = data.node!;
switch (data.node?.template[templateCamp].type) { if (template[templateCamp].input_types) return true
if (!template[templateCamp].show) return false
switch (template[templateCamp].type) {
case "str": case "str":
return false; return false;
case "bool": case "bool":
@ -84,7 +85,6 @@ export default function GenericNode({
}, },
}); });
updateFlow(flow); updateFlow(flow);
console.log(myFlow)
} }
countHandles(); countHandles();
}, [data]); }, [data]);
@ -115,7 +115,7 @@ export default function GenericNode({
<div <div
className={classNames( className={classNames(
selected ? "border border-ring" : "border", 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", "generic-node-div",
)} )}
> >

View file

@ -117,7 +117,7 @@ export default function NodeToolbarComponent({
> >
<div <div
className={classNames( 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 (nodeLength == 0
? " text-muted-foreground" ? " text-muted-foreground"
: " text-foreground") : " text-foreground")
@ -129,17 +129,18 @@ export default function NodeToolbarComponent({
</div> </div>
</ShadTooltip> </ShadTooltip>
<ShadTooltip content={canMinimize() ? "Minimize" : "Only nodes with 1 or less input handles can minimize"} side="top"> {canMinimize() && (
<ShadTooltip content={"Minimize"} side="top">
<button <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" 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) => { onClick={(event) => {
if (canMinimize()) return setShowNode(prev => !prev); setShowNode(prev => !prev);
event.preventDefault();
}} }}
> >
<IconComponent name="Minus" className="h-4 w-4" /> <IconComponent name="Minus" className="h-4 w-4" />
</button> </button>
</ShadTooltip> </ShadTooltip>
)}
</span> </span>
</div> </div>
</> </>