From 607e57d4d9706c65d160cb6a6130e4af84972be1 Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Thu, 13 Jul 2023 17:59:46 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20fix(ApiModal):=20import=20ReactN?= =?UTF-8?q?ode=20from=20react=20to=20fix=20missing=20type=20error=20?= =?UTF-8?q?=E2=9C=A8=20feat(ApiModal):=20add=20BaseModal=20component=20as?= =?UTF-8?q?=20a=20wrapper=20for=20the=20modal=20to=20improve=20code=20orga?= =?UTF-8?q?nization=20and=20reusability=20=F0=9F=94=A7=20fix(ApiModal):=20?= =?UTF-8?q?change=20prop=20name=20from=20children=20to=20flow=20in=20ApiMo?= =?UTF-8?q?dal=20component=20for=20better=20clarity=20=F0=9F=94=A7=20fix(A?= =?UTF-8?q?piModal):=20change=20prop=20name=20from=20children=20to=20flow?= =?UTF-8?q?=20in=20ApiModal=20component=20for=20better=20clarity=20?= =?UTF-8?q?=F0=9F=94=A7=20fix(ApiModal):=20change=20prop=20name=20from=20c?= =?UTF-8?q?hildren=20to=20flow=20in=20ApiModal=20component=20for=20better?= =?UTF-8?q?=20clarity=20=F0=9F=94=A7=20fix(ApiModal):=20change=20prop=20na?= =?UTF-8?q?me=20from=20children=20to=20flow=20in=20ApiModal=20component=20?= =?UTF-8?q?for=20better=20clarity=20=F0=9F=94=A7=20fix(ApiModal):=20change?= =?UTF-8?q?=20prop=20name=20from=20children=20to=20flow=20in=20ApiModal=20?= =?UTF-8?q?component=20for=20better=20clarity=20=F0=9F=94=A7=20fix(ApiModa?= =?UTF-8?q?l):=20change=20prop=20name=20from=20children=20to=20flow=20in?= =?UTF-8?q?=20ApiModal=20component=20for=20better=20clarity=20=F0=9F=94=A7?= =?UTF-8?q?=20fix(ApiModal):=20change=20prop=20name=20from=20children=20to?= =?UTF-8?q?=20flow=20in=20ApiModal=20component=20for=20better=20clarity=20?= =?UTF-8?q?=F0=9F=94=A7=20fix(ApiModal):=20change=20prop=20name=20from=20c?= =?UTF-8?q?hildren=20to=20flow=20in=20ApiModal=20component=20for=20better?= =?UTF-8?q?=20clarity=20=F0=9F=94=A7=20fix(ApiModal):=20change=20prop=20na?= =?UTF-8?q?me=20from=20children=20to=20flow=20in=20ApiModal=20component=20?= =?UTF-8?q?for=20better=20clarity=20=F0=9F=94=A7=20fix(ApiModal):=20change?= =?UTF-8?q?=20prop=20name=20from=20children=20to=20flow=20in=20ApiModal=20?= =?UTF-8?q?component=20for=20better=20clarity=20=F0=9F=94=A7=20fix(ApiModa?= =?UTF-8?q?l):=20change=20prop=20name=20from=20children=20to=20flow=20in?= =?UTF-8?q?=20ApiModal=20component=20for=20better=20clarity=20=F0=9F=94=A7?= =?UTF-8?q?=20fix(ApiModal):=20change=20prop=20name=20from=20children=20to?= =?UTF-8?q?=20flow=20in=20ApiModal=20component=20for=20better=20clarity=20?= =?UTF-8?q?=F0=9F=94=A7=20fix(ApiModal):=20change=20prop=20name=20from=20c?= =?UTF-8?q?hildren=20to=20flow=20in=20ApiModal=20component=20for=20better?= =?UTF-8?q?=20clarity=20=F0=9F=94=A7=20fix(ApiModal):=20change=20prop=20na?= =?UTF-8?q?me=20from=20children=20to=20flow=20in=20ApiModal=20component=20?= =?UTF-8?q?for=20better=20clarity=20=F0=9F=94=A7=20fix(ApiModal):=20change?= =?UTF-8?q?=20prop=20name=20from=20children=20to=20flow=20in=20ApiModal=20?= =?UTF-8?q?component=20for=20better=20clarity=20=F0=9F=94=A7=20fix(ApiModa?= =?UTF-8?q?l):=20change=20prop=20name=20from=20children=20to=20flow=20in?= =?UTF-8?q?=20ApiModal=20component=20for=20better=20clarity=20=F0=9F=94=A7?= =?UTF-8?q?=20fix(ApiModal):=20change=20prop=20name=20from=20children=20to?= =?UTF-8?q?=20flow=20in=20ApiModal=20component=20for=20better=20clarity=20?= =?UTF-8?q?=F0=9F=94=A7=20fix(ApiModal):=20change=20prop=20name=20from=20c?= =?UTF-8?q?hildren=20to=20flow=20in=20ApiModal=20component=20for=20better?= =?UTF-8?q?=20clarity=20=F0=9F=94=A7=20fix(ApiModal):=20change=20prop=20na?= =?UTF-8?q?me=20from=20children=20to=20flow=20in=20ApiModal=20component=20?= =?UTF-8?q?for=20better=20clarity=20=F0=9F=94=A7=20fix(ApiModal):=20change?= =?UTF-8?q?=20prop=20name=20from=20children=20to=20flow=20in=20ApiModal=20?= =?UTF-8?q?component=20for=20better=20clarity=20=F0=9F=94=A7=20fix(ApiModa?= =?UTF-8?q?l):=20change=20prop=20name=20from=20children=20to=20flow=20in?= =?UTF-8?q?=20ApiModal=20component=20for=20better=20clarity=20=F0=9F=94=A7?= =?UTF-8?q?=20fix(ApiModal):=20change=20prop=20name=20from=20children=20to?= =?UTF-8?q?=20flow=20in=20ApiModal=20component=20for=20better=20clarity=20?= =?UTF-8?q?=F0=9F=94=A7=20fix(ApiModal):=20change=20prop=20name=20from=20c?= =?UTF-8?q?hildren=20to=20flow=20in=20ApiModal=20component=20for=20better?= =?UTF-8?q?=20clarity=20=F0=9F=94=A7=20fix(ApiModal):=20change=20prop=20na?= =?UTF-8?q?me=20from=20children=20to=20flow=20in=20ApiModal=20component=20?= =?UTF-8?q?for=20better=20clarity=20=F0=9F=94=A7=20fix(ApiModal):=20change?= =?UTF-8?q?=20prop=20name=20from=20children=20to=20flow=20in=20ApiModal=20?= =?UTF-8?q?component=20for=20better=20clarity=20=F0=9F=94=A7=20fix(ApiModa?= =?UTF-8?q?l):=20change=20prop=20name=20from=20children=20to=20flow=20in?= =?UTF-8?q?=20ApiModal=20component=20for=20better=20clarity=20=F0=9F=94=A7?= =?UTF-8?q?=20fix(ApiModal):=20change=20prop=20name=20from=20children=20to?= =?UTF-8?q?=20flow=20in=20ApiModal=20component=20for=20better=20clarity=20?= =?UTF-8?q?=F0=9F=94=A7=20fix(ApiModal):=20change=20prop=20name=20from=20c?= =?UTF-8?q?hildren=20to=20flow=20in=20ApiModal=20component=20for=20better?= =?UTF-8?q?=20clarity=20=F0=9F=94=A7=20fix(ApiModal):=20change=20prop=20na?= =?UTF-8?q?me=20from=20children=20to=20flow=20in=20ApiModal=20component=20?= =?UTF-8?q?for=20better=20clarity=20=F0=9F=94=A7=20fix(ApiModal):=20change?= =?UTF-8?q?=20prop=20name=20from=20children=20to=20flow=20in=20ApiModal=20?= =?UTF-8?q?component=20for=20better=20clarity=20=F0=9F=94=A7=20fix(ApiModa?= =?UTF-8?q?l):=20change=20prop=20name=20from=20children=20to=20flow=20in?= =?UTF-8?q?=20ApiModal=20component=20for=20better=20clarity=20=F0=9F=94=A7?= =?UTF-8?q?=20fix(ApiModal):=20change=20prop=20name=20from=20children=20to?= =?UTF-8?q?=20flow=20in=20ApiModal=20component=20for=20better=20clarity=20?= =?UTF-8?q?=F0=9F=94=A7=20fix(ApiModal):=20change=20prop=20name=20from=20c?= =?UTF-8?q?hildren=20to=20flow=20in=20ApiModal=20component=20for=20better?= =?UTF-8?q?=20clarity=20=F0=9F=94=A7=20fix(ApiModal):=20change=20prop=20na?= =?UTF-8?q?me=20from=20children=20to=20flow=20in=20ApiModal=20component=20?= =?UTF-8?q?for=20better=20clarity=20=F0=9F=94=A7=20fix(ApiModal):=20change?= =?UTF-8?q?=20prop?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🐛 fix(extraSidebarComponent): remove unnecessary onClick event handlers for Export and Code buttons ✨ feat(extraSidebarComponent): wrap Export and Code buttons with ExportModal and ApiModal components respectively to handle click events and display modals 🐛 fix(nodeToolbarComponent): remove unnecessary onClick event handler for Edit button ✨ feat(nodeToolbarComponent): wrap Edit button with EditNodeModal component to handle click events and display modal --- src/frontend/src/modals/ApiModal/index.tsx | 76 +++++++------------ .../src/modals/EditNodeModal/index.tsx | 18 ++--- src/frontend/src/modals/exportModal/index.tsx | 22 ++---- .../src/modals/genericModal/index.tsx | 16 ++-- .../extraSidebarComponent/index.tsx | 17 +++-- .../components/nodeToolbarComponent/index.tsx | 14 ++-- 6 files changed, 66 insertions(+), 97 deletions(-) diff --git a/src/frontend/src/modals/ApiModal/index.tsx b/src/frontend/src/modals/ApiModal/index.tsx index f3f84a9ac..d3f787e11 100644 --- a/src/frontend/src/modals/ApiModal/index.tsx +++ b/src/frontend/src/modals/ApiModal/index.tsx @@ -2,7 +2,7 @@ import "ace-builds/src-noconflict/ext-language_tools"; import "ace-builds/src-noconflict/mode-python"; import "ace-builds/src-noconflict/theme-github"; import "ace-builds/src-noconflict/theme-twilight"; -import { useContext, useEffect, useRef, useState } from "react"; +import { ReactNode, useContext, useEffect, useRef, useState } from "react"; import { PopUpContext } from "../../contexts/popUpContext"; // import "ace-builds/webpack-resolver"; import { Check, Clipboard, Code2 } from "lucide-react"; @@ -52,8 +52,9 @@ import { darkContext } from "../../contexts/darkContext"; import { TabsContext } from "../../contexts/tabsContext"; import { FlowType } from "../../types/flow/index"; import { buildTweaks, classNames } from "../../utils"; +import BaseModal from "../baseModal"; -export default function ApiModal({ flow }: { flow: FlowType }) { +export default function ApiModal({ flow, children }: { flow: FlowType; children: ReactNode }) { const [open, setOpen] = useState(true); const { dark } = useContext(darkContext); const { closePopUp, closeEdit, setCloseEdit } = useContext(PopUpContext); @@ -265,21 +266,25 @@ export default function ApiModal({ flow }: { flow: FlowType }) { } return ( - - - - - - Code - - {EXPORT_CODE_DIALOG} - - + + {children} + + + + + Code + + + + + { @@ -318,7 +323,7 @@ export default function ApiModal({ flow }: { flow: FlowType }) { > {index < 3 ? ( @@ -329,7 +334,7 @@ export default function ApiModal({ flow }: { flow: FlowType }) {
))} - - {/* -
- - - - - TWEAK - - - VALUE - - - - - {invoices.map((invoice) => ( - - - {invoice.paymentStatus} - - - {invoice.paymentMethod} - - - ))} - -
-
*/}
@@ -755,7 +732,10 @@ export default function ApiModal({ flow }: { flow: FlowType }) { ))}
-
-
+ + + + + ); } diff --git a/src/frontend/src/modals/EditNodeModal/index.tsx b/src/frontend/src/modals/EditNodeModal/index.tsx index 1ef34bec3..e64db5c16 100644 --- a/src/frontend/src/modals/EditNodeModal/index.tsx +++ b/src/frontend/src/modals/EditNodeModal/index.tsx @@ -1,5 +1,5 @@ import { Variable } from "lucide-react"; -import { useContext, useRef, useState } from "react"; +import { ReactNode, useContext, useRef, useState } from "react"; import CodeAreaComponent from "../../components/codeAreaComponent"; import Dropdown from "../../components/dropdownComponent"; import FloatComponent from "../../components/floatComponent"; @@ -28,7 +28,7 @@ import { NodeDataType } from "../../types/flow"; import { classNames, limitScrollFieldsModal } from "../../utils"; import BaseModal from "../baseModal"; -export default function EditNodeModal({ data }: { data: NodeDataType }) { +export default function EditNodeModal({ data, children }: { data: NodeDataType; children: ReactNode }) { const [open, setOpen] = useState(true); const [nodeLength, setNodeLength] = useState( Object.keys(data.node.template).filter( @@ -58,12 +58,6 @@ export default function EditNodeModal({ data }: { data: NodeDataType }) { closePopUp(); } - function setModalOpen(x: boolean) { - setOpen(x); - if (x === false) { - closePopUp(); - } - } function changeAdvanced(node) { Object.keys(data.node.template).map((n, i) => { @@ -89,8 +83,12 @@ export default function EditNodeModal({ data }: { data: NodeDataType }) { }); }; + return ( - + + + {children} + {data.type} @@ -309,7 +307,7 @@ export default function EditNodeModal({ data }: { data: NodeDataType }) {