- {myData.node?.template[templateParam].type ===
- "str" &&
- !myData.node.template[templateParam].options ? (
+
- {myData.node.template[templateParam]
+ {myData.node!.template[templateParam]
?.list ? (
{
handleOnNewValue(
value,
- templateParam
+ templateParam,
);
}}
/>
- ) : myData.node.template[templateParam]
+ ) : myData.node!.template[templateParam]
.multiline ? (
{
handleOnNewValue(
value,
- templateParam
+ templateParam,
);
}}
/>
@@ -274,8 +282,13 @@ const EditNodeModal = forwardRef(
/>
)}
- ) : myData.node?.template[templateParam]
- .type === "NestedDict" ? (
+
+
+
- ) : myData.node?.template[templateParam]
- .type === "dict" ? (
+
+
+
1
? "my-3"
- : ""
+ : "",
)}
>
- ) : myData.node?.template[templateParam]
- .type === "bool" ? (
+
+
+
{" "}
{
handleOnNewValue(
isEnabled,
- templateParam
+ templateParam,
);
}}
size="small"
editNode={true}
/>
- ) : myData.node?.template[templateParam]
- .type === "float" ? (
+
+
+
{
@@ -392,32 +416,38 @@ const EditNodeModal = forwardRef(
}}
/>
- ) : myData.node?.template[templateParam]
- .type === "str" &&
- myData.node.template[templateParam]
- .options ? (
+
+
+
handleOnNewValue(value, templateParam)
}
value={
- myData.node.template[templateParam]
+ myData.node!.template[templateParam]
.value ?? "Choose an option"
}
id={
"dropdown-edit-" +
- myData.node.template[templateParam].name
+ myData.node!.template[templateParam]
+ .name
}
>
- ) : myData.node?.template[templateParam]
- .type === "int" ? (
+
+
+
{
@@ -439,21 +470,24 @@ const EditNodeModal = forwardRef(
}}
/>
- ) : myData.node?.template[templateParam]
- .type === "file" ? (
+
+
+
{
handleOnNewValue(value, templateParam);
}}
fileTypes={
- myData.node.template[templateParam]
+ myData.node!.template[templateParam]
.fileTypes
}
onFileChange={(filePath: string) => {
@@ -463,8 +497,11 @@ const EditNodeModal = forwardRef(
}}
>
- ) : myData.node?.template[templateParam]
- .type === "prompt" ? (
+
+
+
{
@@ -486,21 +523,26 @@ const EditNodeModal = forwardRef(
}}
id={
"prompt-area-edit-" +
- myData.node.template[templateParam].name
+ myData.node!.template[templateParam]
+ .name
}
data-testid={
"modal-prompt-input-" +
- myData.node.template[templateParam].name
+ myData.node!.template[templateParam]
+ .name
}
/>
- ) : myData.node?.template[templateParam]
- .type === "code" ? (
+
+
+
{
@@ -524,16 +566,16 @@ const EditNodeModal = forwardRef(
}}
id={
"code-area-edit" +
- myData.node.template[templateParam].name
+ myData.node!.template[templateParam]
+ .name
}
/>
- ) : myData.node?.template[templateParam]
- .type === "Any" ? (
- "-"
- ) : (
-
- )}
+
+
+
+ <>->
+
@@ -588,7 +630,7 @@ const EditNodeModal = forwardRef(
);
- }
+ },
);
export default EditNodeModal;
diff --git a/src/frontend/src/shared/components/caseComponent/index.tsx b/src/frontend/src/shared/components/caseComponent/index.tsx
new file mode 100644
index 000000000..c5330af3d
--- /dev/null
+++ b/src/frontend/src/shared/components/caseComponent/index.tsx
@@ -0,0 +1,15 @@
+import { memo } from "react";
+
+type BooleanLike = boolean | string | number | null | undefined;
+
+type Props = {
+ condition: (() => BooleanLike) | BooleanLike;
+ children: React.ReactNode | any;
+};
+
+export const Case = memo(({ condition, children }: Props) => {
+ const conditionResult =
+ typeof condition === "function" ? condition() : condition;
+
+ return conditionResult ? children : null;
+});
diff --git a/src/frontend/src/types/components/index.ts b/src/frontend/src/types/components/index.ts
index 6b3f9b224..efe7c29a4 100644
--- a/src/frontend/src/types/components/index.ts
+++ b/src/frontend/src/types/components/index.ts
@@ -400,6 +400,7 @@ export type StoreApiKeyType = {
export type groupedObjType = {
family: string;
type: string;
+ display_name?: string;
};
export type nodeGroupedObjType = {
diff --git a/src/frontend/src/utils/reactflowUtils.ts b/src/frontend/src/utils/reactflowUtils.ts
index 65a85960b..66ebea42e 100644
--- a/src/frontend/src/utils/reactflowUtils.ts
+++ b/src/frontend/src/utils/reactflowUtils.ts
@@ -461,7 +461,8 @@ export function getConnectedNodes(
return nodes.filter((node) => node.id === targetId || node.id === sourceId);
}
-export function convertObjToArray(singleObject: object | string) {
+export function convertObjToArray(singleObject: object | string, type: string) {
+ if (type !== "dict") return [{ "": "" }];
if (typeof singleObject === "string") {
singleObject = JSON.parse(singleObject);
}