import dayjs from 'dayjs' import { ArrowRight, ExternalLink, Github } from 'lucide-react' import Image from 'next/legacy/image' import Link from 'next/link' import { forwardRef, HTMLAttributes, ReactNode, RefAttributes } from 'react' import { Badge, Button, cn } from 'ui' import { Markdown } from '@/components/interfaces/Markdown' import { ButtonTooltip } from '@/components/ui/ButtonTooltip' import type { Integration, IntegrationProjectConnection, } from '@/data/integrations/integrations.types' import { useProjectDetailQuery } from '@/data/projects/project-detail-query' import { BASE_PATH } from '@/lib/constants' import { getIntegrationConfigurationUrl } from '@/lib/integration-utils' const ICON_STROKE_WIDTH = 2 const ICON_SIZE = 14 export interface IntegrationInstallationProps extends RefAttributes { title: string integration: Integration disabled?: boolean } type HandleIconType = Integration['integration']['name'] | 'Supabase' const HandleIcon = ({ type, className }: { type: HandleIconType; className?: string }) => { switch (type) { case 'GitHub': return break // case 'Netlify': // return // break case 'Vercel': return ( ) break case 'Supabase': return Supabase break default: return <> break } } const Avatar = ({ src }: { src: string | undefined }) => { return (
avatar
) } export const IntegrationInstallation = forwardRef( ({ integration, disabled, ...props }, ref) => { const IntegrationIconBlock = () => { return (
) } return (
  • {integration.metadata?.account.name || (integration.metadata !== undefined && 'gitHubConnectionOwner' in integration.metadata && integration.metadata?.gitHubConnectionOwner)} {integration.metadata?.account.type}
    Created {dayjs(integration.inserted_at).fromNow()} Added by {integration?.added_by?.primary_email}
  • ) } ) export interface IntegrationConnectionProps extends HTMLAttributes { connection: IntegrationProjectConnection type: Integration['integration']['name'] actions?: ReactNode showNode?: boolean orientation?: 'horizontal' | 'vertical' } export const IntegrationConnection = forwardRef( ( { connection, type, actions, showNode = true, orientation = 'horizontal', className, ...props }, ref ) => { const { data: project } = useProjectDetailQuery({ ref: connection.supabase_project_ref }) return (
  • {showNode && (
    )}
    {project?.name}
    {!connection?.metadata?.framework ? (
    ) : ( {`icon`} )} {type === 'GitHub' ? ( {connection.metadata?.name} ) : ( {connection.metadata?.name} )}
    Connected {dayjs(connection?.inserted_at).fromNow()} Added by {connection?.added_by?.primary_email}
    {actions}
  • ) } ) export const IntegrationConnectionOption = forwardRef( ({ connection, type, ...props }, ref) => { const { data: project } = useProjectDetailQuery({ ref: connection.supabase_project_ref }) return (
  • {project?.name} {connection.metadata.name}
    Connected {dayjs(connection.inserted_at).fromNow()}
  • ) } ) export const EmptyIntegrationConnection = forwardRef< HTMLDivElement, HTMLAttributes & { showNode?: boolean onClick: () => void disabled?: boolean } >(({ className, showNode = true, onClick, disabled, ...props }, ref) => { return (
    {showNode && (
    )}
    onClick()} tooltip={{ content: { side: 'bottom', text: disabled ? 'Additional permissions required to add connection' : undefined, }, }} > Add new project connection
    ) }) interface IntegrationConnectionHeader extends React.HTMLAttributes { name?: string markdown?: string showNode?: boolean } export const IntegrationConnectionHeader = forwardRef( ({ className, markdown = '', showNode = true, ...props }, ref) => { return (
    {props.title &&
    {props.title}
    }
    ) } ) IntegrationInstallation.displayName = 'IntegrationInstallation' IntegrationConnection.displayName = 'IntegrationConnection' IntegrationConnectionHeader.displayName = 'IntegrationConnectionHeader' EmptyIntegrationConnection.displayName = 'EmptyIntegrationConnection' IntegrationConnectionOption.displayName = 'IntegrationConnectionOption'