diff --git a/frontend/components/environments/secrets/SecretRow.tsx b/frontend/components/environments/secrets/SecretRow.tsx index 66a911209..e008553e0 100644 --- a/frontend/components/environments/secrets/SecretRow.tsx +++ b/frontend/components/environments/secrets/SecretRow.tsx @@ -1,5 +1,5 @@ import { EnvironmentType, SecretType } from '@/apollo/graphql' -import { useState } from 'react' +import { useEffect, useRef, useState } from 'react' import { FaEyeSlash, FaEye } from 'react-icons/fa' import { Button } from '../../common/Button' @@ -27,8 +27,20 @@ export default function SecretRow(props: { const [isRevealed, setIsRevealed] = useState(false) + const keyInputRef = useRef(null) + const [readSecret] = useMutation(LogSecretRead) + // Reveal newly created secrets by default + useEffect(() => { + if (cannonicalSecret === undefined) { + setIsRevealed(true) + if (keyInputRef.current) { + keyInputRef.current.focus() + } + } + }, [cannonicalSecret]) + const handleRevealSecret = async () => { setIsRevealed(true) if (cannonicalSecret !== undefined) await readSecret({ variables: { id: secret.id } }) @@ -62,6 +74,7 @@ export default function SecretRow(props: {