mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 14:27:59 +00:00
fix: requested changes
This commit is contained in:
@@ -61,6 +61,8 @@ export const CreateSecretForm = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const secretKeyInputRef = useRef<HTMLInputElement>(null);
|
const secretKeyInputRef = useRef<HTMLInputElement>(null);
|
||||||
|
const { ref: setSecretKeyHookRef, ...secretKeyRegisterRest } = register("key");
|
||||||
|
|
||||||
const secretKey = watch("key");
|
const secretKey = watch("key");
|
||||||
|
|
||||||
const slugSchema = z.string().trim().toLowerCase().min(1);
|
const slugSchema = z.string().trim().toLowerCase().min(1);
|
||||||
@@ -122,12 +124,11 @@ export const CreateSecretForm = ({
|
|||||||
secretKeyInputRef.current.selectionEnd === secretKeyInputRef.current.value.length;
|
secretKeyInputRef.current.selectionEnd === secretKeyInputRef.current.value.length;
|
||||||
|
|
||||||
if (!secretKey || isWholeKeyHighlighted) {
|
if (!secretKey || isWholeKeyHighlighted) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
setValue("key", key);
|
setValue("key", key);
|
||||||
setValue("value", value);
|
setValue("value", value);
|
||||||
}
|
}
|
||||||
if (!secretKey) {
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -139,8 +140,15 @@ export const CreateSecretForm = ({
|
|||||||
errorText={errors?.key?.message}
|
errorText={errors?.key?.message}
|
||||||
>
|
>
|
||||||
<Input
|
<Input
|
||||||
{...register("key")}
|
{...secretKeyRegisterRest}
|
||||||
ref={secretKeyInputRef}
|
ref={(e) => {
|
||||||
|
setSecretKeyHookRef(e);
|
||||||
|
// Can't directly set secretKeyInputRef.current = e, because of read-only property definitions
|
||||||
|
Object.defineProperty(secretKeyInputRef, "current", {
|
||||||
|
value: e,
|
||||||
|
writable: true
|
||||||
|
});
|
||||||
|
}}
|
||||||
placeholder="Type your secret name"
|
placeholder="Type your secret name"
|
||||||
onPaste={handlePaste}
|
onPaste={handlePaste}
|
||||||
autoCapitalization={autoCapitalize}
|
autoCapitalization={autoCapitalize}
|
||||||
|
|||||||
+13
-5
@@ -63,6 +63,8 @@ export const CreateSecretForm = ({ secretPath = "/", onClose }: Props) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const secretKeyInputRef = useRef<HTMLInputElement>(null);
|
const secretKeyInputRef = useRef<HTMLInputElement>(null);
|
||||||
|
const { ref: setSecretKeyHookRef, ...secretKeyRegisterRest } = register("key");
|
||||||
|
|
||||||
const secretKey = watch("key");
|
const secretKey = watch("key");
|
||||||
|
|
||||||
const handleFormSubmit = async ({ key, value, environments: selectedEnv, tags }: TFormSchema) => {
|
const handleFormSubmit = async ({ key, value, environments: selectedEnv, tags }: TFormSchema) => {
|
||||||
@@ -166,12 +168,11 @@ export const CreateSecretForm = ({ secretPath = "/", onClose }: Props) => {
|
|||||||
secretKeyInputRef.current.selectionEnd === secretKeyInputRef.current.value.length;
|
secretKeyInputRef.current.selectionEnd === secretKeyInputRef.current.value.length;
|
||||||
|
|
||||||
if (!secretKey || isWholeKeyHighlighted) {
|
if (!secretKey || isWholeKeyHighlighted) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
setValue("key", key);
|
setValue("key", key);
|
||||||
setValue("value", value);
|
setValue("value", value);
|
||||||
}
|
}
|
||||||
if (!secretKey) {
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const createWsTag = useCreateWsTag();
|
const createWsTag = useCreateWsTag();
|
||||||
@@ -202,8 +203,15 @@ export const CreateSecretForm = ({ secretPath = "/", onClose }: Props) => {
|
|||||||
errorText={errors?.key?.message}
|
errorText={errors?.key?.message}
|
||||||
>
|
>
|
||||||
<Input
|
<Input
|
||||||
{...register("key")}
|
{...secretKeyRegisterRest}
|
||||||
ref={secretKeyInputRef}
|
ref={(e) => {
|
||||||
|
setSecretKeyHookRef(e);
|
||||||
|
// Can't directly set secretKeyInputRef.current = e, because of read-only property definitions
|
||||||
|
Object.defineProperty(secretKeyInputRef, "current", {
|
||||||
|
value: e,
|
||||||
|
writable: true
|
||||||
|
});
|
||||||
|
}}
|
||||||
placeholder="Type your secret name"
|
placeholder="Type your secret name"
|
||||||
onPaste={handlePaste}
|
onPaste={handlePaste}
|
||||||
autoCapitalization={currentWorkspace?.autoCapitalization}
|
autoCapitalization={currentWorkspace?.autoCapitalization}
|
||||||
|
|||||||
Reference in New Issue
Block a user