From 28c8b3160e0005e5baabcabfe72783907504db04 Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Tue, 5 Sep 2023 10:58:11 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20fix(parameterComponent):=20remov?= =?UTF-8?q?e=20unused=20errorDuplicateKey=20state=20variable=20?= =?UTF-8?q?=F0=9F=94=A7=20fix(parameterComponent):=20remove=20unused=20dic?= =?UTF-8?q?t=20and=20dictArr=20state=20variables=20=F0=9F=94=A7=20fix(para?= =?UTF-8?q?meterComponent):=20remove=20unused=20useEffect=20hook=20?= =?UTF-8?q?=F0=9F=94=A7=20fix(parameterComponent):=20update=20onChange=20h?= =?UTF-8?q?andler=20to=20setObj=20instead=20of=20setDict=20=F0=9F=94=A7=20?= =?UTF-8?q?fix(keypairListComponent):=20remove=20commented=20out=20code=20?= =?UTF-8?q?for=20future=20feature=20=F0=9F=94=A7=20fix(EditNodeModal):=20u?= =?UTF-8?q?pdate=20condition=20to=20check=20for=20"keypairlist"=20type=20i?= =?UTF-8?q?nstead=20of=20"keypair"=20type=20=F0=9F=94=A7=20fix(types):=20u?= =?UTF-8?q?pdate=20onChange=20type=20in=20DictComponentType=20to=20accept?= =?UTF-8?q?=20any=20value=20=F0=9F=94=A7=20fix(reactflowUtils):=20remove?= =?UTF-8?q?=20unnecessary=20comments=20and=20newline=20at=20end=20of=20fil?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/parameterComponent/index.tsx | 37 +------------------ .../components/keypairListComponent/index.tsx | 36 ++++++++++++++++++ .../src/modals/EditNodeModal/index.tsx | 2 +- src/frontend/src/types/components/index.ts | 2 +- src/frontend/src/utils/reactflowUtils.ts | 4 +- 5 files changed, 42 insertions(+), 39 deletions(-) diff --git a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx index c5623d3fa..a2313e4c0 100644 --- a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx @@ -54,7 +54,6 @@ export default function ParameterComponent({ const updateNodeInternals = useUpdateNodeInternals(); const [position, setPosition] = useState(0); const { setTabsState, tabId, save, flows } = useContext(TabsContext); - const [errorDuplicateKey, setErrorDuplicateKey] = useState(false); const flow = flows.find((flow) => flow.id === tabId)?.data?.nodes ?? null; @@ -96,20 +95,6 @@ export default function ParameterComponent({ renderTooltips(); }; - 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], @@ -248,30 +233,12 @@ export default function ParameterComponent({ editNode={false} value={obj} onChange={(newValue) => { - setDict(newValue); + setObj(newValue); }} /> ) - : left === true && type === "keypair" ? ( -
- { - setErrorDuplicateKey(hasDuplicateKeys(newValue)); - if(hasDuplicateKeys(newValue)){ - setDictArr(newValue); - } - else{ - setDict(convertArrayToObj(newValue)); - } - }} - /> -
- ) : ( + : ( { + // setDictArr(convertObjToArray(dict)); + // }, [dict]); + + // left === true && type === "keypairlist" ? ( + //
+ // { + // setErrorDuplicateKey(hasDuplicateKeys(newValue)); + // if(hasDuplicateKeys(newValue)){ + // setDictArr(newValue); + // } + // else{ + // setDict(convertArrayToObj(newValue)); + // } + // }} + // /> + //
+ // ) const handleChangeKey = (event, idx) => { diff --git a/src/frontend/src/modals/EditNodeModal/index.tsx b/src/frontend/src/modals/EditNodeModal/index.tsx index 437cdf232..c47b2503a 100644 --- a/src/frontend/src/modals/EditNodeModal/index.tsx +++ b/src/frontend/src/modals/EditNodeModal/index.tsx @@ -219,7 +219,7 @@ const EditNodeModal = forwardRef( ) : myData.node?.template[templateParam] - .type === "keypair" ? ( + .type === "keypairlist" ? (
void; + onChange: (value) => void; disabled: boolean; editNode?: boolean; }; diff --git a/src/frontend/src/utils/reactflowUtils.ts b/src/frontend/src/utils/reactflowUtils.ts index 1394203f1..7c58864b2 100644 --- a/src/frontend/src/utils/reactflowUtils.ts +++ b/src/frontend/src/utils/reactflowUtils.ts @@ -321,10 +321,10 @@ export function hasDuplicateKeys(array) { for (const obj of array) { for (const key in obj) { if (keys[key]) { - return true; // Duplicate key found + return true; } keys[key] = true; } } - return false; // No duplicate keys found + return false; } \ No newline at end of file