From 1c1d6d2c023444034f0b07fc86069dc2e1eebad0 Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Thu, 14 Sep 2023 19:53:39 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20fix(parameterComponent):=20remov?= =?UTF-8?q?e=20unused=20longString=20variable=20to=20improve=20code=20read?= =?UTF-8?q?ability=20and=20reduce=20unnecessary=20code=20=F0=9F=94=A7=20fi?= =?UTF-8?q?x(parameterComponent):=20move=20DictComponent=20and=20KeypairLi?= =?UTF-8?q?stComponent=20rendering=20logic=20to=20the=20correct=20position?= =?UTF-8?q?=20to=20fix=20rendering=20issues=20=F0=9F=94=A7=20fix(keypairLi?= =?UTF-8?q?stComponent):=20remove=20unused=20imports=20and=20fix=20formatt?= =?UTF-8?q?ing=20to=20improve=20code=20readability=20=F0=9F=94=A7=20fix(ke?= =?UTF-8?q?ypairListComponent):=20fix=20handleChangeKey=20function=20name?= =?UTF-8?q?=20to=20improve=20code=20clarity=20=F0=9F=94=A7=20fix(keypairLi?= =?UTF-8?q?stComponent):=20fix=20className=20prop=20in=20Input=20component?= =?UTF-8?q?=20to=20improve=20code=20readability=20=F0=9F=94=A7=20fix(keypa?= =?UTF-8?q?irListComponent):=20remove=20unused=20GenericModal=20component?= =?UTF-8?q?=20and=20fix=20formatting=20to=20improve=20code=20readability?= =?UTF-8?q?=20=F0=9F=94=A7=20fix(reactflowUtils.ts):=20fix=20formatting=20?= =?UTF-8?q?and=20remove=20unnecessary=20whitespace=20to=20improve=20code?= =?UTF-8?q?=20readability=20=F0=9F=94=A7=20fix(reactflowUtils.ts):=20fix?= =?UTF-8?q?=20function=20names=20and=20formatting=20to=20improve=20code=20?= =?UTF-8?q?readability=20=F0=9F=94=A7=20fix(reactflowUtils.ts):=20fix=20fo?= =?UTF-8?q?rmatting=20and=20remove=20unnecessary=20whitespace=20to=20impro?= =?UTF-8?q?ve=20code=20readability=20=F0=9F=94=A7=20fix(reactflowUtils.ts)?= =?UTF-8?q?:=20fix=20formatting=20and=20remove=20unnecessary=20whitespace?= =?UTF-8?q?=20to=20improve=20code=20readability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/parameterComponent/index.tsx | 61 ++++++++++--------- .../components/keypairListComponent/index.tsx | 39 +++++------- src/frontend/src/utils/reactflowUtils.ts | 23 ++++--- 3 files changed, 56 insertions(+), 67 deletions(-) diff --git a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx index 7f5f5dc84..f0264ee2d 100644 --- a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx @@ -103,8 +103,6 @@ export default function ParameterComponent({ const [obj, setObj] = useState({ arr: ["test", 123456, false, null], boolean: false, - longString: - "long string long string long string long string long string long string", number: 123456, try: { k1: 123, @@ -239,34 +237,6 @@ export default function ParameterComponent({ type === "int") && !optionalHandle ? ( <> - ) : left === true && type === "NestedDict" ? ( -
- { - setObj(newValue); - }} - /> -
- ) : left === true && type === "dict" ? ( -
- { - setErrorDuplicateKey(hasDuplicateKeys(newValue)); - if (hasDuplicateKeys(newValue)) { - setDictArr(newValue); - } else { - setDict(convertArrayToObj(newValue)); - } - }} - /> -
) : ( + ) : left === true && type === "NestedDict" ? ( +
+ { + setObj(newValue); + data.node!.template[name].value = newValue; + console.log(data); + }} + /> +
+ ) : left === true && type === "dict" ? ( +
+ { + setErrorDuplicateKey(hasDuplicateKeys(newValue)); + if (hasDuplicateKeys(newValue)) { + setDictArr(newValue); + } else { + setDict(convertArrayToObj(newValue)); + data.node!.template[name].value = convertArrayToObj(newValue); + } + }} + /> +
) : ( <> )} diff --git a/src/frontend/src/components/keypairListComponent/index.tsx b/src/frontend/src/components/keypairListComponent/index.tsx index ef3f58e39..b88b17946 100644 --- a/src/frontend/src/components/keypairListComponent/index.tsx +++ b/src/frontend/src/components/keypairListComponent/index.tsx @@ -2,8 +2,6 @@ import { useEffect } from "react"; import { KeyPairListComponentType } from "../../types/components"; import _ from "lodash"; -import { TypeModal } from "../../constants/enums"; -import GenericModal from "../../modals/genericModal"; import { classNames } from "../../utils/utils"; import IconComponent from "../genericIconComponent"; import { Input } from "../ui/input"; @@ -13,7 +11,7 @@ export default function KeypairListComponent({ onChange, disabled, editNode = false, - duplicateKey + duplicateKey, }: KeyPairListComponentType): JSX.Element { useEffect(() => { if (disabled) { @@ -56,9 +54,8 @@ export default function KeypairListComponent({ // /> // // ) - - const handleChangeKey = (event, idx) => { + const handleChangeKey = (event, idx) => { const newInputList = _.cloneDeep(value); const oldKey = Object.keys(newInputList[idx])[0]; const updatedObj = { [event.target.value]: newInputList[idx][oldKey] }; @@ -89,10 +86,8 @@ export default function KeypairListComponent({ type="text" value={key} className={classNames( - editNode - ? "input-edit-node" - : "", - duplicateKey ? "input-invalid" : "" + editNode ? "input-edit-node" : "", + duplicateKey ? "input-invalid" : "" )} placeholder="Type key..." onChange={(event) => handleChangeKey(event, index)} @@ -103,23 +98,17 @@ export default function KeypairListComponent({ } }} /> - { - handleChangeValue(value, index); - }} - > - - + className={editNode ? "input-edit-node" : ""} + placeholder="Click to input a value..." + onChange={(event) => + handleChangeValue(event.target.value, index) + } + /> {index === value.length - 1 ? (