feat: Add 'isToolMode' prop for enhanced tool mode support (#4483)
* fix: update getIconName function to support optional parameters and add tool mode handling * Add 'isToolMode' prop to components for tool mode support - Introduced 'isToolMode' prop across various components to enable tool mode functionality. - Updated icon logic in textAreaComponent to use 'getIconName' with 'isToolMode'. - Passed 'isToolMode' prop through parameterRenderComponent and related components. - Adjusted inputGlobalComponent and NodeInputField to handle 'isToolMode' for conditional rendering. --------- Co-authored-by: anovazzi1 <otavio2204@gmail.com>
This commit is contained in:
parent
69a1c16e82
commit
6ace83198b
10 changed files with 26 additions and 6 deletions
|
|
@ -184,6 +184,7 @@ export default function NodeInputField({
|
||||||
nodeClass={data.node!}
|
nodeClass={data.node!}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
placeholder={isToolMode ? DEFAULT_TOOLSET_PLACEHOLDER : undefined}
|
placeholder={isToolMode ? DEFAULT_TOOLSET_PLACEHOLDER : undefined}
|
||||||
|
isToolMode={isToolMode}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
export const getIconName = (
|
export const getIconName = (
|
||||||
disabled: boolean,
|
disabled?: boolean,
|
||||||
selectedOption: string,
|
selectedOption?: string,
|
||||||
optionsIcon: string,
|
optionsIcon?: string,
|
||||||
nodeStyle: boolean,
|
nodeStyle?: boolean,
|
||||||
|
isToolMode?: boolean,
|
||||||
) => {
|
) => {
|
||||||
|
if (isToolMode) return "Hammer";
|
||||||
if (disabled) return "lock";
|
if (disabled) return "lock";
|
||||||
if (selectedOption && nodeStyle) return "GlobeOkIcon";
|
if (selectedOption && nodeStyle) return "GlobeOkIcon";
|
||||||
return optionsIcon;
|
return optionsIcon;
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ export default function InputComponent({
|
||||||
name,
|
name,
|
||||||
onChangeFolderName,
|
onChangeFolderName,
|
||||||
nodeStyle,
|
nodeStyle,
|
||||||
|
isToolMode,
|
||||||
}: 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);
|
||||||
|
|
@ -183,6 +184,7 @@ export default function InputComponent({
|
||||||
selectedOption!,
|
selectedOption!,
|
||||||
optionsIcon,
|
optionsIcon,
|
||||||
nodeStyle!,
|
nodeStyle!,
|
||||||
|
isToolMode!,
|
||||||
)}
|
)}
|
||||||
className={cn(
|
className={cn(
|
||||||
disabled ? "cursor-grab text-placeholder" : "cursor-pointer",
|
disabled ? "cursor-grab text-placeholder" : "cursor-pointer",
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ export default function InputGlobalComponent({
|
||||||
password,
|
password,
|
||||||
editNode = false,
|
editNode = false,
|
||||||
placeholder,
|
placeholder,
|
||||||
|
isToolMode = false,
|
||||||
}: InputProps<string, InputGlobalComponentType>): JSX.Element {
|
}: InputProps<string, InputGlobalComponentType>): JSX.Element {
|
||||||
const setErrorData = useAlertStore((state) => state.setErrorData);
|
const setErrorData = useAlertStore((state) => state.setErrorData);
|
||||||
|
|
||||||
|
|
@ -137,6 +138,7 @@ export default function InputGlobalComponent({
|
||||||
{ skipSnapshot },
|
{ skipSnapshot },
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
|
isToolMode={isToolMode}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,8 @@ export function StrRenderComponent({
|
||||||
placeholder,
|
placeholder,
|
||||||
...baseInputProps
|
...baseInputProps
|
||||||
}: InputProps<string, StrRenderComponentType>) {
|
}: InputProps<string, StrRenderComponentType>) {
|
||||||
const { handleOnNewValue, id, disabled, editNode, value } = baseInputProps;
|
const { handleOnNewValue, id, disabled, editNode, value, isToolMode } =
|
||||||
|
baseInputProps;
|
||||||
|
|
||||||
if (!templateData.options) {
|
if (!templateData.options) {
|
||||||
return templateData.multiline ? (
|
return templateData.multiline ? (
|
||||||
|
|
@ -25,6 +26,7 @@ export function StrRenderComponent({
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
id={`textarea_${id}`}
|
id={`textarea_${id}`}
|
||||||
|
isToolMode={isToolMode}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<InputGlobalComponent
|
<InputGlobalComponent
|
||||||
|
|
@ -33,6 +35,7 @@ export function StrRenderComponent({
|
||||||
load_from_db={templateData.load_from_db}
|
load_from_db={templateData.load_from_db}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
id={"input-" + name}
|
id={"input-" + name}
|
||||||
|
isToolMode={isToolMode}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { getIconName } from "@/components/inputComponent/components/helpers/get-icon-name";
|
||||||
import { GRADIENT_CLASS } from "@/constants/constants";
|
import { GRADIENT_CLASS } from "@/constants/constants";
|
||||||
import ComponentTextModal from "@/modals/textAreaModal";
|
import ComponentTextModal from "@/modals/textAreaModal";
|
||||||
import { useRef, useState } from "react";
|
import { useRef, useState } from "react";
|
||||||
|
|
@ -59,6 +60,7 @@ export default function TextAreaComponent({
|
||||||
updateVisibility,
|
updateVisibility,
|
||||||
password,
|
password,
|
||||||
placeholder,
|
placeholder,
|
||||||
|
isToolMode = false,
|
||||||
}: InputProps<string, TextAreaComponentType>): JSX.Element {
|
}: InputProps<string, TextAreaComponentType>): JSX.Element {
|
||||||
const inputRef = useRef<HTMLInputElement>(null);
|
const inputRef = useRef<HTMLInputElement>(null);
|
||||||
const [isFocused, setIsFocused] = useState(false);
|
const [isFocused, setIsFocused] = useState(false);
|
||||||
|
|
@ -106,7 +108,7 @@ export default function TextAreaComponent({
|
||||||
|
|
||||||
<IconComponent
|
<IconComponent
|
||||||
dataTestId={`button_open_text_area_modal_${id}${editNode ? "_advanced" : ""}`}
|
dataTestId={`button_open_text_area_modal_${id}${editNode ? "_advanced" : ""}`}
|
||||||
name={disabled ? "lock" : "Scan"}
|
name={getIconName(disabled, "", "", false, isToolMode) || "Scan"}
|
||||||
className={cn(
|
className={cn(
|
||||||
"cursor-pointer bg-background",
|
"cursor-pointer bg-background",
|
||||||
externalLinkIconClasses.icon,
|
externalLinkIconClasses.icon,
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ export function ParameterRenderComponent({
|
||||||
nodeClass,
|
nodeClass,
|
||||||
disabled,
|
disabled,
|
||||||
placeholder,
|
placeholder,
|
||||||
|
isToolMode,
|
||||||
}: {
|
}: {
|
||||||
handleOnNewValue: handleOnNewValueType;
|
handleOnNewValue: handleOnNewValueType;
|
||||||
name: string;
|
name: string;
|
||||||
|
|
@ -42,6 +43,7 @@ export function ParameterRenderComponent({
|
||||||
nodeClass: APIClassType;
|
nodeClass: APIClassType;
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
|
isToolMode?: boolean;
|
||||||
}) {
|
}) {
|
||||||
const id = (
|
const id = (
|
||||||
templateData.type +
|
templateData.type +
|
||||||
|
|
@ -61,6 +63,7 @@ export function ParameterRenderComponent({
|
||||||
handleNodeClass,
|
handleNodeClass,
|
||||||
readonly: templateData.readonly,
|
readonly: templateData.readonly,
|
||||||
placeholder,
|
placeholder,
|
||||||
|
isToolMode,
|
||||||
};
|
};
|
||||||
if (TEXT_FIELD_TYPES.includes(templateData.type ?? "")) {
|
if (TEXT_FIELD_TYPES.includes(templateData.type ?? "")) {
|
||||||
if (templateData.list) {
|
if (templateData.list) {
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ export type BaseInputProps<valueType = any> = {
|
||||||
handleNodeClass?: (value: any, code?: string, type?: string) => void;
|
handleNodeClass?: (value: any, code?: string, type?: string) => void;
|
||||||
readonly?: boolean;
|
readonly?: boolean;
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
|
isToolMode?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Generic type for composing input props
|
// Generic type for composing input props
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ export function CustomParameterComponent({
|
||||||
nodeClass,
|
nodeClass,
|
||||||
disabled,
|
disabled,
|
||||||
placeholder,
|
placeholder,
|
||||||
|
isToolMode,
|
||||||
}: {
|
}: {
|
||||||
handleOnNewValue: handleOnNewValueType;
|
handleOnNewValue: handleOnNewValueType;
|
||||||
name: string;
|
name: string;
|
||||||
|
|
@ -25,6 +26,7 @@ export function CustomParameterComponent({
|
||||||
nodeClass: APIClassType;
|
nodeClass: APIClassType;
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
|
isToolMode?: boolean;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<ParameterRenderComponent
|
<ParameterRenderComponent
|
||||||
|
|
@ -38,6 +40,7 @@ export function CustomParameterComponent({
|
||||||
nodeClass={nodeClass}
|
nodeClass={nodeClass}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
|
isToolMode={isToolMode}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ export type InputComponentType = {
|
||||||
isObjectOption?: boolean;
|
isObjectOption?: boolean;
|
||||||
onChangeFolderName?: (e: any) => void;
|
onChangeFolderName?: (e: any) => void;
|
||||||
nodeStyle?: boolean;
|
nodeStyle?: boolean;
|
||||||
|
isToolMode?: boolean;
|
||||||
};
|
};
|
||||||
export type DropDownComponent = {
|
export type DropDownComponent = {
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue