fix: update handle display logic and improve popover layout in node components (#7244)

* ✨ (NodeInputField/index.tsx): Add support for displaying a refresh button based on the template configuration
🔧 (popover/index.tsx): Adjust the width of the input field in the popover to improve UI consistency

* 🐛 (NodeInputField/index.tsx): fix access to refresh_button property to prevent potential null pointer error

* ✨ (index.tsx): Add hasRefreshButton prop to InputComponent, InputGlobalComponent, and StrRenderComponent to enable refresh button functionality
📝 (index.tsx): Add hasRefreshButton prop to BaseInputProps type to ensure type safety and consistency across components and types
This commit is contained in:
Cristhian Zanforlin Lousa 2025-03-24 12:19:18 -03:00 • committed by GitHub
commit 234b10457e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 18 additions and 4 deletions

View file

@ -68,6 +68,10 @@ export default function NodeInputField({
name,
});
const hasRefreshButton = useMemo(() => {
return data.node?.template[name]?.refresh_button;
}, [data.node?.template, name]);
const nodeInformationMetadata: NodeInfoType = useMemo(() => {
return {
flowId: currentFlow?.id ?? "",
@ -89,7 +93,8 @@ export default function NodeInputField({
const displayHandle =
(!LANGFLOW_SUPPORTED_TYPES.has(type ?? "") ||
(optionalHandle && optionalHandle.length > 0)) &&
!isToolMode;
!isToolMode &&
!hasRefreshButton;
const isFlexView = FLEX_VIEW_TYPES.includes(type ?? "");

View file

@ -185,6 +185,7 @@ const CustomInputPopover = ({
popoverWidth,
commandWidth,
blockAddNewGlobalVariable,
hasRefreshButton,
}) => {
const [isFocused, setIsFocused] = useState(false);
const memoizedOptions = useMemo(() => new Set<string>(options), [options]);
@ -254,8 +255,9 @@ const CustomInputPopover = ({
className={cn(
editNode && "text-xs",
nodeStyle
? "max-w-60 rounded-[3px] px-1 font-mono"
? "max-w-56 rounded-[3px] px-1 font-mono"
: "bg-muted",
hasRefreshButton && "max-w-48",
)}
/>
</div>

View file

@ -42,6 +42,7 @@ export default function InputComponent({
popoverWidth,
commandWidth,
blockAddNewGlobalVariable = false,
hasRefreshButton = false,
}: InputComponentType): JSX.Element {
const [pwdVisible, setPwdVisible] = useState(false);
const refInput = useRef<HTMLInputElement>(null);
@ -155,6 +156,7 @@ export default function InputComponent({
popoverWidth={popoverWidth}
commandWidth={commandWidth}
blockAddNewGlobalVariable={blockAddNewGlobalVariable}
hasRefreshButton={hasRefreshButton}
/>
)}
</>

View file

@ -5,7 +5,7 @@ import {
import GeneralDeleteConfirmationModal from "@/shared/components/delete-confirmation-modal";
import GeneralGlobalVariableModal from "@/shared/components/global-variable-modal";
import { useGlobalVariablesStore } from "@/stores/globalVariablesStore/globalVariables";
import { useEffect } from "react";
import { useEffect, useMemo } from "react";
import DeleteConfirmationModal from "../../../../../modals/deleteConfirmationModal";
import useAlertStore from "../../../../../stores/alertStore";
import { cn } from "../../../../../utils/utils";
@ -27,6 +27,7 @@ export default function InputGlobalComponent({
editNode = false,
placeholder,
isToolMode = false,
hasRefreshButton = false,
}: InputProps<string, InputGlobalComponentType>): JSX.Element {
const { data: globalVariables } = useGetGlobalVariables();
const unavailableFields = useGlobalVariablesStore(
@ -115,6 +116,7 @@ export default function InputGlobalComponent({
);
}}
isToolMode={isToolMode}
hasRefreshButton={hasRefreshButton}
/>
);
}

View file

@ -66,7 +66,7 @@ export function StrRenderComponent({
<DropdownComponent
{...baseInputProps}
dialogInputs={templateData.dialog_inputs}
options={templateData.options}
options={templateData.options ?? []}
optionsMetaData={templateData.options_metadata}
combobox={templateData.combobox}
name={templateData?.name!}

View file

@ -72,6 +72,7 @@ export function ParameterRenderComponent({
isToolMode,
nodeId,
nodeInformationMetadata,
hasRefreshButton: templateData.refresh_button,
};
if (TEXT_FIELD_TYPES.includes(templateData.type ?? "")) {

View file

@ -20,6 +20,7 @@ export type BaseInputProps<valueType = any> = {
metadata?: any;
nodeId?: string;
nodeInformationMetadata?: NodeInfoType;
hasRefreshButton?: boolean;
};
// Generic type for composing input props

View file

@ -49,6 +49,7 @@ export type InputComponentType = {
popoverWidth?: string;
commandWidth?: string;
blockAddNewGlobalVariable?: boolean;
hasRefreshButton?: boolean;
};
export type DropDownComponent = {
disabled?: boolean;