mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 03:27:38 +00:00
adjustment: finalized InfisicalSecretInput
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable react/no-danger */
|
/* eslint-disable react/no-danger */
|
||||||
import React, { forwardRef, TextareaHTMLAttributes, useRef, useState } from "react";
|
import React, { forwardRef, TextareaHTMLAttributes, useEffect, useRef, useState } from "react";
|
||||||
import { twMerge } from "tailwind-merge";
|
import { twMerge } from "tailwind-merge";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -97,15 +97,23 @@ export const InfisicalSecretInput = forwardRef<HTMLTextAreaElement, Props>(
|
|||||||
const [referenceKey, setReferenceKey] = useState<string>();
|
const [referenceKey, setReferenceKey] = useState<string>();
|
||||||
const [lastCaretPos, setLastCaretPos] = useState<number>(0);
|
const [lastCaretPos, setLastCaretPos] = useState<number>(0);
|
||||||
|
|
||||||
const isCaretInsideReference = (str: string, start: number) => {
|
useEffect(() => {
|
||||||
const match = [...str.matchAll(REGEX_SECRET_REFERENCE_FIND)].find(
|
setValue(propValue as string);
|
||||||
(entry) =>
|
}, [propValue]);
|
||||||
typeof entry?.index !== "undefined" &&
|
|
||||||
entry.index <= start &&
|
|
||||||
start < entry.index + entry[0].length
|
|
||||||
);
|
|
||||||
|
|
||||||
return match || null;
|
const isCaretInsideReference = (str: string, start: number) => {
|
||||||
|
if (str) {
|
||||||
|
const match = [...str.matchAll(REGEX_SECRET_REFERENCE_FIND)].find(
|
||||||
|
(entry) =>
|
||||||
|
typeof entry?.index !== "undefined" &&
|
||||||
|
entry.index <= start &&
|
||||||
|
start < entry.index + entry[0].length
|
||||||
|
);
|
||||||
|
|
||||||
|
return match || null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const setCaretPos = (caretPos: number) => {
|
const setCaretPos = (caretPos: number) => {
|
||||||
@@ -299,7 +307,7 @@ export const InfisicalSecretInput = forwardRef<HTMLTextAreaElement, Props>(
|
|||||||
if (!showReferencePopup) setIsSecretFocused.off();
|
if (!showReferencePopup) setIsSecretFocused.off();
|
||||||
}}
|
}}
|
||||||
{...props}
|
{...props}
|
||||||
value={value}
|
value={value || ""}
|
||||||
readOnly={isReadOnly}
|
readOnly={isReadOnly}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+1
@@ -100,6 +100,7 @@ export const SecretEditRow = ({
|
|||||||
<InfisicalSecretInput
|
<InfisicalSecretInput
|
||||||
{...field}
|
{...field}
|
||||||
value={field.value as string}
|
value={field.value as string}
|
||||||
|
key="secret-input"
|
||||||
isVisible={isVisible}
|
isVisible={isVisible}
|
||||||
secretPath={secretPath}
|
secretPath={secretPath}
|
||||||
environment={environment}
|
environment={environment}
|
||||||
|
|||||||
Reference in New Issue
Block a user