From 8651850803116afc570e871f20f56c83213bcd19 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sat, 30 Mar 2024 17:42:38 -0300 Subject: [PATCH 1/5] Refactor data and helper components --- src/backend/base/langflow/components/data/Directory.py | 2 +- src/backend/base/langflow/components/data/File.py | 2 +- src/backend/base/langflow/components/data/URL.py | 2 +- src/backend/base/langflow/components/helpers/CombineText.py | 1 + src/backend/base/langflow/components/helpers/RecordsToText.py | 1 - src/backend/base/langflow/components/helpers/SearchApi.py | 0 6 files changed, 4 insertions(+), 4 deletions(-) delete mode 100644 src/backend/base/langflow/components/helpers/SearchApi.py diff --git a/src/backend/base/langflow/components/data/Directory.py b/src/backend/base/langflow/components/data/Directory.py index a40e63711..87dc99287 100644 --- a/src/backend/base/langflow/components/data/Directory.py +++ b/src/backend/base/langflow/components/data/Directory.py @@ -9,7 +9,7 @@ class DirectoryComponent(CustomComponent): display_name = "Directory" description = "Recursively load files from a directory." icon = "folder" - + def build_config(self) -> Dict[str, Any]: return { "path": {"display_name": "Path"}, diff --git a/src/backend/base/langflow/components/data/File.py b/src/backend/base/langflow/components/data/File.py index a01d84528..fe3b08066 100644 --- a/src/backend/base/langflow/components/data/File.py +++ b/src/backend/base/langflow/components/data/File.py @@ -10,7 +10,7 @@ class FileComponent(CustomComponent): display_name = "File" description = "A generic file loader." icon = "file-text" - + def build_config(self) -> Dict[str, Any]: return { "paths": { diff --git a/src/backend/base/langflow/components/data/URL.py b/src/backend/base/langflow/components/data/URL.py index 6b9413354..2b286e126 100644 --- a/src/backend/base/langflow/components/data/URL.py +++ b/src/backend/base/langflow/components/data/URL.py @@ -10,7 +10,7 @@ class URLComponent(CustomComponent): display_name = "URL" description = "Fetch content from one or more URLs." icon = "layout-template" - + def build_config(self) -> Dict[str, Any]: return { "urls": {"display_name": "URL"}, diff --git a/src/backend/base/langflow/components/helpers/CombineText.py b/src/backend/base/langflow/components/helpers/CombineText.py index 1f8ac5e13..fcd23c188 100644 --- a/src/backend/base/langflow/components/helpers/CombineText.py +++ b/src/backend/base/langflow/components/helpers/CombineText.py @@ -1,6 +1,7 @@ from langflow.interface.custom.custom_component import CustomComponent from langflow.field_typing import Text + class CombineTextComponent(CustomComponent): display_name = "Combine Text" description = "Concatenate two text sources into a single text chunk using a specified delimiter." diff --git a/src/backend/base/langflow/components/helpers/RecordsToText.py b/src/backend/base/langflow/components/helpers/RecordsToText.py index 1a35c1c80..8f4fed311 100644 --- a/src/backend/base/langflow/components/helpers/RecordsToText.py +++ b/src/backend/base/langflow/components/helpers/RecordsToText.py @@ -7,7 +7,6 @@ from langflow.schema import Record class RecordsToTextComponent(CustomComponent): display_name = "Records To Text" description = "Convert Records into plain text following a specified template." - def build_config(self): return { diff --git a/src/backend/base/langflow/components/helpers/SearchApi.py b/src/backend/base/langflow/components/helpers/SearchApi.py deleted file mode 100644 index e69de29bb..000000000 From fd580b75681fa53b2502aab7bb8ca67ae40d930f Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sat, 30 Mar 2024 17:43:02 -0300 Subject: [PATCH 2/5] Update ESLint configuration --- src/frontend/.eslintrc.json | 59 ++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/src/frontend/.eslintrc.json b/src/frontend/.eslintrc.json index c9ec184fd..682c7fc87 100644 --- a/src/frontend/.eslintrc.json +++ b/src/frontend/.eslintrc.json @@ -1,32 +1,29 @@ { - "extends": [ - "eslint:recommended", - "plugin:node/recommended" - ], - "parserOptions": { - "ecmaVersion": 2018 - }, - "rules": { - "no-console": "warn", - "no-self-assign": "warn", - "no-self-compare":"warn", - "complexity": ["error", { "max": 15 }], - "indent": ["error", 2, { "SwitchCase": 1 }], - "no-dupe-keys": "error", - "no-invalid-regexp": "error", - "no-undef": "error", - "no-return-assign": "error", - "no-redeclare": "error", - "no-empty": "error", - "no-await-in-loop": "error", - "node/exports-style": ["error", "module.exports"], - "node/file-extension-in-import": ["error", "always"], - "node/prefer-global/buffer": ["error", "always"], - "node/prefer-global/console": ["error", "always"], - "node/prefer-global/process": ["error", "always"], - "node/prefer-global/url-search-params": ["error", "always"], - "node/prefer-global/url": ["error", "always"], - "node/prefer-promises/dns": "error", - "node/prefer-promises/fs": "error" - } -} \ No newline at end of file + "extends": ["eslint:recommended", "plugin:node/recommended"], + "parserOptions": { + "ecmaVersion": 2018 + }, + "rules": { + "no-console": "warn", + "no-self-assign": "warn", + "no-self-compare": "warn", + "complexity": ["error", { "max": 15 }], + "indent": ["error", 2, { "SwitchCase": 1 }], + "no-dupe-keys": "error", + "no-invalid-regexp": "error", + "no-undef": "error", + "no-return-assign": "error", + "no-redeclare": "error", + "no-empty": "error", + "no-await-in-loop": "error", + "node/exports-style": ["error", "module.exports"], + "node/file-extension-in-import": ["error", "always"], + "node/prefer-global/buffer": ["error", "always"], + "node/prefer-global/console": ["error", "always"], + "node/prefer-global/process": ["error", "always"], + "node/prefer-global/url-search-params": ["error", "always"], + "node/prefer-global/url": ["error", "always"], + "node/prefer-promises/dns": "error", + "node/prefer-promises/fs": "error" + } +} From e9cb84a933e1d9a5838e902b5b6b732d0dee6ce4 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sat, 30 Mar 2024 17:43:12 -0300 Subject: [PATCH 3/5] Fix formatting issues and update dependencies --- .../components/parameterComponent/index.tsx | 4 +- .../src/CustomNodes/GenericNode/index.tsx | 55 +++++++++++-------- .../src/components/chatComponent/index.tsx | 3 +- .../components/dropdownComponent/index.tsx | 4 +- src/frontend/src/components/ui/button.tsx | 13 ++--- src/frontend/src/constants/enums.ts | 2 +- src/frontend/src/index.tsx | 2 +- .../components/FileInput/index.tsx | 2 +- .../IOModal/components/IOFieldView/index.tsx | 2 +- .../components/chatView/chatInput/index.tsx | 4 +- .../IOModal/components/chatView/index.tsx | 2 +- src/frontend/src/modals/IOModal/index.tsx | 6 +- .../components/NewFlowCardComponent/index.tsx | 7 ++- .../components/undrawCards/index.tsx | 14 +++-- .../src/modals/NewFlowModal/index.tsx | 11 ++-- .../components/PageComponent/index.tsx | 16 +++--- .../extraSidebarComponent/index.tsx | 1 - .../components/nodeToolbarComponent/index.tsx | 34 ++++++------ src/frontend/src/pages/FlowPage/index.tsx | 7 +-- src/frontend/src/pages/MainPage/index.tsx | 5 +- src/frontend/src/stores/flowStore.ts | 2 +- src/frontend/src/types/components/index.ts | 2 +- src/frontend/src/utils/reactflowUtils.ts | 2 +- src/frontend/vite.config.ts | 1 - 24 files changed, 111 insertions(+), 90 deletions(-) diff --git a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx index 041c26fc4..c9b8e901f 100644 --- a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx @@ -402,7 +402,9 @@ export default function ParameterComponent({ {title} )} - + {required ? "*" : ""}
diff --git a/src/frontend/src/CustomNodes/GenericNode/index.tsx b/src/frontend/src/CustomNodes/GenericNode/index.tsx index c9a8e463a..1e8d15451 100644 --- a/src/frontend/src/CustomNodes/GenericNode/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/index.tsx @@ -345,29 +345,40 @@ export default function GenericNode({ return ( { - takeSnapshot(); - deleteNode(id); - }} - setShowNode={(show) => { - setNode(data.id, (old) => ({ - ...old, - data: { ...old.data, showNode: show }, - })); - }} - setShowState={setShowNode} - numberOfHandles={handles} - showNode={showNode} - openAdvancedModal={false} - onCloseAdvancedModal={() => {}} - updateNodeCode={updateNodeCode} - isOutdated={isOutdated} - selected={selected} - /> + data={data} + deleteNode={(id) => { + takeSnapshot(); + deleteNode(id); + }} + setShowNode={(show) => { + setNode(data.id, (old) => ({ + ...old, + data: { ...old.data, showNode: show }, + })); + }} + setShowState={setShowNode} + numberOfHandles={handles} + showNode={showNode} + openAdvancedModal={false} + onCloseAdvancedModal={() => {}} + updateNodeCode={updateNodeCode} + isOutdated={isOutdated} + selected={selected} + /> - ) - }, [data, deleteNode, takeSnapshot, setNode, setShowNode, handles, showNode, updateNodeCode, isOutdated, selected]); + ); + }, [ + data, + deleteNode, + takeSnapshot, + setNode, + setShowNode, + handles, + showNode, + updateNodeCode, + isOutdated, + selected, + ]); return ( <> diff --git a/src/frontend/src/components/chatComponent/index.tsx b/src/frontend/src/components/chatComponent/index.tsx index b387a2ae8..66ff2b609 100644 --- a/src/frontend/src/components/chatComponent/index.tsx +++ b/src/frontend/src/components/chatComponent/index.tsx @@ -1,13 +1,12 @@ import { Transition } from "@headlessui/react"; import { useEffect, useMemo, useRef, useState } from "react"; import ApiModal from "../../modals/ApiModal"; +import IOModal from "../../modals/IOModal"; import ShareModal from "../../modals/shareModal"; import useFlowStore from "../../stores/flowStore"; import useFlowsManagerStore from "../../stores/flowsManagerStore"; import { useStoreStore } from "../../stores/storeStore"; -import { ChatType } from "../../types/chat"; import { classNames } from "../../utils/utils"; -import IOModal from "../../modals/IOModal"; import ForwardedIconComponent from "../genericIconComponent"; import { Separator } from "../ui/separator"; diff --git a/src/frontend/src/components/dropdownComponent/index.tsx b/src/frontend/src/components/dropdownComponent/index.tsx index 729b11a55..e0c0d39cf 100644 --- a/src/frontend/src/components/dropdownComponent/index.tsx +++ b/src/frontend/src/components/dropdownComponent/index.tsx @@ -52,9 +52,9 @@ export default function Dropdown({ editNode ? "input-edit-node" : "py-2" )} > - {(value && + {value && value !== "" && - options.find((option) => option === value)) + options.find((option) => option === value) ? options.find((option) => option === value) : "Choose an option..."} word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) - .join(' '); + .split(" ") + .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) + .join(" "); } const Button = React.forwardRef( - ({ className, variant, size, asChild = false,children, ...props }, ref) => { + ({ className, variant, size, asChild = false, children, ...props }, ref) => { const Comp = asChild ? Slot : "button"; let newChildren = children; - if (typeof(children)==="string"){ - newChildren = toTitleCase(children) + if (typeof children === "string") { + newChildren = toTitleCase(children); } return ( ( ref={ref} children={newChildren} {...props} - /> ); } diff --git a/src/frontend/src/constants/enums.ts b/src/frontend/src/constants/enums.ts index d7d3ac334..2573b5194 100644 --- a/src/frontend/src/constants/enums.ts +++ b/src/frontend/src/constants/enums.ts @@ -18,4 +18,4 @@ export enum BuildStatus { export enum InputOutput { INPUT = "input", OUTPUT = "output", -} \ No newline at end of file +} diff --git a/src/frontend/src/index.tsx b/src/frontend/src/index.tsx index 051908e3b..62e73f091 100644 --- a/src/frontend/src/index.tsx +++ b/src/frontend/src/index.tsx @@ -8,8 +8,8 @@ import "./style/index.css"; // @ts-ignore import "./style/applies.css"; // @ts-ignore -import "./style/classes.css"; import { StrictMode } from "react"; +import "./style/classes.css"; const root = ReactDOM.createRoot( document.getElementById("root") as HTMLElement diff --git a/src/frontend/src/modals/IOModal/components/IOFieldView/components/FileInput/index.tsx b/src/frontend/src/modals/IOModal/components/IOFieldView/components/FileInput/index.tsx index 90bf6e974..935db2644 100644 --- a/src/frontend/src/modals/IOModal/components/IOFieldView/components/FileInput/index.tsx +++ b/src/frontend/src/modals/IOModal/components/IOFieldView/components/FileInput/index.tsx @@ -1,11 +1,11 @@ import { Button } from "../../../../../../components/ui/button"; import { useEffect, useState } from "react"; +import IconComponent from "../../../../../../components/genericIconComponent"; import { BASE_URL_API } from "../../../../../../constants/constants"; import { uploadFile } from "../../../../../../controllers/API"; import useFlowsManagerStore from "../../../../../../stores/flowsManagerStore"; import { IOFileInputProps } from "../../../../../../types/components"; -import IconComponent from "../../../../../../components/genericIconComponent"; export default function IOFileInput({ field, updateValue }: IOFileInputProps) { //component to handle file upload from chatIO diff --git a/src/frontend/src/modals/IOModal/components/IOFieldView/index.tsx b/src/frontend/src/modals/IOModal/components/IOFieldView/index.tsx index cbb81cc0e..25f9deeaa 100644 --- a/src/frontend/src/modals/IOModal/components/IOFieldView/index.tsx +++ b/src/frontend/src/modals/IOModal/components/IOFieldView/index.tsx @@ -1,9 +1,9 @@ import { cloneDeep } from "lodash"; +import { Textarea } from "../../../../components/ui/textarea"; import { InputOutput } from "../../../../constants/enums"; import useFlowStore from "../../../../stores/flowStore"; import { IOFieldViewProps } from "../../../../types/components"; import IOFileInput from "./components/FileInput"; -import { Textarea } from "../../../../components/ui/textarea"; export default function IOFieldView({ type, diff --git a/src/frontend/src/modals/IOModal/components/chatView/chatInput/index.tsx b/src/frontend/src/modals/IOModal/components/chatView/chatInput/index.tsx index fd9baa39e..30d609f8c 100644 --- a/src/frontend/src/modals/IOModal/components/chatView/chatInput/index.tsx +++ b/src/frontend/src/modals/IOModal/components/chatView/chatInput/index.tsx @@ -25,7 +25,6 @@ export default function ChatInput({ } }, [lockChat, inputRef]); - useEffect(() => { if (inputRef.current) { inputRef.current.style.height = "inherit"; // Reset the height @@ -42,7 +41,8 @@ export default function ChatInput({ event.key === "Enter" && !lockChat && !saveLoading && - !event.shiftKey && !event.nativeEvent.isComposing + !event.shiftKey && + !event.nativeEvent.isComposing ) { sendMessage(repeat); } diff --git a/src/frontend/src/modals/IOModal/components/chatView/index.tsx b/src/frontend/src/modals/IOModal/components/chatView/index.tsx index f439fe283..e655f22a5 100644 --- a/src/frontend/src/modals/IOModal/components/chatView/index.tsx +++ b/src/frontend/src/modals/IOModal/components/chatView/index.tsx @@ -15,10 +15,10 @@ import { ChatOutputType, FlowPoolObjectType, } from "../../../../types/chat"; +import { chatViewProps } from "../../../../types/components"; import { classNames } from "../../../../utils/utils"; import ChatInput from "./chatInput"; import ChatMessage from "./chatMessage"; -import { chatViewProps } from "../../../../types/components"; export default function ChatView({ sendMessage, diff --git a/src/frontend/src/modals/IOModal/index.tsx b/src/frontend/src/modals/IOModal/index.tsx index 30a753ecf..e5b1c885c 100644 --- a/src/frontend/src/modals/IOModal/index.tsx +++ b/src/frontend/src/modals/IOModal/index.tsx @@ -1,9 +1,7 @@ import { useEffect, useState } from "react"; import AccordionComponent from "../../components/AccordionComponent"; -import IOFieldView from "./components/IOFieldView"; import ShadTooltip from "../../components/ShadTooltipComponent"; import IconComponent from "../../components/genericIconComponent"; -import ChatView from "./components/chatView"; import { Badge } from "../../components/ui/badge"; import { Button } from "../../components/ui/button"; import { @@ -20,11 +18,13 @@ import { 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 { updateVerticesOrder } from "../../utils/buildUtils"; import { cn } from "../../utils/utils"; import BaseModal from "../baseModal"; -import { IOModalPropsType } from "../../types/components"; +import IOFieldView from "./components/IOFieldView"; +import ChatView from "./components/chatView"; export default function IOModal({ children, diff --git a/src/frontend/src/modals/NewFlowModal/components/NewFlowCardComponent/index.tsx b/src/frontend/src/modals/NewFlowModal/components/NewFlowCardComponent/index.tsx index bbc6e6111..8fbd8ab8f 100644 --- a/src/frontend/src/modals/NewFlowModal/components/NewFlowCardComponent/index.tsx +++ b/src/frontend/src/modals/NewFlowModal/components/NewFlowCardComponent/index.tsx @@ -1,6 +1,11 @@ import { useNavigate } from "react-router-dom"; +import { + Card, + CardContent, + CardDescription, + CardTitle, +} from "../../../../components/ui/card"; import useFlowsManagerStore from "../../../../stores/flowsManagerStore"; -import { Card, CardContent, CardDescription, CardTitle } from "../../../../components/ui/card"; export default function NewFlowCardComponent() { const addFlow = useFlowsManagerStore((state) => state.addFlow); diff --git a/src/frontend/src/modals/NewFlowModal/components/undrawCards/index.tsx b/src/frontend/src/modals/NewFlowModal/components/undrawCards/index.tsx index aeed1351e..a98413dcb 100644 --- a/src/frontend/src/modals/NewFlowModal/components/undrawCards/index.tsx +++ b/src/frontend/src/modals/NewFlowModal/components/undrawCards/index.tsx @@ -10,13 +10,19 @@ import { ReactComponent as ChatWithHistory } from "../../../../assets/undraw_mob import { ReactComponent as Assistant } from "../../../../assets/undraw_team_collaboration_re_ow29.svg"; //@ts-ignore import { ReactComponent as APIRequest } from "../../../../assets/undraw_real_time_analytics_re_yliv.svg"; +import { + Card, + CardContent, + CardDescription, + CardTitle, +} from "../../../../components/ui/card"; import useFlowsManagerStore from "../../../../stores/flowsManagerStore"; -import { FlowType } from "../../../../types/flow"; -import { updateIds } from "../../../../utils/reactflowUtils"; -import { Card, CardContent, CardDescription, CardTitle } from "../../../../components/ui/card"; import { UndrawCardComponentProps } from "../../../../types/components"; +import { updateIds } from "../../../../utils/reactflowUtils"; -export default function UndrawCardComponent({ flow }: UndrawCardComponentProps): JSX.Element { +export default function UndrawCardComponent({ + flow, +}: UndrawCardComponentProps): JSX.Element { const addFlow = useFlowsManagerStore((state) => state.addFlow); const navigate = useNavigate(); diff --git a/src/frontend/src/modals/NewFlowModal/index.tsx b/src/frontend/src/modals/NewFlowModal/index.tsx index d318475c3..5ad736247 100644 --- a/src/frontend/src/modals/NewFlowModal/index.tsx +++ b/src/frontend/src/modals/NewFlowModal/index.tsx @@ -1,10 +1,13 @@ +import useFlowsManagerStore from "../../stores/flowsManagerStore"; +import { newFlowModalPropsType } from "../../types/components"; +import BaseModal from "../baseModal"; import NewFlowCardComponent from "./components/NewFlowCardComponent"; import UndrawCardComponent from "./components/undrawCards"; -import useFlowsManagerStore from "../../stores/flowsManagerStore"; -import BaseModal from "../baseModal"; -import { newFlowModalPropsType } from "../../types/components"; -export default function NewFlowModal({ open, setOpen }: newFlowModalPropsType): JSX.Element { +export default function NewFlowModal({ + open, + setOpen, +}: newFlowModalPropsType): JSX.Element { const examples = useFlowsManagerStore((state) => state.examples); return ( diff --git a/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx b/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx index 19f245dd5..32dc23f89 100644 --- a/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx +++ b/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx @@ -12,7 +12,6 @@ import ReactFlow, { updateEdge, } from "reactflow"; import GenericNode from "../../../../CustomNodes/GenericNode"; -import FlowToolbar from "../../../../components/chatComponent"; import { INVALID_SELECTION_ERROR_ALERT, UPLOAD_ALERT_LIST, @@ -58,8 +57,9 @@ export default function Page({ const templates = useTypesStore((state) => state.templates); const setFilterEdge = useFlowStore((state) => state.setFilterEdge); const reactFlowWrapper = useRef(null); - const [showCanvas, setSHowCanvas] = useState(Object.keys(templates).length > 0 && - Object.keys(types).length > 0) + const [showCanvas, setSHowCanvas] = useState( + Object.keys(templates).length > 0 && Object.keys(types).length > 0 + ); const reactFlowInstance = useFlowStore((state) => state.reactFlowInstance); const setReactFlowInstance = useFlowStore( @@ -273,8 +273,10 @@ export default function Page({ }, []); useEffect(() => { - setSHowCanvas(Object.keys(templates).length > 0 && Object.keys(types).length > 0) - }, [templates, types]) + setSHowCanvas( + Object.keys(templates).length > 0 && Object.keys(types).length > 0 + ); + }, [templates, types]); const onConnectMod = useCallback( (params: Connection) => { @@ -437,7 +439,6 @@ export default function Page({ } return ( -
{showCanvas ? (
@@ -491,8 +492,7 @@ export default function Page({
) : ( <> - )} + )}
- ); } diff --git a/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx b/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx index 43cbc0137..9b057fde7 100644 --- a/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx +++ b/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx @@ -1,7 +1,6 @@ import { cloneDeep } from "lodash"; import { LinkIcon, SparklesIcon } from "lucide-react"; import { useEffect, useMemo, useState } from "react"; -import AccordionComponent from "../../../../components/AccordionComponent"; import ShadTooltip from "../../../../components/ShadTooltipComponent"; import IconComponent from "../../../../components/genericIconComponent"; import { Input } from "../../../../components/ui/input"; diff --git a/src/frontend/src/pages/FlowPage/components/nodeToolbarComponent/index.tsx b/src/frontend/src/pages/FlowPage/components/nodeToolbarComponent/index.tsx index 763211e32..c507a541f 100644 --- a/src/frontend/src/pages/FlowPage/components/nodeToolbarComponent/index.tsx +++ b/src/frontend/src/pages/FlowPage/components/nodeToolbarComponent/index.tsx @@ -631,22 +631,24 @@ export default function NodeToolbarComponent({ )} {hasCode && (
- {openModal&& } + {openModal && ( + + )}
)} diff --git a/src/frontend/src/pages/FlowPage/index.tsx b/src/frontend/src/pages/FlowPage/index.tsx index 960e71af4..a222dddcc 100644 --- a/src/frontend/src/pages/FlowPage/index.tsx +++ b/src/frontend/src/pages/FlowPage/index.tsx @@ -1,11 +1,11 @@ import { useEffect } from "react"; import { useParams } from "react-router-dom"; +import FlowToolbar from "../../components/chatComponent"; import Header from "../../components/headerComponent"; import { useDarkStore } from "../../stores/darkStore"; import useFlowsManagerStore from "../../stores/flowsManagerStore"; import Page from "./components/PageComponent"; import ExtraSidebar from "./components/extraSidebarComponent"; -import FlowToolbar from "../../components/chatComponent"; export default function FlowPage({ view }: { view?: boolean }): JSX.Element { const setCurrentFlowId = useFlowsManagerStore( @@ -23,7 +23,7 @@ export default function FlowPage({ view }: { view?: boolean }): JSX.Element { <>
- {currentFlow && + {currentFlow && (
{!view && }
@@ -32,10 +32,9 @@ export default function FlowPage({ view }: { view?: boolean }): JSX.Element {
{!view && } -
- } + )} state.uploadFlow); const setCurrentFlowId = useFlowsManagerStore( diff --git a/src/frontend/src/stores/flowStore.ts b/src/frontend/src/stores/flowStore.ts index 4a7b30b6b..15ee69169 100644 --- a/src/frontend/src/stores/flowStore.ts +++ b/src/frontend/src/stores/flowStore.ts @@ -72,7 +72,7 @@ const useFlowStore = create((set, get) => ({ }, getNodePosition: (nodeId: string) => { const node = get().nodes.find((node) => node.id === nodeId); - return node?.position||{x:0,y:0}; + return node?.position || { x: 0, y: 0 }; }, updateFlowPool: ( nodeId: string, diff --git a/src/frontend/src/types/components/index.ts b/src/frontend/src/types/components/index.ts index 03578e224..378fa8674 100644 --- a/src/frontend/src/types/components/index.ts +++ b/src/frontend/src/types/components/index.ts @@ -1,5 +1,5 @@ import { ReactElement, ReactNode, SetStateAction } from "react"; -import { ReactFlowJsonObject, XYPosition } from "reactflow"; +import { ReactFlowJsonObject } from "reactflow"; import { InputOutput } from "../../constants/enums"; import { APIClassType, APITemplateType, TemplateVariableType } from "../api"; import { ChatMessageType } from "../chat"; diff --git a/src/frontend/src/utils/reactflowUtils.ts b/src/frontend/src/utils/reactflowUtils.ts index 1a803bf82..f9de6099b 100644 --- a/src/frontend/src/utils/reactflowUtils.ts +++ b/src/frontend/src/utils/reactflowUtils.ts @@ -1170,7 +1170,7 @@ export function downloadNode(NodeFLow: FlowType) { type: "application/json", }); element.href = URL.createObjectURL(file); - element.download = `${NodeFLow?.name??"node"}.json`; + element.download = `${NodeFLow?.name ?? "node"}.json`; element.click(); } diff --git a/src/frontend/vite.config.ts b/src/frontend/vite.config.ts index 479a98202..b513e36bb 100644 --- a/src/frontend/vite.config.ts +++ b/src/frontend/vite.config.ts @@ -1,7 +1,6 @@ import react from "@vitejs/plugin-react-swc"; import { defineConfig } from "vite"; import svgr from "vite-plugin-svgr"; -import MillionCompiler from "@million/lint"; const apiRoutes = ["^/api/v1/", "/health"]; // Use environment variable to determine the target. From f381d0f065378f082349cf8e1cb2b9be57893de5 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Sat, 30 Mar 2024 22:46:40 +0200 Subject: [PATCH 4/5] Fixed display name of IOView --- src/frontend/src/modals/IOModal/index.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/frontend/src/modals/IOModal/index.tsx b/src/frontend/src/modals/IOModal/index.tsx index e5b1c885c..707d039c1 100644 --- a/src/frontend/src/modals/IOModal/index.tsx +++ b/src/frontend/src/modals/IOModal/index.tsx @@ -315,7 +315,10 @@ export default function IOModal({ className="h-6 w-6" > - {selectedViewField.type} + { + nodes.find((node) => node.id === selectedViewField.id) + ?.data.node.display_name + }
{inputs.some( From 70135e7353b35b12b83ffa7eed7e6d386e5c2a85 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sat, 30 Mar 2024 17:51:55 -0300 Subject: [PATCH 5/5] Refactor onBuildComplete in flowStore.ts to include allNodesValid parameter --- src/frontend/src/stores/flowStore.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/frontend/src/stores/flowStore.ts b/src/frontend/src/stores/flowStore.ts index 15ee69169..bcc8f6309 100644 --- a/src/frontend/src/stores/flowStore.ts +++ b/src/frontend/src/stores/flowStore.ts @@ -529,9 +529,9 @@ const useFlowStore = create((set, get) => ({ onGetOrderSuccess: () => { setNoticeData({ title: "Running components" }); }, - onBuildComplete: () => { + onBuildComplete: (allNodesValid) => { const nodeId = startNodeId || stopNodeId; - if (nodeId) { + if (nodeId && allNodesValid) { setSuccessData({ title: `${ get().nodes.find((node) => node.id === nodeId)?.data.node