Files
supabase/apps/studio/components/interfaces/Integrations/Integration/MarkdownContent.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

58 lines
1.9 KiB
TypeScript

import { motion } from 'framer-motion'
import { useEffect, useState } from 'react'
import { Markdown } from 'components/interfaces/Markdown'
import { cn } from 'ui'
const CHAR_LIMIT = 500 // Adjust this number as needed
export const MarkdownContent = ({ integrationId }: { integrationId: string }) => {
const [content, setContent] = useState<string>('')
const [isExpanded, setIsExpanded] = useState(false)
useEffect(() => {
import(`static-data/integrations/${integrationId}/overview.md`)
.then((module) => setContent(String(module.default)))
.catch((error) => console.error('Error loading markdown:', error))
}, [integrationId])
const displayContent = isExpanded ? content : content.slice(0, CHAR_LIMIT)
const supportExpanding = content.length > CHAR_LIMIT || (content.match(/\n/g) || []).length > 1
if (displayContent.length === 0) return null
return (
<div className="px-10">
<div className="relative">
<motion.div
initial={false}
animate={{ height: isExpanded ? 'auto' : 80 }}
className="overflow-hidden"
transition={{ duration: 0.4 }}
>
<Markdown content={displayContent} className="!max-w-3xl" />
</motion.div>
{!isExpanded && (
<div
className={cn(
'bottom-0 left-0 right-0 h-24',
supportExpanding && 'bg-gradient-to-t from-background-200 to-transparent',
!isExpanded ? 'absolute' : 'relative'
)}
/>
)}
{supportExpanding && (
<div className={cn('bottom-0', !isExpanded ? 'absolute' : 'relative mt-3')}>
<button
className="text-foreground-light hover:text-foreground underline text-sm"
onClick={() => setIsExpanded(!isExpanded)}
>
{isExpanded ? 'Show less' : 'Read more'}
</button>
</div>
)}
</div>
</div>
)
}