feature: migrated path inputs to new component

This commit is contained in:
Sheen Capadngan
2024-04-26 18:18:23 +08:00
parent 5142e6e5f6
commit 656ec4bf16
14 changed files with 88 additions and 68 deletions
@@ -43,19 +43,26 @@ export const SecretPathInput = ({
});
useEffect(() => {
setInputValue(propValue ?? "");
const initialValue = propValue ?? "/";
setInputValue(initialValue);
setSecretPath(initialValue);
onChange?.({ target: { value: initialValue } } as any);
}, [propValue]);
useEffect(() => {
setInputValue("/");
setSecretPath("/");
if (environment) {
setInputValue("/");
setSecretPath("/");
onChange?.({ target: { value: "/" } } as any);
}
}, [environment]);
useEffect(() => {
// update secret path if input is valid
if (
debouncedInputValue.length > 0 &&
debouncedInputValue[debouncedInputValue.length - 1] === "/"
(debouncedInputValue.length > 0 &&
debouncedInputValue[debouncedInputValue.length - 1] === "/") ||
debouncedInputValue.length === 0
) {
setSecretPath(debouncedInputValue);
}