mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
fix: requested changes
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { ClipboardEvent } from "react";
|
||||
import { ClipboardEvent, useRef } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { faTriangleExclamation } from "@fortawesome/free-solid-svg-icons";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
@@ -60,7 +60,7 @@ export const CreateSecretForm = ({
|
||||
canReadTags ? workspaceId : ""
|
||||
);
|
||||
|
||||
const secretValue = watch("value");
|
||||
const secretKeyInputRef = useRef<HTMLInputElement>(null);
|
||||
const secretKey = watch("key");
|
||||
|
||||
const slugSchema = z.string().trim().toLowerCase().min(1);
|
||||
@@ -116,13 +116,15 @@ export const CreateSecretForm = ({
|
||||
const pastedContent = e.clipboardData.getData("text");
|
||||
const { key, value } = getKeyValue(pastedContent, delimitters);
|
||||
|
||||
if (!secretKey) {
|
||||
const isWholeKeyHighlighted =
|
||||
secretKeyInputRef.current &&
|
||||
secretKeyInputRef.current.selectionStart === 0 &&
|
||||
secretKeyInputRef.current.selectionEnd === secretKeyInputRef.current.value.length;
|
||||
|
||||
if (!secretKey || isWholeKeyHighlighted) {
|
||||
setValue("key", key);
|
||||
}
|
||||
if (!secretValue) {
|
||||
setValue("value", value);
|
||||
}
|
||||
|
||||
if (!secretKey) {
|
||||
e.preventDefault();
|
||||
}
|
||||
@@ -138,6 +140,7 @@ export const CreateSecretForm = ({
|
||||
>
|
||||
<Input
|
||||
{...register("key")}
|
||||
ref={secretKeyInputRef}
|
||||
placeholder="Type your secret name"
|
||||
onPaste={handlePaste}
|
||||
autoCapitalization={autoCapitalize}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ClipboardEvent } from "react";
|
||||
import { ClipboardEvent, useRef } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { subject } from "@casl/ability";
|
||||
import { faTriangleExclamation } from "@fortawesome/free-solid-svg-icons";
|
||||
@@ -62,7 +62,7 @@ export const CreateSecretForm = ({ secretPath = "/", onClose }: Props) => {
|
||||
canReadTags ? workspaceId : ""
|
||||
);
|
||||
|
||||
const secretValue = watch("value");
|
||||
const secretKeyInputRef = useRef<HTMLInputElement>(null);
|
||||
const secretKey = watch("key");
|
||||
|
||||
const handleFormSubmit = async ({ key, value, environments: selectedEnv, tags }: TFormSchema) => {
|
||||
@@ -160,13 +160,15 @@ export const CreateSecretForm = ({ secretPath = "/", onClose }: Props) => {
|
||||
const pastedContent = e.clipboardData.getData("text");
|
||||
const { key, value } = getKeyValue(pastedContent, delimitters);
|
||||
|
||||
if (!secretKey) {
|
||||
const isWholeKeyHighlighted =
|
||||
secretKeyInputRef.current &&
|
||||
secretKeyInputRef.current.selectionStart === 0 &&
|
||||
secretKeyInputRef.current.selectionEnd === secretKeyInputRef.current.value.length;
|
||||
|
||||
if (!secretKey || isWholeKeyHighlighted) {
|
||||
setValue("key", key);
|
||||
}
|
||||
if (!secretValue) {
|
||||
setValue("value", value);
|
||||
}
|
||||
|
||||
if (!secretKey) {
|
||||
e.preventDefault();
|
||||
}
|
||||
@@ -201,6 +203,7 @@ export const CreateSecretForm = ({ secretPath = "/", onClose }: Props) => {
|
||||
>
|
||||
<Input
|
||||
{...register("key")}
|
||||
ref={secretKeyInputRef}
|
||||
placeholder="Type your secret name"
|
||||
onPaste={handlePaste}
|
||||
autoCapitalization={currentWorkspace?.autoCapitalization}
|
||||
|
||||
Reference in New Issue
Block a user