Files
supabase/apps/studio/components/interfaces/Storage/AnalyticBucketDetails/DecryptedReadOnlyInput.tsx
T
Ivan VasilovandJoshen Lim 32c3eeb389 feat: Create new schema when creating a FDW with the schema option (#37205)
* Change the import foreign schema to always create a schema.

* Fix the Iceberg wrapper.

* Refactor the create wrapper to always create a new schema.

* Remove unneeded props.

* Smol fixes

* Prevent double error toasts

* Smol fix

* Fix the wrapper creation to include the correct api key.

* Fix a bug with the new api keys.

* Handle both types of keys when fetching the iceberg namespaces.

* Add a field to all wrappers to hold the schema name which can import foreign schema.

* sq

* When importing a foreign schema, save the schema in a special field.

* Fix a type error.

* Fix importing foreign schema overriding wrapper server options with unencrypted values

* Add comment

* Handle duplicate and empty schemas when importing a foreign schema.

* Update the copy in the foreign schema wrappers.

* Remove unnecessary code.

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2025-07-25 10:54:17 +02:00

92 lines
2.7 KiB
TypeScript

import { ExternalLink, Eye, EyeOff, Loader } from 'lucide-react'
import { useState } from 'react'
import { useParams } from 'common'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
import { useVaultSecretDecryptedValueQuery } from 'data/vault/vault-secret-decrypted-value-query'
import { Button, Input, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
export const DecryptedReadOnlyInput = ({
value,
secureEntry,
descriptionText,
label,
}: {
value?: string
secureEntry: boolean
descriptionText: string
label: string
}) => {
const { ref } = useParams()
const { project } = useProjectContext()
const [showHidden, setShowHidden] = useState(false)
const { data: decryptedValue, isLoading: isDecryptedValueLoading } =
useVaultSecretDecryptedValueQuery(
{
projectRef: project?.ref,
connectionString: project?.connectionString,
id: value ?? '',
},
{ enabled: secureEntry && showHidden }
)
const isLoading = isDecryptedValueLoading && showHidden
const renderedValue = secureEntry
? isLoading
? 'Fetching value from Vault...'
: showHidden
? decryptedValue
: value
: value
return (
<Input
readOnly
copy
disabled
label={
<div className="flex items-center gap-x-2">
<span>{label}</span>
<Tooltip>
<TooltipTrigger asChild>
<a
target="_blank"
rel="noreferrer noopener"
href={`/project/${ref}/integrations/vault/secrets?search=${value}`}
>
<ExternalLink
size={14}
className="text-foreground-lighter hover:text-foreground-light transition"
/>
</a>
</TooltipTrigger>
<TooltipContent side="bottom">View parameter in Vault</TooltipContent>
</Tooltip>
</div>
}
value={renderedValue}
type={secureEntry ? (isLoading ? 'text' : showHidden ? 'text' : 'password') : 'text'}
descriptionText={descriptionText}
layout="horizontal"
actions={
secureEntry ? (
isLoading ? (
<div className="flex items-center justify-center mr-1">
<Button disabled type="default" icon={<Loader className="animate-spin" />} />
</div>
) : (
<div className="flex items-center justify-center mr-1">
<Button
type="default"
icon={showHidden ? <Eye /> : <EyeOff />}
onClick={() => setShowHidden(!showHidden)}
/>
</div>
)
) : null
}
/>
)
}