fix(parameterComponent): import extractIdFromLongId function to fix missing reference error

feat(parameterComponent): add proxy prop to ParameterComponentType to pass proxy information to the component
feat(GenericNode): pass proxy information from node template to ParameterComponent
feat(types): add proxy field to proxy object in ParameterComponentType
fix(reactflowUtils): remove unnecessary code for extracting node id
This commit is contained in:
anovazzi1 2023-09-18 20:25:42 -03:00
commit 9e01aa1580
4 changed files with 9 additions and 5 deletions

View file

@ -33,7 +33,7 @@ import {
nodeIconsLucide, nodeIconsLucide,
nodeNames, nodeNames,
} from "../../../../utils/styleUtils"; } from "../../../../utils/styleUtils";
import { classNames, groupByFamily } from "../../../../utils/utils"; import { classNames, extractIdFromLongId, groupByFamily } from "../../../../utils/utils";
export default function ParameterComponent({ export default function ParameterComponent({
left, left,
@ -48,6 +48,7 @@ export default function ParameterComponent({
required = false, required = false,
optionalHandle = null, optionalHandle = null,
info = "", info = "",
proxy
}: ParameterComponentType): JSX.Element { }: ParameterComponentType): JSX.Element {
const ref = useRef<HTMLDivElement>(null); const ref = useRef<HTMLDivElement>(null);
const refHtml = useRef<HTMLDivElement & ReactNode>(null); const refHtml = useRef<HTMLDivElement & ReactNode>(null);
@ -98,7 +99,6 @@ export default function ParameterComponent({
}; };
useEffect(() => { useEffect(() => {
if (name === "openai_api_base") console.log(info);
// @ts-ignore // @ts-ignore
infoHtml.current = ( infoHtml.current = (
<div className="h-full w-full break-words"> <div className="h-full w-full break-words">
@ -185,7 +185,9 @@ export default function ParameterComponent({
(info !== "" ? " flex items-center" : "") (info !== "" ? " flex items-center" : "")
} }
> >
{title} {proxy ? (<ShadTooltip content={<span>{proxy.id}</span>}>
<span>{title}</span>
</ShadTooltip>):title}
<span className="text-status-red">{required ? " *" : ""}</span> <span className="text-status-red">{required ? " *" : ""}</span>
<div className=""> <div className="">
{info !== "" && ( {info !== "" && (

View file

@ -274,6 +274,7 @@ export default function GenericNode({
optionalHandle={ optionalHandle={
data.node?.template[templateField].input_types data.node?.template[templateField].input_types
} }
proxy={data.node?.template[templateField].proxy}
/> />
) : ( ) : (
<></> <></>

View file

@ -49,6 +49,7 @@ export type ParameterComponentType = {
dataContext?: typesContextType; dataContext?: typesContextType;
optionalHandle?: Array<String> | null; optionalHandle?: Array<String> | null;
info?: string; info?: string;
proxy?: {field: string, id: string};
}; };
export type InputListComponentType = { export type InputListComponentType = {
value: string[]; value: string[];

View file

@ -584,8 +584,8 @@ export function mergeNodeTemplates({
? nodeTemplate[key].display_name ? nodeTemplate[key].display_name
: nodeTemplate[key].name : nodeTemplate[key].name
? toTitleCase(nodeTemplate[key].name) ? toTitleCase(nodeTemplate[key].name)
: toTitleCase(key)) + " - "+ truncateDisplayName(node.data.node?.display_name!) +"-" + : toTitleCase(key)) + " - "+ truncateDisplayName(node.data.node?.display_name!)
extractIdFromLongId(node.data.id)
} }
} }
}); });