🐛 fix(parameterComponent): fix incorrect condition for rendering component based on type
🐛 fix(keypairListComponent): remove console.log statement 🐛 fix(keypairListComponent): add class 'input-invalid' to input when duplicate key is detected 🐛 fix(EditNodeModal): fix incorrect condition for rendering KeypairListComponent based on type 🎨 style(applies.css): add styles for 'input-invalid' class to indicate invalid input
This commit is contained in:
parent
7d1a6c310d
commit
3d82767950
4 changed files with 34 additions and 9 deletions
|
|
@ -224,7 +224,7 @@ export default function ParameterComponent({
|
||||||
type === "int") &&
|
type === "int") &&
|
||||||
!optionalHandle ? (
|
!optionalHandle ? (
|
||||||
<></>
|
<></>
|
||||||
) : left === true && type === "str" ? (
|
) : left === true && type === "dict" ? (
|
||||||
<div className="mt-2 w-full">
|
<div className="mt-2 w-full">
|
||||||
<KeypairListComponent
|
<KeypairListComponent
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,6 @@ export default function KeypairListComponent({
|
||||||
onChange([""]);
|
onChange([""]);
|
||||||
}
|
}
|
||||||
}, [disabled]);
|
}, [disabled]);
|
||||||
|
|
||||||
console.log(duplicateKey);
|
|
||||||
|
|
||||||
|
|
||||||
const handleChangeKey = (event, idx) => {
|
const handleChangeKey = (event, idx) => {
|
||||||
|
|
@ -54,7 +52,12 @@ export default function KeypairListComponent({
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
type="text"
|
type="text"
|
||||||
value={key}
|
value={key}
|
||||||
className={editNode ? "input-edit-node" : ""}
|
className={classNames(
|
||||||
|
editNode
|
||||||
|
? "input-edit-node"
|
||||||
|
: "",
|
||||||
|
duplicateKey ? "input-invalid" : ""
|
||||||
|
)}
|
||||||
placeholder="Type key..."
|
placeholder="Type key..."
|
||||||
onChange={(event) => handleChangeKey(event, index)}
|
onChange={(event) => handleChangeKey(event, index)}
|
||||||
onKeyDown={(e) => {
|
onKeyDown={(e) => {
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,11 @@ import { TabsContext } from "../../contexts/tabsContext";
|
||||||
import { typesContext } from "../../contexts/typesContext";
|
import { typesContext } from "../../contexts/typesContext";
|
||||||
import { NodeDataType } from "../../types/flow";
|
import { NodeDataType } from "../../types/flow";
|
||||||
import { TabsState } from "../../types/tabs";
|
import { TabsState } from "../../types/tabs";
|
||||||
|
import {
|
||||||
|
convertArrayToObj,
|
||||||
|
convertObjToArray,
|
||||||
|
hasDuplicateKeys,
|
||||||
|
} from "../../utils/reactflowUtils";
|
||||||
import { classNames } from "../../utils/utils";
|
import { classNames } from "../../utils/utils";
|
||||||
import BaseModal from "../baseModal";
|
import BaseModal from "../baseModal";
|
||||||
|
|
||||||
|
|
@ -49,6 +54,7 @@ const EditNodeModal = forwardRef(
|
||||||
const [myData, setMyData] = useState(data);
|
const [myData, setMyData] = useState(data);
|
||||||
const { setTabsState, tabId } = useContext(TabsContext);
|
const { setTabsState, tabId } = useContext(TabsContext);
|
||||||
const { reactFlowInstance } = useContext(typesContext);
|
const { reactFlowInstance } = useContext(typesContext);
|
||||||
|
const [errorDuplicateKey, setErrorDuplicateKey] = useState(false);
|
||||||
|
|
||||||
let disabled =
|
let disabled =
|
||||||
reactFlowInstance
|
reactFlowInstance
|
||||||
|
|
@ -87,10 +93,10 @@ const EditNodeModal = forwardRef(
|
||||||
key5: "value5",
|
key5: "value5",
|
||||||
key6: "value6",
|
key6: "value6",
|
||||||
} as {});
|
} as {});
|
||||||
const [dictArr, setDictArr] = useState([]);
|
const [dictArr, setDictArr] = useState([] as string[]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
convertToArray(dict);
|
setDictArr(convertObjToArray(dict));
|
||||||
}, [dict]);
|
}, [dict]);
|
||||||
|
|
||||||
const convertToArray = (singleObject) => {
|
const convertToArray = (singleObject) => {
|
||||||
|
|
@ -208,13 +214,25 @@ const EditNodeModal = forwardRef(
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
) : myData.node?.template[templateParam]
|
) : myData.node?.template[templateParam]
|
||||||
.type === "str" ? (
|
.type === "dict" ? (
|
||||||
<div className="mt-2 w-full">
|
<div className="mt-2 w-full">
|
||||||
<KeypairListComponent
|
<KeypairListComponent
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
editNode={true}
|
editNode={false}
|
||||||
value={dictArr}
|
value={dictArr}
|
||||||
onChange={convertToDict}
|
duplicateKey={errorDuplicateKey}
|
||||||
|
onChange={(newValue: string[]) => {
|
||||||
|
setErrorDuplicateKey(
|
||||||
|
hasDuplicateKeys(newValue)
|
||||||
|
);
|
||||||
|
if (hasDuplicateKeys(newValue)) {
|
||||||
|
setDictArr(newValue);
|
||||||
|
} else {
|
||||||
|
setDict(
|
||||||
|
convertArrayToObj(newValue)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : myData.node.template[templateParam]
|
) : myData.node.template[templateParam]
|
||||||
|
|
|
||||||
|
|
@ -1037,4 +1037,8 @@
|
||||||
.label-invalid{
|
.label-invalid{
|
||||||
@apply text-destructive
|
@apply text-destructive
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.input-invalid{
|
||||||
|
@apply border-destructive focus:ring-destructive focus:border-destructive
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue