From 3e7c776ccf794844b76bdfa33d836f9729cda1a5 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Sat, 24 Feb 2024 22:19:52 +0100 Subject: [PATCH] Added visual changes, as pin on toolbar and play button separate from status. --- .../src/CustomNodes/GenericNode/index.tsx | 60 +---- .../src/components/IOInputField/index.tsx | 2 +- .../src/components/IOOutputView/index.tsx | 2 +- src/frontend/src/components/IOview/index.tsx | 251 ++++++++++-------- src/frontend/src/constants/constants.ts | 2 +- .../src/modals/genericModal/index.tsx | 2 +- .../components/nodeToolbarComponent/index.tsx | 63 +++-- src/frontend/src/style/applies.css | 2 +- src/frontend/src/utils/styleUtils.ts | 6 + 9 files changed, 210 insertions(+), 180 deletions(-) diff --git a/src/frontend/src/CustomNodes/GenericNode/index.tsx b/src/frontend/src/CustomNodes/GenericNode/index.tsx index c62abf6b9..7464f07f7 100644 --- a/src/frontend/src/CustomNodes/GenericNode/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/index.tsx @@ -120,7 +120,6 @@ export default function GenericNode({ }, [flowPool, data.id]); const showNode = data.showNode ?? true; - const pinned = data.node?.pinned ?? false; const nameEditable = data.node?.flow || data.type === "CustomComponent"; @@ -160,7 +159,7 @@ export default function GenericNode({ const getIconPlayOrPauseComponent = (name, className) => ( ); @@ -193,7 +192,7 @@ export default function GenericNode({ return ; } else { const className = getStatusClassName(buildStatus, validationStatus); - return <>{getIconPlayOrPauseComponent("Play", className)}; + return <>{getIconPlayOrPauseComponent("CircleDot", className)}; } }; @@ -439,39 +438,7 @@ export default function GenericNode({ {showNode && ( - )} - {showNode && ( - )} +
+ {renderIconPlayOrPauseComponents( + data?.build_status, + validationStatus + )} +
diff --git a/src/frontend/src/components/IOInputField/index.tsx b/src/frontend/src/components/IOInputField/index.tsx index c499bd551..0b1afa52d 100644 --- a/src/frontend/src/components/IOInputField/index.tsx +++ b/src/frontend/src/components/IOInputField/index.tsx @@ -63,7 +63,7 @@ export default function IOInputField({ } } return ( -
+
{inputType} {handleInputType()}
diff --git a/src/frontend/src/components/IOOutputView/index.tsx b/src/frontend/src/components/IOOutputView/index.tsx index fdae4b6b3..da37d34ee 100644 --- a/src/frontend/src/components/IOOutputView/index.tsx +++ b/src/frontend/src/components/IOOutputView/index.tsx @@ -44,7 +44,7 @@ export default function IOOutputView({ } } return ( -
+
{outputType} {handleOutputType()}
diff --git a/src/frontend/src/components/IOview/index.tsx b/src/frontend/src/components/IOview/index.tsx index 7e3e24f76..9fc109e21 100644 --- a/src/frontend/src/components/IOview/index.tsx +++ b/src/frontend/src/components/IOview/index.tsx @@ -10,6 +10,7 @@ import IconComponent from "../genericIconComponent"; import NewChatView from "../newChatView"; import { Badge } from "../ui/badge"; import { Button } from "../ui/button"; +import { Tabs, TabsContent, TabsList, TabsTrigger } from "../ui/tabs"; export default function IOView({ children, open, setOpen }): JSX.Element { const inputs = useFlowStore((state) => state.inputs).filter( @@ -67,123 +68,147 @@ export default function IOView({ children, open, setOpen }): JSX.Element { haveChat ? "w-2/6" : "w-full" )} > -
-
- {inputs.length > 0 && ( - - )} - {outputs.length > 0 && ( - - )} + { + setSelectedTab(Number(value)); + }} + > +
+ + {inputs.length > 0 && ( + Inputs + )} + {outputs.length > 0 && ( + Outputs + )} +
- {selectedViewField && haveChat && ( - - )} -
-
- {selectedTab === 1 && ( - <> - + + +
+ Text Inputs - - )} - {selectedTab === 2 && ( - <> - - Prompt Outputs - - )} -
- {nodes - .filter((node) => - selectedTab === 1 - ? inputs.some((input) => input.id === node.id) - : outputs.some((output) => output.id === node.id) - ) - .map((node, index) => { - const input = - selectedTab === 1 - ? inputs.find((input) => input.id === node.id)! - : outputs.find((output) => output.id === node.id)!; - return ( -
- - - {input.id} - - {haveChat && ( -
{ - 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 ( +
+ + + {input.id} + + {haveChat && ( +
{ + event.stopPropagation(); + setSelectedViewField(input); + }} + > + +
+ )}
- )} -
- } - key={index} - keyValue={input.id} - > -
-
- {input && - (selectedTab === 1 ? ( - - ) : ( - - ))} -
+ } + key={index} + keyValue={input.id} + > +
+
+ {input && ( + + )} +
+
+
- -
- ); - })} + ); + })} + + +
+ + Prompt Outputs +
+ {nodes + .filter((node) => + outputs.some((output) => output.id === node.id) + ) + .map((node, index) => { + const output = outputs.find( + (output) => output.id === node.id + )!; + return ( +
+ + + {output.id} + + {haveChat && ( +
{ + event.stopPropagation(); + setSelectedViewField(output); + }} + > + +
+ )} +
+ } + key={index} + keyValue={output.id} + > +
+
+ {output && ( + + )} +
+
+ +
+ ); + })} + +
)} diff --git a/src/frontend/src/constants/constants.ts b/src/frontend/src/constants/constants.ts index b9422efab..c1eaa999d 100644 --- a/src/frontend/src/constants/constants.ts +++ b/src/frontend/src/constants/constants.ts @@ -681,4 +681,4 @@ export const LANGFLOW_SUPPORTED_TYPES = new Set([ export const priorityFields = new Set(["code", "template"]); export const INPUT_TYPES = new Set(["ChatInput", "TextInput"]); -export const OUTPUT_TYPES = new Set(["ChatOutput"]); +export const OUTPUT_TYPES = new Set(["ChatOutput", "PromptTemplate"]); diff --git a/src/frontend/src/modals/genericModal/index.tsx b/src/frontend/src/modals/genericModal/index.tsx index 44173057f..2f7a07905 100644 --- a/src/frontend/src/modals/genericModal/index.tsx +++ b/src/frontend/src/modals/genericModal/index.tsx @@ -255,7 +255,7 @@ export default function GenericModal({ >
diff --git a/src/frontend/src/pages/FlowPage/components/nodeToolbarComponent/index.tsx b/src/frontend/src/pages/FlowPage/components/nodeToolbarComponent/index.tsx index 84013a34f..ff21af45f 100644 --- a/src/frontend/src/pages/FlowPage/components/nodeToolbarComponent/index.tsx +++ b/src/frontend/src/pages/FlowPage/components/nodeToolbarComponent/index.tsx @@ -25,7 +25,7 @@ import { expandGroupNode, updateFlowPosition, } from "../../../../utils/reactflowUtils"; -import { classNames } from "../../../../utils/utils"; +import { classNames, cn } from "../../../../utils/utils"; export default function NodeToolbarComponent({ data, @@ -60,6 +60,7 @@ export default function NodeToolbarComponent({ const isMinimal = numberOfHandles <= 1; const isGroup = data.node?.flow ? true : false; + const pinned = data.node?.pinned ?? false; const paste = useFlowStore((state) => state.paste); const nodes = useFlowStore((state) => state.nodes); const edges = useFlowStore((state) => state.edges); @@ -107,6 +108,9 @@ export default function NodeToolbarComponent({ takeSnapshot(); setShowNode(data.showNode ?? true ? false : true); break; + case "Share": + if (hasApiKey || hasStore) setShowconfirmShare(true); + break; case "Download": downloadNode(flowComponent!); break; @@ -269,22 +273,35 @@ export default function NodeToolbarComponent({ - {hasStore && ( - - - - )} + /> + +