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:
parent
ee1b5494fc
commit
234b10457e
8 changed files with 18 additions and 4 deletions
|
|
@ -68,6 +68,10 @@ export default function NodeInputField({
|
||||||
name,
|
name,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const hasRefreshButton = useMemo(() => {
|
||||||
|
return data.node?.template[name]?.refresh_button;
|
||||||
|
}, [data.node?.template, name]);
|
||||||
|
|
||||||
const nodeInformationMetadata: NodeInfoType = useMemo(() => {
|
const nodeInformationMetadata: NodeInfoType = useMemo(() => {
|
||||||
return {
|
return {
|
||||||
flowId: currentFlow?.id ?? "",
|
flowId: currentFlow?.id ?? "",
|
||||||
|
|
@ -89,7 +93,8 @@ export default function NodeInputField({
|
||||||
const displayHandle =
|
const displayHandle =
|
||||||
(!LANGFLOW_SUPPORTED_TYPES.has(type ?? "") ||
|
(!LANGFLOW_SUPPORTED_TYPES.has(type ?? "") ||
|
||||||
(optionalHandle && optionalHandle.length > 0)) &&
|
(optionalHandle && optionalHandle.length > 0)) &&
|
||||||
!isToolMode;
|
!isToolMode &&
|
||||||
|
!hasRefreshButton;
|
||||||
|
|
||||||
const isFlexView = FLEX_VIEW_TYPES.includes(type ?? "");
|
const isFlexView = FLEX_VIEW_TYPES.includes(type ?? "");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -185,6 +185,7 @@ const CustomInputPopover = ({
|
||||||
popoverWidth,
|
popoverWidth,
|
||||||
commandWidth,
|
commandWidth,
|
||||||
blockAddNewGlobalVariable,
|
blockAddNewGlobalVariable,
|
||||||
|
hasRefreshButton,
|
||||||
}) => {
|
}) => {
|
||||||
const [isFocused, setIsFocused] = useState(false);
|
const [isFocused, setIsFocused] = useState(false);
|
||||||
const memoizedOptions = useMemo(() => new Set<string>(options), [options]);
|
const memoizedOptions = useMemo(() => new Set<string>(options), [options]);
|
||||||
|
|
@ -254,8 +255,9 @@ const CustomInputPopover = ({
|
||||||
className={cn(
|
className={cn(
|
||||||
editNode && "text-xs",
|
editNode && "text-xs",
|
||||||
nodeStyle
|
nodeStyle
|
||||||
? "max-w-60 rounded-[3px] px-1 font-mono"
|
? "max-w-56 rounded-[3px] px-1 font-mono"
|
||||||
: "bg-muted",
|
: "bg-muted",
|
||||||
|
hasRefreshButton && "max-w-48",
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ export default function InputComponent({
|
||||||
popoverWidth,
|
popoverWidth,
|
||||||
commandWidth,
|
commandWidth,
|
||||||
blockAddNewGlobalVariable = false,
|
blockAddNewGlobalVariable = false,
|
||||||
|
hasRefreshButton = false,
|
||||||
}: InputComponentType): JSX.Element {
|
}: InputComponentType): JSX.Element {
|
||||||
const [pwdVisible, setPwdVisible] = useState(false);
|
const [pwdVisible, setPwdVisible] = useState(false);
|
||||||
const refInput = useRef<HTMLInputElement>(null);
|
const refInput = useRef<HTMLInputElement>(null);
|
||||||
|
|
@ -155,6 +156,7 @@ export default function InputComponent({
|
||||||
popoverWidth={popoverWidth}
|
popoverWidth={popoverWidth}
|
||||||
commandWidth={commandWidth}
|
commandWidth={commandWidth}
|
||||||
blockAddNewGlobalVariable={blockAddNewGlobalVariable}
|
blockAddNewGlobalVariable={blockAddNewGlobalVariable}
|
||||||
|
hasRefreshButton={hasRefreshButton}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import {
|
||||||
import GeneralDeleteConfirmationModal from "@/shared/components/delete-confirmation-modal";
|
import GeneralDeleteConfirmationModal from "@/shared/components/delete-confirmation-modal";
|
||||||
import GeneralGlobalVariableModal from "@/shared/components/global-variable-modal";
|
import GeneralGlobalVariableModal from "@/shared/components/global-variable-modal";
|
||||||
import { useGlobalVariablesStore } from "@/stores/globalVariablesStore/globalVariables";
|
import { useGlobalVariablesStore } from "@/stores/globalVariablesStore/globalVariables";
|
||||||
import { useEffect } from "react";
|
import { useEffect, useMemo } from "react";
|
||||||
import DeleteConfirmationModal from "../../../../../modals/deleteConfirmationModal";
|
import DeleteConfirmationModal from "../../../../../modals/deleteConfirmationModal";
|
||||||
import useAlertStore from "../../../../../stores/alertStore";
|
import useAlertStore from "../../../../../stores/alertStore";
|
||||||
import { cn } from "../../../../../utils/utils";
|
import { cn } from "../../../../../utils/utils";
|
||||||
|
|
@ -27,6 +27,7 @@ export default function InputGlobalComponent({
|
||||||
editNode = false,
|
editNode = false,
|
||||||
placeholder,
|
placeholder,
|
||||||
isToolMode = false,
|
isToolMode = false,
|
||||||
|
hasRefreshButton = false,
|
||||||
}: InputProps<string, InputGlobalComponentType>): JSX.Element {
|
}: InputProps<string, InputGlobalComponentType>): JSX.Element {
|
||||||
const { data: globalVariables } = useGetGlobalVariables();
|
const { data: globalVariables } = useGetGlobalVariables();
|
||||||
const unavailableFields = useGlobalVariablesStore(
|
const unavailableFields = useGlobalVariablesStore(
|
||||||
|
|
@ -115,6 +116,7 @@ export default function InputGlobalComponent({
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
isToolMode={isToolMode}
|
isToolMode={isToolMode}
|
||||||
|
hasRefreshButton={hasRefreshButton}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ export function StrRenderComponent({
|
||||||
<DropdownComponent
|
<DropdownComponent
|
||||||
{...baseInputProps}
|
{...baseInputProps}
|
||||||
dialogInputs={templateData.dialog_inputs}
|
dialogInputs={templateData.dialog_inputs}
|
||||||
options={templateData.options}
|
options={templateData.options ?? []}
|
||||||
optionsMetaData={templateData.options_metadata}
|
optionsMetaData={templateData.options_metadata}
|
||||||
combobox={templateData.combobox}
|
combobox={templateData.combobox}
|
||||||
name={templateData?.name!}
|
name={templateData?.name!}
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ export function ParameterRenderComponent({
|
||||||
isToolMode,
|
isToolMode,
|
||||||
nodeId,
|
nodeId,
|
||||||
nodeInformationMetadata,
|
nodeInformationMetadata,
|
||||||
|
hasRefreshButton: templateData.refresh_button,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (TEXT_FIELD_TYPES.includes(templateData.type ?? "")) {
|
if (TEXT_FIELD_TYPES.includes(templateData.type ?? "")) {
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ export type BaseInputProps<valueType = any> = {
|
||||||
metadata?: any;
|
metadata?: any;
|
||||||
nodeId?: string;
|
nodeId?: string;
|
||||||
nodeInformationMetadata?: NodeInfoType;
|
nodeInformationMetadata?: NodeInfoType;
|
||||||
|
hasRefreshButton?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Generic type for composing input props
|
// Generic type for composing input props
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ export type InputComponentType = {
|
||||||
popoverWidth?: string;
|
popoverWidth?: string;
|
||||||
commandWidth?: string;
|
commandWidth?: string;
|
||||||
blockAddNewGlobalVariable?: boolean;
|
blockAddNewGlobalVariable?: boolean;
|
||||||
|
hasRefreshButton?: boolean;
|
||||||
};
|
};
|
||||||
export type DropDownComponent = {
|
export type DropDownComponent = {
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue