/* eslint-disable react/jsx-no-useless-fragment */ import { useCallback, useRef, useState } from "react"; import { faEye, faEyeSlash, faKey, faMinus } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { useSyntaxHighlight } from "@app/hooks"; import { useToggle } from "@app/hooks/useToggle"; type Props = { secrets: any[] | undefined; // permission and external state's that decided to hide or show isReadOnly?: boolean; isSecretValueHidden: boolean; userAvailableEnvs?: any[]; }; const SEC_VAL_LINE_HEIGHT = 21; const MAX_MULTI_LINE = 6; const DashboardInput = ({ isOverridden, isSecretValueHidden, secret, isReadOnly = true }: { isOverridden: boolean; isSecretValueHidden: boolean; isReadOnly?: boolean; secret?: any; }): JSX.Element => { const ref = useRef(null); const [isFocused, setIsFocused] = useToggle(); const syntaxHighlight = useSyntaxHighlight(); const value = isOverridden ? secret.valueOverride : secret?.value; const multilineExpandUnit = ((value?.match(/\n/g)?.length || 0) + 1) * SEC_VAL_LINE_HEIGHT; const maxMultilineHeight = Math.min(multilineExpandUnit, 21 * MAX_MULTI_LINE); return (