From 356e7c4455f2516d52dae074e90a2d4f583ee579 Mon Sep 17 00:00:00 2001 From: igorrCarvalho Date: Tue, 25 Jun 2024 11:06:41 -0300 Subject: [PATCH 1/2] Feat: add more types --- src/frontend/src/CustomNodes/GenericNode/index.tsx | 4 ++-- src/frontend/src/CustomNodes/helpers/get-node-input-colors.ts | 2 +- .../src/CustomNodes/helpers/get-node-output-colors.ts | 4 +++- src/frontend/src/components/ImageViewer/index.tsx | 2 +- .../src/components/horizontalScrollFadeComponent/index.tsx | 3 +++ src/frontend/src/modals/BundleModal/hooks/submit-folder.tsx | 3 ++- src/frontend/src/modals/foldersModal/hooks/submit-folder.tsx | 3 ++- 7 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/frontend/src/CustomNodes/GenericNode/index.tsx b/src/frontend/src/CustomNodes/GenericNode/index.tsx index 18c2bbb6a..c71313b3b 100644 --- a/src/frontend/src/CustomNodes/GenericNode/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/index.tsx @@ -26,7 +26,7 @@ import useFlowStore from "../../stores/flowStore"; import useFlowsManagerStore from "../../stores/flowsManagerStore"; import { useShortcutsStore } from "../../stores/shortcuts"; import { useTypesStore } from "../../stores/typesStore"; -import { VertexBuildTypeAPI } from "../../types/api"; +import { OutputFieldType, VertexBuildTypeAPI } from "../../types/api"; import { NodeDataType } from "../../types/flow"; import { handleKeyDown, scapedJSONStringfy } from "../../utils/reactflowUtils"; import { nodeColors, nodeIconsLucide } from "../../utils/styleUtils"; @@ -279,7 +279,7 @@ export default function GenericNode({ const shortcuts = useShortcutsStore((state) => state.shortcuts); - const renderOutputParameter = (output, idx) => { + const renderOutputParameter = (output: OutputFieldType, idx: number) => { return ( nodeColors[type] ?? nodeColors.unknown; diff --git a/src/frontend/src/CustomNodes/helpers/get-node-output-colors.ts b/src/frontend/src/CustomNodes/helpers/get-node-output-colors.ts index d846a304e..b91a9691c 100644 --- a/src/frontend/src/CustomNodes/helpers/get-node-output-colors.ts +++ b/src/frontend/src/CustomNodes/helpers/get-node-output-colors.ts @@ -1,6 +1,8 @@ +import { OutputFieldType } from "../../types/api"; +import { NodeDataType } from "../../types/flow"; import { nodeColors } from "../../utils/styleUtils"; -export function getNodeOutputColors(output, data, types): string[] { +export function getNodeOutputColors(output: OutputFieldType, data: NodeDataType, types: {[char: string]: string}): string[] { // Helper function to get the color based on type const getColorByType = (type) => nodeColors[type] ?? nodeColors.unknown; diff --git a/src/frontend/src/components/ImageViewer/index.tsx b/src/frontend/src/components/ImageViewer/index.tsx index 9e7f091d2..8c62894a3 100644 --- a/src/frontend/src/components/ImageViewer/index.tsx +++ b/src/frontend/src/components/ImageViewer/index.tsx @@ -6,7 +6,7 @@ import useAlertStore from "../../stores/alertStore"; import ForwardedIconComponent from "../genericIconComponent"; import { Separator } from "../ui/separator"; -export default function ImageViewer({ image }) { +export default function ImageViewer({ image }: {image: string}) { const viewerRef = useRef(null); const [errorDownloading, setErrordownloading] = useState(false); const setErrorList = useAlertStore((state) => state.setErrorData); diff --git a/src/frontend/src/components/horizontalScrollFadeComponent/index.tsx b/src/frontend/src/components/horizontalScrollFadeComponent/index.tsx index e0bf48917..b59927e53 100644 --- a/src/frontend/src/components/horizontalScrollFadeComponent/index.tsx +++ b/src/frontend/src/components/horizontalScrollFadeComponent/index.tsx @@ -3,6 +3,9 @@ import { useEffect, useRef, useState } from "react"; export default function HorizontalScrollFadeComponent({ children, isFolder = true, +}: { + children: JSX.Element | JSX.Element[], + isFolder?: boolean, }) { const scrollContainerRef = useRef(null); const fadeContainerRef = useRef(null); diff --git a/src/frontend/src/modals/BundleModal/hooks/submit-folder.tsx b/src/frontend/src/modals/BundleModal/hooks/submit-folder.tsx index cb12ca7cb..f6cf486c3 100644 --- a/src/frontend/src/modals/BundleModal/hooks/submit-folder.tsx +++ b/src/frontend/src/modals/BundleModal/hooks/submit-folder.tsx @@ -1,8 +1,9 @@ +import { FolderType } from "../../../pages/MainPage/entities"; import { addFolder, updateFolder } from "../../../pages/MainPage/services"; import useAlertStore from "../../../stores/alertStore"; import { useFolderStore } from "../../../stores/foldersStore"; -const useFolderSubmit = (setOpen, folderToEdit) => { +const useFolderSubmit = (setOpen: (a: boolean) => void, folderToEdit: FolderType | null) => { const setSuccessData = useAlertStore((state) => state.setSuccessData); const setErrorData = useAlertStore((state) => state.setErrorData); const getFoldersApi = useFolderStore((state) => state.getFoldersApi); diff --git a/src/frontend/src/modals/foldersModal/hooks/submit-folder.tsx b/src/frontend/src/modals/foldersModal/hooks/submit-folder.tsx index 71a8ac944..9dcd054c4 100644 --- a/src/frontend/src/modals/foldersModal/hooks/submit-folder.tsx +++ b/src/frontend/src/modals/foldersModal/hooks/submit-folder.tsx @@ -1,9 +1,10 @@ import { useNavigate } from "react-router-dom"; +import { FolderType } from "../../../pages/MainPage/entities"; import { addFolder, updateFolder } from "../../../pages/MainPage/services"; import useAlertStore from "../../../stores/alertStore"; import { useFolderStore } from "../../../stores/foldersStore"; -const useFolderSubmit = (setOpen, folderToEdit) => { +const useFolderSubmit = (setOpen: (a: boolean) => void, folderToEdit: FolderType | null) => { const setSuccessData = useAlertStore((state) => state.setSuccessData); const setErrorData = useAlertStore((state) => state.setErrorData); const getFoldersApi = useFolderStore((state) => state.getFoldersApi); From 8836c29a397344a2cbd08627abd12e8180be540d Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 27 Jun 2024 17:33:49 -0300 Subject: [PATCH 2/2] Format code --- .../src/CustomNodes/helpers/get-node-input-colors.ts | 6 +++++- .../src/CustomNodes/helpers/get-node-output-colors.ts | 6 +++++- src/frontend/src/components/ImageViewer/index.tsx | 2 +- .../src/components/horizontalScrollFadeComponent/index.tsx | 4 ++-- src/frontend/src/modals/BundleModal/hooks/submit-folder.tsx | 5 ++++- .../src/modals/foldersModal/hooks/submit-folder.tsx | 5 ++++- 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/frontend/src/CustomNodes/helpers/get-node-input-colors.ts b/src/frontend/src/CustomNodes/helpers/get-node-input-colors.ts index e76d073bd..58b2ae677 100644 --- a/src/frontend/src/CustomNodes/helpers/get-node-input-colors.ts +++ b/src/frontend/src/CustomNodes/helpers/get-node-input-colors.ts @@ -1,6 +1,10 @@ import { nodeColors } from "../../utils/styleUtils"; -export function getNodeInputColors(input_types: string[] | undefined, type: string | undefined, types: {[char: string]: string}) { +export function getNodeInputColors( + input_types: string[] | undefined, + type: string | undefined, + types: { [char: string]: string }, +) { // Helper function to get the color based on type const getColorByType = (type) => nodeColors[type] ?? nodeColors.unknown; diff --git a/src/frontend/src/CustomNodes/helpers/get-node-output-colors.ts b/src/frontend/src/CustomNodes/helpers/get-node-output-colors.ts index b91a9691c..dcac3d5cc 100644 --- a/src/frontend/src/CustomNodes/helpers/get-node-output-colors.ts +++ b/src/frontend/src/CustomNodes/helpers/get-node-output-colors.ts @@ -2,7 +2,11 @@ import { OutputFieldType } from "../../types/api"; import { NodeDataType } from "../../types/flow"; import { nodeColors } from "../../utils/styleUtils"; -export function getNodeOutputColors(output: OutputFieldType, data: NodeDataType, types: {[char: string]: string}): string[] { +export function getNodeOutputColors( + output: OutputFieldType, + data: NodeDataType, + types: { [char: string]: string }, +): string[] { // Helper function to get the color based on type const getColorByType = (type) => nodeColors[type] ?? nodeColors.unknown; diff --git a/src/frontend/src/components/ImageViewer/index.tsx b/src/frontend/src/components/ImageViewer/index.tsx index 8c62894a3..6e2c340fd 100644 --- a/src/frontend/src/components/ImageViewer/index.tsx +++ b/src/frontend/src/components/ImageViewer/index.tsx @@ -6,7 +6,7 @@ import useAlertStore from "../../stores/alertStore"; import ForwardedIconComponent from "../genericIconComponent"; import { Separator } from "../ui/separator"; -export default function ImageViewer({ image }: {image: string}) { +export default function ImageViewer({ image }: { image: string }) { const viewerRef = useRef(null); const [errorDownloading, setErrordownloading] = useState(false); const setErrorList = useAlertStore((state) => state.setErrorData); diff --git a/src/frontend/src/components/horizontalScrollFadeComponent/index.tsx b/src/frontend/src/components/horizontalScrollFadeComponent/index.tsx index b59927e53..db78daaaf 100644 --- a/src/frontend/src/components/horizontalScrollFadeComponent/index.tsx +++ b/src/frontend/src/components/horizontalScrollFadeComponent/index.tsx @@ -4,8 +4,8 @@ export default function HorizontalScrollFadeComponent({ children, isFolder = true, }: { - children: JSX.Element | JSX.Element[], - isFolder?: boolean, + children: JSX.Element | JSX.Element[]; + isFolder?: boolean; }) { const scrollContainerRef = useRef(null); const fadeContainerRef = useRef(null); diff --git a/src/frontend/src/modals/BundleModal/hooks/submit-folder.tsx b/src/frontend/src/modals/BundleModal/hooks/submit-folder.tsx index f6cf486c3..cd3c3a1e1 100644 --- a/src/frontend/src/modals/BundleModal/hooks/submit-folder.tsx +++ b/src/frontend/src/modals/BundleModal/hooks/submit-folder.tsx @@ -3,7 +3,10 @@ import { addFolder, updateFolder } from "../../../pages/MainPage/services"; import useAlertStore from "../../../stores/alertStore"; import { useFolderStore } from "../../../stores/foldersStore"; -const useFolderSubmit = (setOpen: (a: boolean) => void, folderToEdit: FolderType | null) => { +const useFolderSubmit = ( + setOpen: (a: boolean) => void, + folderToEdit: FolderType | null, +) => { const setSuccessData = useAlertStore((state) => state.setSuccessData); const setErrorData = useAlertStore((state) => state.setErrorData); const getFoldersApi = useFolderStore((state) => state.getFoldersApi); diff --git a/src/frontend/src/modals/foldersModal/hooks/submit-folder.tsx b/src/frontend/src/modals/foldersModal/hooks/submit-folder.tsx index 9dcd054c4..a60f2a419 100644 --- a/src/frontend/src/modals/foldersModal/hooks/submit-folder.tsx +++ b/src/frontend/src/modals/foldersModal/hooks/submit-folder.tsx @@ -4,7 +4,10 @@ import { addFolder, updateFolder } from "../../../pages/MainPage/services"; import useAlertStore from "../../../stores/alertStore"; import { useFolderStore } from "../../../stores/foldersStore"; -const useFolderSubmit = (setOpen: (a: boolean) => void, folderToEdit: FolderType | null) => { +const useFolderSubmit = ( + setOpen: (a: boolean) => void, + folderToEdit: FolderType | null, +) => { const setSuccessData = useAlertStore((state) => state.setSuccessData); const setErrorData = useAlertStore((state) => state.setErrorData); const getFoldersApi = useFolderStore((state) => state.getFoldersApi);