The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Fix edit secret modal showing decrypted secret
Joshen Lim45a8a5dc1dc2
diff --git a/studio/components/interfaces/Settings/Vault/Secrets/EditSecretModal.tsx b/studio/components/interfaces/Settings/Vault/Secrets/EditSecretModal.tsxindex 53991731c4c..c6e93afef3b 100644--- a/studio/components/interfaces/Settings/Vault/Secrets/EditSecretModal.tsx+++ b/studio/components/interfaces/Settings/Vault/Secrets/EditSecretModal.tsx@@ -1,25 +1,38 @@import { FC, useState, useEffect } from 'react'+import { useStore } from 'hooks'+import { VaultSecret } from 'types'import { Modal, Form, Input, Button, IconEyeOff, IconEye } from 'ui'import EncryptionKeySelector from '../Keys/EncryptionKeySelector'+import ShimmeringLoader from 'components/ui/ShimmeringLoader'interface Props {- selectedSecret: any+ selectedSecret: VaultSecretonClose: () => void}const EditSecretModal: FC<Props> = ({ selectedSecret, onClose }) => {+ const { vault } = useStore()+ const [isLoadingSecretValue, setIsLoadingSecretValue] = useState(false)const [showSecretValue, setShowSecretValue] = useState(false)const [selectedKeyId, setSelectedKeyId] = useState<string>()+ let INITIAL_VALUES = {+ name: selectedSecret?.name ?? '',+ description: selectedSecret?.description ?? '',+ secret: selectedSecret?.decryptedSecret ?? '',+ }+useEffect(() => {- setSelectedKeyId(selectedSecret?.key_id)+ if (selectedSecret !== undefined) {+ setShowSecretValue(false)+ setSelectedKeyId(selectedSecret?.key_id)+ }}, [selectedSecret])const validate = (values: any) => {const errors: any = {}-+ if (values.name.length === 0) errors.name = 'Please provide a name for your secret'if (values.secret.length === 0) errors.secret = 'Please enter your secret value'-return errors}@@ -40,17 +53,40 @@ const EditSecretModal: FC<Props> = ({ selectedSecret, onClose }) => {><Formid="add-new-secret-form"- initialValues={{- name: selectedSecret?.name ?? '',- description: selectedSecret?.description ?? '',- secret: selectedSecret?.secret ?? '',- }}+ initialValues={INITIAL_VALUES}validate={validate}validateOnBlur={false}onSubmit={onUpdateSecret}>- {({ isSubmitting }: any) => {- return (+ {({ isSubmitting, resetForm }: any) => {+ useEffect(() => {+ if (selectedSecret !== undefined && selectedSecret.decryptedSecret === undefined) {+ fetchSecretValue()+ }+ }, [selectedSecret])++ const fetchSecretValue = async () => {+ if (selectedSecret === undefined) return+ setIsLoadingSecretValue(true)+ const res = await vault.fetchSecretValue(selectedSecret.id)+ resetForm({+ values: { ...INITIAL_VALUES, secret: res },+ initialValues: { ...INITIAL_VALUES, secret: res },+ })+ setIsLoadingSecretValue(false)+ }++ return isLoadingSecretValue ? (+ <div className="space-y-2 py-4 px-2">+ <ShimmeringLoader />+ <div className="w-3/4">+ <ShimmeringLoader />+ </div>+ <div className="w-1/2">+ <ShimmeringLoader />+ </div>+ </div>+ ) : (<div className="py-4"><Modal.Content><div className="space-y-4 pb-4">diff --git a/studio/components/interfaces/Settings/Vault/Secrets/SecretRow.tsx b/studio/components/interfaces/Settings/Vault/Secrets/SecretRow.tsxindex c082c157cd2..2d4d0865b2a 100644--- a/studio/components/interfaces/Settings/Vault/Secrets/SecretRow.tsx+++ b/studio/components/interfaces/Settings/Vault/Secrets/SecretRow.tsx@@ -54,9 +54,16 @@ const SecretRow: FC<Props> = ({ secret, onSelectEdit, onSelectRemove }) => {</p>)}</div>- <div className="flex items-center space-x-2">- <IconKey size={14} strokeWidth={2} />- <p className="text-scale-1100 font-mono text-xs" title={secret.key_id}>+ <div className="flex items-center space-x-2 group">+ <IconKey+ size={14}+ strokeWidth={2}+ className="text-scale-1000 transition group-hover:text-brand-900"+ />+ <p+ className="text-scale-1100 font-mono text-xs cursor-pointer transition group-hover:text-brand-900"+ title={secret.key_id}+ >{secret.key_id}</p></div>diff --git a/studio/components/interfaces/Settings/Vault/Secrets/SecretsManagement.tsx b/studio/components/interfaces/Settings/Vault/Secrets/SecretsManagement.tsxindex b9dbad3b9c3..7e9e1d7b6c7 100644--- a/studio/components/interfaces/Settings/Vault/Secrets/SecretsManagement.tsx+++ b/studio/components/interfaces/Settings/Vault/Secrets/SecretsManagement.tsx@@ -35,10 +35,6 @@ const SecretsManagement: FC<Props> = ({}) => {}})- const onConfirmUpdateSecret = async () => {- if (!selectedSecretToEdit) return- }-return (<><div className="space-y-4">