🔥 refactor(keypairListComponent): remove commented out code and unused imports for cleaner code

🐛 fix(reactflowUtils.ts): add space before key in flattenedObject to prevent ordering when adding new keys to the object
This commit is contained in:
Cristhian Zanforlin Lousa 2023-09-15 14:02:21 -03:00
commit 321024fd4c
2 changed files with 2 additions and 38 deletions

View file

@ -19,42 +19,6 @@ export default function KeypairListComponent({
}
}, [disabled]);
//when this feature is available, this code below must be in the parent component
// const [errorDuplicateKey, setErrorDuplicateKey] = useState(false);
// 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]);
// left === true && type === "keypairlist" ? (
// <div className="mt-2 w-full">
// <KeypairListComponent
// disabled={disabled}
// editNode={false}
// value={dictArr}
// duplicateKey={errorDuplicateKey}
// onChange={(newValue: string[]) => {
// setErrorDuplicateKey(hasDuplicateKeys(newValue));
// if(hasDuplicateKeys(newValue)){
// setDictArr(newValue);
// }
// else{
// setDict(convertArrayToObj(newValue));
// }
// }}
// />
// </div>
// )
const handleChangeKey = (event, idx) => {
const newInputList = _.cloneDeep(value);
const oldKey = Object.keys(newInputList[idx])[0];
@ -83,7 +47,7 @@ export default function KeypairListComponent({
<div key={idx} className="flex w-full gap-3">
<Input
type="text"
value={key}
value={key.trim()}
className={classNames(
editNode ? "input-edit-node" : "",
duplicateKey ? "input-invalid" : ""

View file

@ -307,7 +307,7 @@ export function convertArrayToObj(newValue) {
for (const obj of newValue) {
for (const key in obj) {
if (obj.hasOwnProperty(key)) {
flattenedObject[key] = obj[key];
flattenedObject[' ' + key] = obj[key]; //added space to dont order when add new keys to object
}
}
}