From 6aaad2d2cd30eb631f852f3fc7c48c8948a2fadb Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Mon, 8 Jan 2024 15:00:42 -0300 Subject: [PATCH] Revert "code format" This reverts commit 8a0b240a7f6409bc6509101c435c2882f4c5c519. --- src/frontend/src/App.tsx | 5 ++- .../components/parameterComponent/index.tsx | 16 +++++--- .../src/CustomNodes/GenericNode/index.tsx | 6 +-- .../src/components/authAdminGuard/index.tsx | 11 ++++-- .../src/components/authGuard/index.tsx | 3 +- .../src/components/cardComponent/index.tsx | 4 +- .../chatComponent/buildTrigger/index.tsx | 3 +- .../src/components/chatComponent/index.tsx | 12 +++--- .../components/menuBar/index.tsx | 6 ++- .../src/components/headerComponent/index.tsx | 5 +-- .../components/inputFileComponent/index.tsx | 4 +- .../src/components/intComponent/index.tsx | 5 +-- src/frontend/src/components/ui/checkbox.tsx | 10 +---- src/frontend/src/contexts/authContext.tsx | 9 ++--- src/frontend/src/contexts/index.tsx | 4 +- src/frontend/src/contexts/typesContext.tsx | 9 ++++- src/frontend/src/modals/ApiModal/index.tsx | 14 +------ src/frontend/src/modals/exportModal/index.tsx | 6 +-- .../src/modals/flowSettingsModal/index.tsx | 4 +- src/frontend/src/modals/formModal/index.tsx | 17 +++++---- src/frontend/src/modals/shareModal/index.tsx | 6 +-- .../src/pages/AdminPage/LoginPage/index.tsx | 2 +- src/frontend/src/pages/AdminPage/index.tsx | 14 ++++--- .../components/PageComponent/index.tsx | 14 ++++--- .../components/nodeToolbarComponent/index.tsx | 37 ++++++++++--------- .../MainPage/components/components/index.tsx | 4 +- src/frontend/src/pages/MainPage/index.tsx | 6 ++- .../src/pages/ProfileSettingsPage/index.tsx | 6 +-- src/frontend/src/pages/StorePage/index.tsx | 6 +-- src/frontend/src/pages/ViewPage/index.tsx | 10 ++--- src/frontend/src/pages/loginPage/index.tsx | 2 +- src/frontend/src/stores/flowStore.ts | 1 + src/frontend/src/stores/flowsManagerStore.ts | 22 ++++------- src/frontend/src/types/components/index.ts | 9 +++-- src/frontend/src/types/zustand/flow/index.ts | 1 + .../src/types/zustand/flowsManager/index.ts | 36 +++--------------- src/frontend/src/types/zustand/types/index.ts | 20 +++++----- src/frontend/src/utils/reactflowUtils.ts | 4 +- src/frontend/src/utils/utils.ts | 5 +-- 39 files changed, 167 insertions(+), 191 deletions(-) diff --git a/src/frontend/src/App.tsx b/src/frontend/src/App.tsx index 5b00268b7..7e4d80f4d 100644 --- a/src/frontend/src/App.tsx +++ b/src/frontend/src/App.tsx @@ -17,12 +17,12 @@ import { } from "./constants/constants"; import { AuthContext } from "./contexts/authContext"; import { locationContext } from "./contexts/locationContext"; -import { getHealth } from "./controllers/API"; +import { getHealth, getRepoStars, getVersion } from "./controllers/API"; import Router from "./routes"; import useAlertStore from "./stores/alertStore"; +import { useTypesStore } from "./stores/typesStore"; import { useDarkStore } from "./stores/darkStore"; import useFlowsManagerStore from "./stores/flowsManagerStore"; -import { useTypesStore } from "./stores/typesStore"; export default function App() { let { setCurrent, setShowSideBar, setIsStackedOpen } = @@ -147,6 +147,7 @@ export default function App() { refreshFlows(); }); } + }, [isAuthenticated]); useEffect(() => { diff --git a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx index a76a15d17..b688fdb7b 100644 --- a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx @@ -1,5 +1,11 @@ import { cloneDeep } from "lodash"; -import React, { ReactNode, useEffect, useRef, useState } from "react"; +import React, { + ReactNode, + useContext, + useEffect, + useRef, + useState, +} from "react"; import { Handle, Position } from "reactflow"; import ShadTooltip from "../../../../components/ShadTooltipComponent"; import CodeAreaComponent from "../../../../components/codeAreaComponent"; @@ -23,8 +29,6 @@ import { import { postCustomComponentUpdate } from "../../../../controllers/API"; import useAlertStore from "../../../../stores/alertStore"; import useFlowStore from "../../../../stores/flowStore"; -import useFlowsManagerStore from "../../../../stores/flowsManagerStore"; -import { useTypesStore } from "../../../../stores/typesStore"; import { APIClassType } from "../../../../types/api"; import { ParameterComponentType } from "../../../../types/components"; import { NodeDataType } from "../../../../types/flow"; @@ -41,6 +45,8 @@ import { nodeNames, } from "../../../../utils/styleUtils"; import { classNames, groupByFamily } from "../../../../utils/utils"; +import { useTypesStore } from "../../../../stores/typesStore"; +import useFlowsManagerStore from "../../../../stores/flowsManagerStore"; export default function ParameterComponent({ left, @@ -106,7 +112,7 @@ export default function ParameterComponent({ if (data.node!.template[name].value !== newValue) { takeSnapshot(); } - + data.node!.template[name].value = newValue; // necessary to enable ctrl+z inside the input setNode(data.id, (oldNode) => { @@ -294,7 +300,7 @@ export default function ParameterComponent({ ) : (
<>
{ - const { isAdmin, isAuthenticated, logout, userData, autoLogin } = - useContext(AuthContext); + const { + isAdmin, + isAuthenticated, + logout, + userData, + autoLogin, + } = useContext(AuthContext); if (!isAuthenticated) { logout(); diff --git a/src/frontend/src/components/authGuard/index.tsx b/src/frontend/src/components/authGuard/index.tsx index 93735e977..713862e00 100644 --- a/src/frontend/src/components/authGuard/index.tsx +++ b/src/frontend/src/components/authGuard/index.tsx @@ -3,7 +3,8 @@ import { Navigate } from "react-router-dom"; import { AuthContext } from "../../contexts/authContext"; export const ProtectedRoute = ({ children }) => { - const { isAuthenticated, logout } = useContext(AuthContext); + const { isAuthenticated, logout} = + useContext(AuthContext); if (!isAuthenticated) { logout(); return ; diff --git a/src/frontend/src/components/cardComponent/index.tsx b/src/frontend/src/components/cardComponent/index.tsx index a253f1f5e..d87419fe2 100644 --- a/src/frontend/src/components/cardComponent/index.tsx +++ b/src/frontend/src/components/cardComponent/index.tsx @@ -1,8 +1,7 @@ -import { useEffect, useState } from "react"; +import { useContext, useEffect, useState } from "react"; import { getComponent, postLikeComponent } from "../../controllers/API"; import DeleteConfirmationModal from "../../modals/DeleteConfirmationModal"; import useAlertStore from "../../stores/alertStore"; -import useFlowsManagerStore from "../../stores/flowsManagerStore"; import { useStoreStore } from "../../stores/storeStore"; import { storeComponent } from "../../types/store"; import cloneFLowWithParent from "../../utils/storeUtils"; @@ -18,6 +17,7 @@ import { CardHeader, CardTitle, } from "../ui/card"; +import useFlowsManagerStore from "../../stores/flowsManagerStore"; export default function CollectionCardComponent({ data, diff --git a/src/frontend/src/components/chatComponent/buildTrigger/index.tsx b/src/frontend/src/components/chatComponent/buildTrigger/index.tsx index e965397a3..1dcc327ee 100644 --- a/src/frontend/src/components/chatComponent/buildTrigger/index.tsx +++ b/src/frontend/src/components/chatComponent/buildTrigger/index.tsx @@ -1,5 +1,5 @@ import { Transition } from "@headlessui/react"; -import { useState } from "react"; +import { useContext, useState } from "react"; import Loading from "../../../components/ui/loading"; import { useSSE } from "../../../contexts/SSEContext"; import { postBuildInit } from "../../../controllers/API"; @@ -9,6 +9,7 @@ import useAlertStore from "../../../stores/alertStore"; import useFlowStore from "../../../stores/flowStore"; import useFlowsManagerStore from "../../../stores/flowsManagerStore"; import { parsedDataType } from "../../../types/components"; +import { FlowState } from "../../../types/tabs"; import { validateNodes } from "../../../utils/reactflowUtils"; import RadialProgressComponent from "../../RadialProgress"; import IconComponent from "../../genericIconComponent"; diff --git a/src/frontend/src/components/chatComponent/index.tsx b/src/frontend/src/components/chatComponent/index.tsx index 9e0026898..80d6fb991 100644 --- a/src/frontend/src/components/chatComponent/index.tsx +++ b/src/frontend/src/components/chatComponent/index.tsx @@ -1,4 +1,4 @@ -import { useEffect, useRef, useState } from "react"; +import { useContext, useEffect, useRef, useState } from "react"; import { useNodes } from "reactflow"; import { ChatType } from "../../types/chat"; import BuildTrigger from "./buildTrigger"; @@ -8,17 +8,15 @@ import * as _ from "lodash"; import { getBuildStatus } from "../../controllers/API"; import FormModal from "../../modals/formModal"; import useFlowStore from "../../stores/flowStore"; -import useFlowsManagerStore from "../../stores/flowsManagerStore"; import { NodeType } from "../../types/flow"; +import useFlowsManagerStore from "../../stores/flowsManagerStore"; export default function Chat({ flow }: ChatType): JSX.Element { const [open, setOpen] = useState(false); const [canOpen, setCanOpen] = useState(false); const isBuilt = useFlowStore((state) => state.isBuilt); const setIsBuilt = useFlowStore((state) => state.setIsBuilt); - const currentFlowState = useFlowsManagerStore( - (state) => state.currentFlowState - ); + const currentFlowState = useFlowsManagerStore((state) => state.currentFlowState); useEffect(() => { const handleKeyDown = (event: KeyboardEvent) => { @@ -55,7 +53,9 @@ export default function Chat({ flow }: ChatType): JSX.Element { const currentNodes = nodes.map((node: NodeType) => _.cloneDeep(node.data.node?.template) ); - if (JSON.stringify(prevNodes) !== JSON.stringify(currentNodes)) { + if ( + JSON.stringify(prevNodes) !== JSON.stringify(currentNodes) + ) { setIsBuilt(false); } if ( diff --git a/src/frontend/src/components/headerComponent/components/menuBar/index.tsx b/src/frontend/src/components/headerComponent/components/menuBar/index.tsx index a4ff37fae..20ac20f04 100644 --- a/src/frontend/src/components/headerComponent/components/menuBar/index.tsx +++ b/src/frontend/src/components/headerComponent/components/menuBar/index.tsx @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useContext, useState } from "react"; import { DropdownMenu, DropdownMenuContent, @@ -49,7 +49,9 @@ export const MenuBar = (): JSX.Element => { diff --git a/src/frontend/src/components/headerComponent/index.tsx b/src/frontend/src/components/headerComponent/index.tsx index 111e1d046..b4a6a9fff 100644 --- a/src/frontend/src/components/headerComponent/index.tsx +++ b/src/frontend/src/components/headerComponent/index.tsx @@ -166,10 +166,7 @@ export default function Header(): JSX.Element {