import { twMerge } from "tailwind-merge"; import { SecretInput, Tooltip } from "@app/components/v2"; import { Blur } from "@app/components/v2/Blur"; import { useProject } from "@app/context"; import { useToggle } from "@app/hooks"; import { useGetSecretValue } from "@app/hooks/api/dashboard/queries"; import { SecretV3RawSanitized } from "@app/hooks/api/secrets/types"; import { HIDDEN_SECRET_VALUE } from "@app/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretItem"; interface SecretOverviewRotationSecretRowProps { secret: SecretV3RawSanitized | null; isSecretVisible: boolean; environment: string; secretPath: string; } export const SecretOverviewRotationSecretRow = ({ secret, isSecretVisible, environment, secretPath }: SecretOverviewRotationSecretRowProps) => { const [isFieldFocused, setIsFieldFocused] = useToggle(); const { currentProject } = useProject(); const canFetchValue = Boolean(secret); const { data: secretValueData, isError } = useGetSecretValue( { secretKey: secret?.key ?? "", environment, secretPath, projectId: currentProject.id }, { enabled: canFetchValue && (isSecretVisible || isFieldFocused) } ); const secretValue = isError ? "Error loading secret value..." : (secretValueData?.valueOverride ?? secretValueData?.value ?? HIDDEN_SECRET_VALUE); return ( {secret?.key ?? "********"} {/* eslint-disable-next-line no-nested-ternary */} {!secret ? (
********
) : secret.secretValueHidden ? ( ) : ( setIsFieldFocused.on()} onBlur={() => setIsFieldFocused.off()} /> )}
); };