import { useParams } from 'common' import Link from 'next/link' import { useState } from 'react' import toast from 'react-hot-toast' import { Button, IconExternalLink, IconSearch, Input, Modal } from 'ui' import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal' import Table from 'components/to-be-cleaned/Table' import AlertError from 'components/ui/AlertError' import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader' import { useSecretsDeleteMutation } from 'data/secrets/secrets-delete-mutation' import { ProjectSecret, useSecretsQuery } from 'data/secrets/secrets-query' import AddNewSecretModal from './AddNewSecretModal' import EdgeFunctionSecret from './EdgeFunctionSecret' const EdgeFunctionSecrets = () => { const { ref: projectRef } = useParams() const [searchString, setSearchString] = useState('') const [showCreateSecret, setShowCreateSecret] = useState(false) const [selectedSecret, setSelectedSecret] = useState() const { data, error, isLoading, isSuccess, isError } = useSecretsQuery({ projectRef: projectRef, }) const { mutate: deleteSecret, isLoading: isDeleting } = useSecretsDeleteMutation({ onSuccess: () => { toast.success(`Successfully deleted ${selectedSecret?.name}`) setSelectedSecret(undefined) }, }) const secrets = searchString.length > 0 ? data?.filter((secret) => secret.name.toLowerCase().includes(searchString.toLowerCase())) ?? [] : data ?? [] return ( <>

Edge Function Secrets Management

Manage the secrets for your project's edge functions
{isLoading && } {isError && } {isSuccess && (
setSearchString(e.target.value)} icon={} />
Name, Digest, , ]} body={ secrets.length > 0 ? ( secrets.map((secret) => ( setSelectedSecret(secret)} /> )) ) : secrets.length === 0 && searchString.length > 0 ? (

No results found

Your search for "{searchString}" did not return any results

) : (

No secrets created

There are no secrets associated with your project yet

) } /> )} setShowCreateSecret(false)} /> setSelectedSecret(undefined)} onConfirm={() => { if (selectedSecret !== undefined) { deleteSecret({ projectRef, secrets: [selectedSecret.name] }) } }} >

Before removing this secret, do ensure that none of your edge functions are currently actively using this secret. This action cannot be undone.

) } export default EdgeFunctionSecrets