import { useParams } from 'common' import { PropsWithChildren } from 'react' import { cn } from 'ui' import { useAvailableIntegrations } from '../../Landing/useAvailableIntegrations' import { FilesViewer } from './FilesViewer' import { MarkdownContent } from './MarkdownContent' import { InlineLinkClassName } from '@/components/ui/InlineLink' const getSiteUrlLabel = (url: string | undefined | null) => { if (!url) return undefined try { return new URL(url).origin } catch (error) { return undefined } } const isGithubHost = (url: string | undefined | null) => { if (!url) return false try { const hostname = new URL(url).hostname.toLowerCase() return hostname === 'github.com' || hostname.endsWith('.github.com') } catch (error) { return false } } /** * [Joshen] This will serve as the overview tab for remotely fetched integrations */ export const IntegrationOverviewTabV2 = ({ children }: PropsWithChildren) => { const { id } = useParams() const { data: allIntegrations } = useAvailableIntegrations() const integration = allIntegrations.find((i) => i.id === id) if (!integration) { return
Unsupported integration type
} const { type, content, docsUrl, siteUrl, files = [] } = integration const docsUrlLabel = docsUrl?.includes('supabase.com/docs') ? 'Supabase Docs' : isGithubHost(docsUrl) ? 'GitHub Docs' : 'Documentation' const siteUrlLabel = getSiteUrlLabel(siteUrl) return (
{files.length > 0 && } {children}

Details

Type

{type === 'oauth' ? 'OAuth' : type.replaceAll('_', ' ')}

Built by

{integration.author.name || 'Unknown Author'}

{docsUrl && (

Docs

{docsUrlLabel}
)} {siteUrl && (

Website

{siteUrlLabel}
)}
{/* Subsequent other actions here */}
) }