From b32c02671d3932e52f1ec0c2e246930c2e796d23 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Wed, 5 Jun 2024 15:46:52 -0300 Subject: [PATCH] add hsitory tab section to playground --- src/frontend/src/modals/IOModal/index.tsx | 337 +++++++++++----------- 1 file changed, 173 insertions(+), 164 deletions(-) diff --git a/src/frontend/src/modals/IOModal/index.tsx b/src/frontend/src/modals/IOModal/index.tsx index 001ea4b9e..2bac1f2cb 100644 --- a/src/frontend/src/modals/IOModal/index.tsx +++ b/src/frontend/src/modals/IOModal/index.tsx @@ -19,7 +19,7 @@ import { InputOutput } from "../../constants/enums"; import useFlowStore from "../../stores/flowStore"; import useFlowsManagerStore from "../../stores/flowsManagerStore"; import { IOModalPropsType } from "../../types/components"; -import { NodeType } from "../../types/flow"; +import { NodeDataType, NodeType } from "../../types/flow"; import { updateVerticesOrder } from "../../utils/buildUtils"; import { cn } from "../../utils/utils"; import BaseModal from "../baseModal"; @@ -113,13 +113,17 @@ export default function IOModal({ setSelectedTab(inputs.length > 0 ? 1 : outputs.length > 0 ? 2 : 0); }, [allNodes.length]); + const flow_sessions = allNodes + .map((node) => (node.data as NodeDataType).node?.template["session_id"]) + .filter((session) => session !== undefined); + useEffect(() => { setSelectedViewField(startView()); - // if (haveChat) { - // getSessions().then((sessions) => { - // setSessions(sessions); - // }); - // } + if (haveChat) { + getSessions().then((sessions) => { + setSessions(sessions); + }); + } }, [open]); return ( @@ -144,175 +148,180 @@ export default function IOModal({
- {selectedTab !== 0 && ( -
+ { + setSelectedTab(Number(value)); + }} > - { - setSelectedTab(Number(value)); - }} - > -
- - {inputs.length > 0 && ( - Inputs - )} - {outputs.length > 0 && ( - Outputs - )} - {/* {haveChat && ( - History - )} */} - -
+
+ + {inputs.length > 0 && ( + Inputs + )} + {outputs.length > 0 && ( + Outputs + )} + {haveChat && History} + +
- -
- - {TEXT_INPUT_MODAL_TITLE} -
- {nodes - .filter((node) => - inputs.some((input) => input.id === node.id), - ) - .map((node, index) => { - const input = inputs.find( - (input) => input.id === node.id, - )!; - return ( -
- - -
- - {node.data.node.display_name} - -
-
-
{ - event.stopPropagation(); - setSelectedViewField(input); - }} - > - + + {nodes + .filter((node) => + inputs.some((input) => input.id === node.id), + ) + .map((node, index) => { + const input = inputs.find( + (input) => input.id === node.id, + )!; + return ( +
+ + +
+ + {node.data.node.display_name} +
-
- } - key={index} - keyValue={input.id} - > -
-
- {input && ( - - )} + +
{ + event.stopPropagation(); + setSelectedViewField(input); + }} + > +
- -
- ); - })} -
- -
- - {OUTPUTS_MODAL_TITLE} -
- {nodes - .filter((node) => - outputs.some((output) => output.id === node.id), - ) - .map((node, index) => { - const output = outputs.find( - (output) => output.id === node.id, - )!; - return ( -
- - -
- - {node.data.node.display_name} - -
-
-
{ - event.stopPropagation(); - setSelectedViewField(output); - }} - > - +
+
+ {input && ( + + )} +
+
+ +
+ ); + })} + + + {nodes + .filter((node) => + outputs.some((output) => output.id === node.id), + ) + .map((node, index) => { + const output = outputs.find( + (output) => output.id === node.id, + )!; + return ( +
+ + +
+ + {node.data.node.display_name} +
-
- } - key={index} - keyValue={output.id} - > -
-
- {output && ( - - )} + +
{ + event.stopPropagation(); + setSelectedViewField(output); + }} + > +
- + } + key={index} + keyValue={output.id} + > +
+
+ {output && ( + + )} +
+
+ +
+ ); + })} +
+ + {sessions.map((session, index) => { + return ( +
+ {session} +
+ +
+ +
+
- ); - })} - - -
- )} - +
+
+ ); + })} +
+ +
{selectedViewField && (