From 5b000e607837390ccc95ad7ff86b607953a0c7df Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Wed, 21 Feb 2024 21:09:52 +0100 Subject: [PATCH] Changed view to not show chat --- src/frontend/src/components/IOview/index.tsx | 216 ++++++++++-------- .../src/components/chatComponent/index.tsx | 28 +-- src/frontend/src/modals/formModal/index.tsx | 2 +- src/frontend/src/style/applies.css | 3 - 4 files changed, 129 insertions(+), 120 deletions(-) diff --git a/src/frontend/src/components/IOview/index.tsx b/src/frontend/src/components/IOview/index.tsx index c03d32594..2bf8b229b 100644 --- a/src/frontend/src/components/IOview/index.tsx +++ b/src/frontend/src/components/IOview/index.tsx @@ -1,7 +1,10 @@ import { ReactNode, useState } from "react"; +import { CHAT_FORM_DIALOG_SUBTITLE } from "../../constants/constants"; +import BaseModal from "../../modals/baseModal"; import useFlowStore from "../../stores/flowStore"; import { NodeType } from "../../types/flow"; import { isInputType, isOutputType } from "../../utils/reactflowUtils"; +import { cn } from "../../utils/utils"; import AccordionComponent from "../AccordionComponent"; import IOInputField from "../IOInputField"; import IOOutputView from "../IOOutputView"; @@ -10,7 +13,7 @@ import NewChatView from "../newChatView"; import { Badge } from "../ui/badge"; import { Button } from "../ui/button"; -export default function IOView(): JSX.Element { +export default function IOView({ children, open, setOpen }): JSX.Element { const inputs = useFlowStore((state) => state.inputs); const outputs = useFlowStore((state) => state.outputs); const inputIds = inputs.map((obj) => obj.id); @@ -39,7 +42,7 @@ export default function IOView(): JSX.Element { function getCategories() { const categories: CategoriesType[] = []; - if (inputs.length > 0) + if (inputs.filter((input) => input.type !== "ChatInput").length > 0) categories.push({ name: "Inputs", icon: "TextCursorInput" }); if (outputs.filter((output) => output.type !== "ChatOutput").length > 0) categories.push({ name: "Outputs", icon: "TerminalSquare" }); @@ -53,7 +56,7 @@ export default function IOView(): JSX.Element { return ; if (isOutputType(type)) return ; - else return
no view selected
; + else return undefined; } function UpdateAccordion() { @@ -61,96 +64,127 @@ export default function IOView(): JSX.Element { } return ( -
-
-
- {categories.map((category, index) => { - return ( - //hide chat button if chat is alredy on the view - - ); - })} - {(outputs.map((output) => output.type).includes("ChatOutput") || - inputs.map((output) => output.type).includes("chatInput")) && - selectedView.type !== "ChatOutput" && ( - - )} + + {children} + {/* TODO ADAPT TO ALL TYPES OF INPUTS AND OUTPUTS */} + +
+ Chat +
- {UpdateAccordion() - .filter((input) => input.type !== "ChatInput") - .map((input, index) => { - const node: NodeType = nodes.find((node) => node.id === input.id)!; - return ( -
- - - {input.id} - -
{ - event.stopPropagation(); - setSelectedView({ type: input.type, id: input.id }); - }} - > - + + +
+
+
+ {categories.map((category, index) => { + return ( + //hide chat button if chat is alredy on the view + + ); + })} + {(outputs.map((output) => output.type).includes("ChatOutput") || + inputs.map((output) => output.type).includes("chatInput")) && + selectedView.type !== "ChatOutput" && ( + + )} +
+ {UpdateAccordion() + .filter( + (input) => + input.type !== "ChatInput" && input.type !== "ChatOutput" + ) + .map((input, index) => { + const node: NodeType = nodes.find( + (node) => node.id === input.id + )!; + return ( +
+ + + {input.id} + +
{ + event.stopPropagation(); + setSelectedView({ + type: input.type, + id: input.id, + }); + }} + > + +
+
+ } + key={index} + keyValue={input.id} + > +
+ {node && + (categories[selectedCategory].name === "Inputs" ? ( + + ) : ( + + ))}
-
- } - key={index} - keyValue={input.id} - > -
- {node && - (categories[selectedCategory].name === "Inputs" ? ( - - ) : ( - - ))} +
- -
- ); - })} -
- {handleSelectChange()} -
+ ); + })} +
+ {handleSelectChange() && handleSelectChange()} +
+ + ); } diff --git a/src/frontend/src/components/chatComponent/index.tsx b/src/frontend/src/components/chatComponent/index.tsx index 7ac6818bf..43e035b70 100644 --- a/src/frontend/src/components/chatComponent/index.tsx +++ b/src/frontend/src/components/chatComponent/index.tsx @@ -1,12 +1,8 @@ import { useEffect, useRef, useState } from "react"; -import { CHAT_FORM_DIALOG_SUBTITLE } from "../../constants/constants"; -import BaseModal from "../../modals/baseModal"; import useFlowStore from "../../stores/flowStore"; import { ChatType } from "../../types/chat"; import IOView from "../IOview"; import ChatTrigger from "../ViewTriggers/chat"; -import IconComponent from "../genericIconComponent"; -import BuildTrigger from "./buildTrigger"; export default function Chat({ flow }: ChatType): JSX.Element { const [open, setOpen] = useState(false); @@ -38,27 +34,9 @@ export default function Chat({ flow }: ChatType): JSX.Element {
{/* */} {hasIO && ( - - -
setOpen(true)}> - -
-
- {/* TODO ADAPT TO ALL TYPES OF INPUTS AND OUTPUTS */} - -
- Chat -
-
- - - -
+ + + )}
diff --git a/src/frontend/src/modals/formModal/index.tsx b/src/frontend/src/modals/formModal/index.tsx index 80ab8c06b..dfaf871ed 100644 --- a/src/frontend/src/modals/formModal/index.tsx +++ b/src/frontend/src/modals/formModal/index.tsx @@ -439,7 +439,7 @@ export default function FormModal({ {CHAT_FORM_DIALOG_SUBTITLE} -
+