diff --git a/src/frontend/package-lock.json b/src/frontend/package-lock.json index 74e5994a7..5a0a618c5 100644 --- a/src/frontend/package-lock.json +++ b/src/frontend/package-lock.json @@ -6655,9 +6655,9 @@ } }, "node_modules/framer-motion": { - "version": "11.1.5", - "resolved": "https://registry.npmjs.org/framer-motion/-/framer-motion-11.1.5.tgz", - "integrity": "sha512-ogK5fc0GBUT3AjzMXPx7f74m5V1ByRqkKQARBVHpdkYTNDxb/WriANYD+5JBo1wklQQJ1HayDZtmofQLqZFcbw==", + "version": "11.1.7", + "resolved": "https://registry.npmjs.org/framer-motion/-/framer-motion-11.1.7.tgz", + "integrity": "sha512-cW11Pu53eDAXUEhv5hEiWuIXWhfkbV32PlgVISn7jRdcAiVrJ1S03YQQ0/DzoswGYYwKi4qYmHHjCzAH52eSdQ==", "dependencies": { "tslib": "^2.4.0" }, diff --git a/src/frontend/src/modals/IOModal/components/chatView/chatMessage/index.tsx b/src/frontend/src/modals/IOModal/components/chatView/chatMessage/index.tsx index 93a0db3c3..39f754ff4 100644 --- a/src/frontend/src/modals/IOModal/components/chatView/chatMessage/index.tsx +++ b/src/frontend/src/modals/IOModal/components/chatView/chatMessage/index.tsx @@ -235,7 +235,7 @@ dark:prose-invert" }, ]} activeTab={"0"} - setActiveTab={() => {}} + setActiveTab={() => { }} /> ) : ( @@ -251,21 +251,6 @@ dark:prose-invert" [chat.message, chatMessage] )} - {chat.files && ( -
- {chat.files.map((file, index) => { - return ( -
- -
- ); - })} -
- )} @@ -292,33 +277,33 @@ dark:prose-invert" {promptOpen ? template?.split("\n")?.map((line, index) => { - const regex = /{([^}]+)}/g; - let match; - let parts: Array = []; - let lastIndex = 0; - while ((match = regex.exec(line)) !== null) { - // Push text up to the match - if (match.index !== lastIndex) { - parts.push(line.substring(lastIndex, match.index)); - } - // Push div with matched text - if (chat.message[match[1]]) { - parts.push( - - {chat.message[match[1]]} - - ); - } + const regex = /{([^}]+)}/g; + let match; + let parts: Array = []; + let lastIndex = 0; + while ((match = regex.exec(line)) !== null) { + // Push text up to the match + if (match.index !== lastIndex) { + parts.push(line.substring(lastIndex, match.index)); + } + // Push div with matched text + if (chat.message[match[1]]) { + parts.push( + + {chat.message[match[1]]} + + ); + } - // Update last index - lastIndex = regex.lastIndex; - } - // Push text after the last match - if (lastIndex !== line.length) { - parts.push(line.substring(lastIndex)); - } - return

{parts}

; - }) + // Update last index + lastIndex = regex.lastIndex; + } + // Push text after the last match + if (lastIndex !== line.length) { + parts.push(line.substring(lastIndex)); + } + return

{parts}

; + }) : chatMessage}
@@ -335,6 +320,21 @@ dark:prose-invert" )}
+ {chat.files && ( +
+ {chat.files.map((file, index) => { + return ( +
+ +
+ ); + })} +
+ )} ); } diff --git a/src/frontend/src/modals/IOModal/components/chatView/fileComponent/index.tsx b/src/frontend/src/modals/IOModal/components/chatView/fileComponent/index.tsx index 408e741c2..62b4a8071 100644 --- a/src/frontend/src/modals/IOModal/components/chatView/fileComponent/index.tsx +++ b/src/frontend/src/modals/IOModal/components/chatView/fileComponent/index.tsx @@ -2,6 +2,10 @@ import * as base64js from "base64-js"; import { useState } from "react"; import IconComponent from "../../../../../components/genericIconComponent"; import { fileCardPropsType } from "../../../../../types/components"; +import useFlowsManagerStore from "../../../../../stores/flowsManagerStore"; +import { BACKEND_URL, BASE_URL_API } from "../../../../../constants/constants"; + +const imgTypes = new Set(["png", "jpg"]); export default function FileCard({ fileName, @@ -9,18 +13,10 @@ export default function FileCard({ fileType, }: fileCardPropsType): JSX.Element { const handleDownload = (): void => { - const byteArray = new Uint8Array(base64js.toByteArray(content)); - const blob = new Blob([byteArray], { type: "application/octet-stream" }); - const url = URL.createObjectURL(blob); - const link = document.createElement("a"); - link.href = url; - link.download = fileName + ".png"; - document.body.appendChild(link); - link.click(); - document.body.removeChild(link); - URL.revokeObjectURL(url); + //TODO: update download function }; const [isHovered, setIsHovered] = useState(false); + const currentFlowId = useFlowsManagerStore((state) => state.currentFlowId); function handleMouseEnter(): void { setIsHovered(true); } @@ -28,7 +24,7 @@ export default function FileCard({ setIsHovered(false); } - if (fileType === "image") { + if (imgTypes.has(fileType)) { return (
generated image {isHovered && ( @@ -60,10 +56,10 @@ export default function FileCard({ return (