From 89a0918dc57f5b9950c4b590e3081e3747cae66a Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Tue, 29 Aug 2023 22:07:18 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20fix(codeTabsComponent):=20remove?= =?UTF-8?q?=20unused=20useContext=20for=20isTweakPage=20in=20codeTabsCompo?= =?UTF-8?q?nent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🔧 fix(alertContext): remove isTweakPage and setIsTweakPage from alertContext 🔧 fix(genericModal): add null check for nodeClass before calling postValidatePrompt 🔧 fix(extraSidebarComponent): remove setIsTweakPage from extraSidebarComponent 🔧 fix(typesContext): remove isTweakPage and setIsTweakPage from typesContext --- .../components/codeTabsComponent/index.tsx | 19 ++++++++----------- src/frontend/src/contexts/alertContext.tsx | 6 +----- .../src/modals/genericModal/index.tsx | 3 ++- .../extraSidebarComponent/index.tsx | 3 +-- src/frontend/src/types/typesContext/index.ts | 2 -- 5 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/frontend/src/components/codeTabsComponent/index.tsx b/src/frontend/src/components/codeTabsComponent/index.tsx index fcd7385d7..2fa6563a6 100644 --- a/src/frontend/src/components/codeTabsComponent/index.tsx +++ b/src/frontend/src/components/codeTabsComponent/index.tsx @@ -49,7 +49,6 @@ export default function CodeTabsComponent({ const [openAccordion, setOpenAccordion] = useState([]); const { dark } = useContext(darkContext); const { reactFlowInstance } = useContext(typesContext); - const { isTweakPage, setIsTweakPage } = useContext(alertContext); useEffect(() => { if (flow && flow["data"]!["nodes"]) { @@ -58,16 +57,14 @@ export default function CodeTabsComponent({ }, [flow]); useEffect(() => { - unselectAllNodes({ - data, - updateNodes: (nodes) => { - reactFlowInstance?.setNodes(nodes); - }, - }); - - return () => { - if (isTweakPage) setIsTweakPage(false); - }; + if(tweaks){ + unselectAllNodes({ + data, + updateNodes: (nodes) => { + reactFlowInstance?.setNodes(nodes); + }, + }); + } }, []); const copyToClipboard = () => { diff --git a/src/frontend/src/contexts/alertContext.tsx b/src/frontend/src/contexts/alertContext.tsx index 98b2fdef8..ba46dddac 100644 --- a/src/frontend/src/contexts/alertContext.tsx +++ b/src/frontend/src/contexts/alertContext.tsx @@ -25,9 +25,7 @@ const initialValue: alertContextType = { notificationList: [], pushNotificationList: () => {}, clearNotificationList: () => {}, - removeFromNotificationList: () => {}, - isTweakPage: false, - setIsTweakPage: () => {}, + removeFromNotificationList: () => {} }; export const alertContext = createContext(initialValue); @@ -123,8 +121,6 @@ export function AlertProvider({ children }: { children: ReactNode }) { return ( { - if (apiReturn.data) { + if (apiReturn.data && nodeClass) { let inputVariables = apiReturn.data.input_variables ?? []; if (inputVariables && inputVariables.length === 0) { setIsEdit(true); diff --git a/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx b/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx index c506975ae..c8dd34628 100644 --- a/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx +++ b/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx @@ -21,7 +21,7 @@ export default function ExtraSidebar(): JSX.Element { const { data, templates } = useContext(typesContext); const { flows, tabId, uploadFlow, tabsState, saveFlow, isBuilt } = useContext(TabsContext); - const { setSuccessData, setErrorData, setIsTweakPage } = + const { setSuccessData, setErrorData } = useContext(alertContext); const [dataFilter, setFilterData] = useState(data); const [search, setSearch] = useState(""); @@ -103,7 +103,6 @@ export default function ExtraSidebar(): JSX.Element {
setIsTweakPage(true)} > void; loading: boolean; setLoading: (newState: boolean) => void; - isTweakPage: boolean; - setIsTweakPage: (newState: boolean) => void; }; export type darkContextType = {