From 628e6bace57af900d256cd16d9b0d6cc31c5820c Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Tue, 5 Sep 2023 11:13:42 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(EditNodeModal):=20remove=20u?= =?UTF-8?q?nused=20state=20variable=20'errorDuplicateKey'=20to=20improve?= =?UTF-8?q?=20code=20cleanliness=20and=20remove=20unnecessary=20complexity?= =?UTF-8?q?=20=F0=9F=94=A5=20chore(EditNodeModal):=20remove=20unused=20sta?= =?UTF-8?q?te=20variables=20'dict'=20and=20'dictArr'=20to=20improve=20code?= =?UTF-8?q?=20cleanliness=20and=20remove=20unnecessary=20complexity=20?= =?UTF-8?q?=F0=9F=94=A5=20chore(EditNodeModal):=20remove=20unused=20useEff?= =?UTF-8?q?ect=20hook=20for=20'dict'=20state=20variable=20to=20improve=20c?= =?UTF-8?q?ode=20cleanliness=20and=20remove=20unnecessary=20complexity=20?= =?UTF-8?q?=F0=9F=94=A5=20chore(EditNodeModal):=20remove=20unused=20state?= =?UTF-8?q?=20variable=20'obj'=20to=20improve=20code=20cleanliness=20and?= =?UTF-8?q?=20remove=20unnecessary=20complexity=20=F0=9F=94=A5=20chore(Edi?= =?UTF-8?q?tNodeModal):=20remove=20unused=20state=20variable=20'myData'=20?= =?UTF-8?q?to=20improve=20code=20cleanliness=20and=20remove=20unnecessary?= =?UTF-8?q?=20complexity=20=F0=9F=94=A5=20chore(EditNodeModal):=20remove?= =?UTF-8?q?=20unused=20state=20variable=20'setMyData'=20to=20improve=20cod?= =?UTF-8?q?e=20cleanliness=20and=20remove=20unnecessary=20complexity=20?= =?UTF-8?q?=F0=9F=94=A5=20chore(EditNodeModal):=20remove=20unused=20state?= =?UTF-8?q?=20variable=20'setDict'=20to=20improve=20code=20cleanliness=20a?= =?UTF-8?q?nd=20remove=20unnecessary=20complexity=20=F0=9F=94=A5=20chore(E?= =?UTF-8?q?ditNodeModal):=20remove=20unused=20state=20variable=20'setDictA?= =?UTF-8?q?rr'=20to=20improve=20code=20cleanliness=20and=20remove=20unnece?= =?UTF-8?q?ssary=20complexity=20=F0=9F=94=A5=20chore(EditNodeModal):=20rem?= =?UTF-8?q?ove=20unused=20state=20variable=20'setObj'=20to=20improve=20cod?= =?UTF-8?q?e=20cleanliness=20and=20remove=20unnecessary=20complexity=20?= =?UTF-8?q?=F0=9F=94=A5=20chore(EditNodeModal):=20remove=20unused=20state?= =?UTF-8?q?=20variable=20'setTabsState'=20to=20improve=20code=20cleanlines?= =?UTF-8?q?s=20and=20remove=20unnecessary=20complexity=20=F0=9F=94=A5=20ch?= =?UTF-8?q?ore(EditNodeModal):=20remove=20unused=20state=20variable=20'tab?= =?UTF-8?q?Id'=20to=20improve=20code=20cleanliness=20and=20remove=20unnece?= =?UTF-8?q?ssary=20complexity=20=F0=9F=94=A5=20chore(EditNodeModal):=20rem?= =?UTF-8?q?ove=20unused=20state=20variable=20'reactFlowInstance'=20to=20im?= =?UTF-8?q?prove=20code=20cleanliness=20and=20remove=20unnecessary=20compl?= =?UTF-8?q?exity=20=F0=9F=94=A5=20chore(EditNodeModal):=20remove=20unused?= =?UTF-8?q?=20import=20for=20'typesContext'=20to=20improve=20code=20cleanl?= =?UTF-8?q?iness=20and=20remove=20unnecessary=20complexity=20=F0=9F=94=A5?= =?UTF-8?q?=20chore(EditNodeModal):=20remove=20unused=20import=20for=20'us?= =?UTF-8?q?eState'=20to=20improve=20code=20cleanliness=20and=20remove=20un?= =?UTF-8?q?necessary=20complexity=20=F0=9F=94=A5=20chore(EditNodeModal):?= =?UTF-8?q?=20remove=20unused=20import=20for=20'useEffect'=20to=20improve?= =?UTF-8?q?=20code=20cleanliness=20and=20remove=20unnecessary=20complexity?= =?UTF-8?q?=20=F0=9F=94=A5=20chore(EditNodeModal):=20remove=20unused=20imp?= =?UTF-8?q?ort=20for=20'forwardRef'=20to=20improve=20code=20cleanliness=20?= =?UTF-8?q?and=20remove=20unnecessary=20complexity=20=F0=9F=94=A5=20chore(?= =?UTF-8?q?EditNodeModal):=20remove=20unused=20import=20for=20'useContext'?= =?UTF-8?q?=20to=20improve=20code=20cleanliness=20and=20remove=20unnecessa?= =?UTF-8?q?ry=20complexity=20=F0=9F=94=A5=20chore(EditNodeModal):=20remove?= =?UTF-8?q?=20unused=20import=20for=20'classNames'=20to=20improve=20code?= =?UTF-8?q?=20cleanliness=20and=20remove=20unnecessary=20complexity=20?= =?UTF-8?q?=F0=9F=94=A5=20chore(EditNodeModal):=20remove=20unused=20import?= =?UTF-8?q?=20for=20'convertObjToArray'=20to=20improve=20code=20cleanlines?= =?UTF-8?q?s=20and=20remove=20unnecessary=20complexity=20=F0=9F=94=A5=20ch?= =?UTF-8?q?ore(EditNodeModal):=20remove=20unused=20import=20for=20'convert?= =?UTF-8?q?ArrayToObj'=20to=20improve=20code=20cleanliness=20and=20remove?= =?UTF-8?q?=20unnecessary=20complexity=20=F0=9F=94=A5=20chore(EditNodeModa?= =?UTF-8?q?l):=20remove=20unused=20import=20for=20'hasDuplicateKeys'=20to?= =?UTF-8?q?=20improve=20code=20cleanliness=20and=20remove=20unnecessary=20?= =?UTF-8?q?complexity=20=F0=9F=94=A5=20chore(EditNodeModal):=20remove=20un?= =?UTF-8?q?used=20import=20for=20'KeypairListComponent'=20to=20improve=20c?= =?UTF-8?q?ode=20cleanliness=20and=20remove=20unnecessary=20complexity=20?= =?UTF-8?q?=F0=9F=94=A5=20chore(EditNodeModal):=20remove=20unused=20import?= =?UTF-8?q?=20for=20'TextAreaComponent'=20to=20improve=20code=20cleanlines?= =?UTF-8?q?s=20and=20remove=20unnecessary=20complexity=20=F0=9F=94=A5=20ch?= =?UTF-8?q?ore(EditNodeModal):=20remove=20unused=20import=20for=20'useStat?= =?UTF-8?q?e'=20to=20improve=20code=20cleanliness=20and=20remove=20unneces?= =?UTF-8?q?sary=20complexity=20=F0=9F=94=A5=20chore(EditNodeModal):=20remo?= =?UTF-8?q?ve=20unused=20import=20for=20'useEffect'=20to=20improve=20code?= =?UTF-8?q?=20cleanliness=20and=20remove=20unnecessary=20complexity=20?= =?UTF-8?q?=F0=9F=94=A5=20chore(EditNodeModal):=20remove=20unused=20import?= =?UTF-8?q?=20for=20'useContext'=20to=20improve=20code=20cleanliness=20and?= =?UTF-8?q?=20remove=20unnecessary=20complexity=20=F0=9F=94=A5=20chore(Edi?= =?UTF-8?q?tNodeModal):=20remove=20unused=20import=20for=20'forwardRef'=20?= =?UTF-8?q?to=20improve=20code=20cleanliness=20and=20remove=20unnecessary?= =?UTF-8?q?=20complexity=20=F0=9F=94=A5=20chore(EditNodeModal):=20remove?= =?UTF-8?q?=20unused=20import=20for=20'classNames'=20to=20improve=20code?= =?UTF-8?q?=20cleanliness=20and=20remove=20unnecessary=20complexity=20?= =?UTF-8?q?=F0=9F=94=A5=20chore(EditNodeModal):=20remove=20unused=20import?= =?UTF-8?q?=20for=20'convertObjToArray'=20to=20improve=20code=20cleanlines?= =?UTF-8?q?s=20and=20remove=20unnecessary=20complexity=20=F0=9F=94=A5=20ch?= =?UTF-8?q?ore(EditNodeModal):=20remove=20unused=20import=20for=20'convert?= =?UTF-8?q?ArrayToObj'=20to=20improve=20code=20cleanliness=20and=20remove?= =?UTF-8?q?=20unnecessary=20complexity=20=F0=9F=94=A5=20chore(EditNodeModa?= =?UTF-8?q?l):=20remove=20unused=20import=20for=20'hasDuplicateKeys'=20to?= =?UTF-8?q?=20improve=20code=20cleanliness=20and=20remove=20unnecessary=20?= =?UTF-8?q?complexity=20=F0=9F=94=A5=20chore(EditNodeModal):=20remove?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/modals/EditNodeModal/index.tsx | 43 ++----------------- 1 file changed, 3 insertions(+), 40 deletions(-) diff --git a/src/frontend/src/modals/EditNodeModal/index.tsx b/src/frontend/src/modals/EditNodeModal/index.tsx index c47b2503a..f27347897 100644 --- a/src/frontend/src/modals/EditNodeModal/index.tsx +++ b/src/frontend/src/modals/EditNodeModal/index.tsx @@ -55,7 +55,6 @@ const EditNodeModal = forwardRef( const [myData, setMyData] = useState(data); const { setTabsState, tabId } = useContext(TabsContext); const { reactFlowInstance } = useContext(typesContext); - const [errorDuplicateKey, setErrorDuplicateKey] = useState(false); let disabled = reactFlowInstance @@ -86,19 +85,6 @@ const EditNodeModal = forwardRef( setMyData(data); // reset data to what it is on node when opening modal }, [modalOpen]); - const [dict, setDict] = useState({ - key1: "value1", - key2: "value2", - key3: "value3", - key4: "value4", - key5: "value5", - key6: "value6", - } as {}); - const [dictArr, setDictArr] = useState([] as string[]); - - useEffect(() => { - setDictArr(convertObjToArray(dict)); - }, [dict]); const [obj, setObj] = useState({ arr: ["test", 123456, false, null], @@ -135,8 +121,7 @@ const EditNodeModal = forwardRef(
limitScrollFieldsModal || - nodeLength > dictArr.length + nodeLength > limitScrollFieldsModal ? "overflow-scroll overflow-x-hidden custom-scroll" : "overflow-hidden" )} @@ -213,34 +198,12 @@ const EditNodeModal = forwardRef( editNode={false} value={obj} onChange={(newValue) => { - setDict(newValue); + setObj(newValue); }} />
) - : myData.node?.template[templateParam] - .type === "keypairlist" ? ( -
- { - setErrorDuplicateKey( - hasDuplicateKeys(newValue) - ); - if (hasDuplicateKeys(newValue)) { - setDictArr(newValue); - } else { - setDict( - convertArrayToObj(newValue) - ); - } - }} - /> -
- ) : myData.node.template[templateParam] + : myData.node.template[templateParam] .multiline ? (