adjustment: added isImport handling

This commit is contained in:
Sheen Capadngan
2024-04-23 11:17:12 +08:00
parent fb69236f47
commit 2200bd646e
@@ -19,7 +19,8 @@ const replaceContentWithDot = (str: string) => {
return finalStr; return finalStr;
}; };
const syntaxHighlight = (content?: string | null, isVisible?: boolean) => { const syntaxHighlight = (content?: string | null, isVisible?: boolean, isImport?: boolean) => {
if (isImport) return "IMPORTED";
if (content === "") return "EMPTY"; if (content === "") return "EMPTY";
if (!content) return "EMPTY"; if (!content) return "EMPTY";
if (!isVisible) return replaceContentWithDot(content); if (!isVisible) return replaceContentWithDot(content);
@@ -59,6 +60,7 @@ const syntaxHighlight = (content?: string | null, isVisible?: boolean) => {
type Props = TextareaHTMLAttributes<HTMLTextAreaElement> & { type Props = TextareaHTMLAttributes<HTMLTextAreaElement> & {
value?: string | null; value?: string | null;
isImport?: boolean;
isVisible?: boolean; isVisible?: boolean;
isReadOnly?: boolean; isReadOnly?: boolean;
isDisabled?: boolean; isDisabled?: boolean;
@@ -77,6 +79,7 @@ export const InfisicalSecretInput = forwardRef<HTMLTextAreaElement, Props>(
containerClassName, containerClassName,
onBlur, onBlur,
isDisabled, isDisabled,
isImport,
isReadOnly, isReadOnly,
onFocus, onFocus,
secretPath: propSecretPath, secretPath: propSecretPath,
@@ -275,7 +278,7 @@ export const InfisicalSecretInput = forwardRef<HTMLTextAreaElement, Props>(
<pre aria-hidden className="m-0 "> <pre aria-hidden className="m-0 ">
<code className={`inline-block w-full ${commonClassName}`}> <code className={`inline-block w-full ${commonClassName}`}>
<span style={{ whiteSpace: "break-spaces" }}> <span style={{ whiteSpace: "break-spaces" }}>
{syntaxHighlight(value, isVisible || isSecretFocused)} {syntaxHighlight(value, isVisible || isSecretFocused, isImport)}
</span> </span>
</code> </code>
</pre> </pre>