mirror of
https://github.com/supabase/supabase.git
synced 2026-10-11 20:35:07 +03:00
* Initial commit. * Minor type fixes. * Add a integration for Queues. Refactor some of the integration layout. * Migrate the Cron integration to the new style. * Add useInstalledIntegrations hook. * Add an integration entry for vault. * Add an integration entry for GraphiQL. * Add supabase webhooks. * Feat/integrations get layout (#30538) * scroll based icon * Update header.tsx * remove dep from overview * moar * more table stuff * moar * alt nav put in * fix MotionNumber issues * more * trying both layouts * Fix bunch of type errors. --------- Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com> * Migrate Vercel and Github files to their own folders. * Switch all integrations with the new designs. * More fixes for links, pages structure and other random stuff. * Remove unneeded file. * Another set of fixes. Migrated most of the extension integrations. * Migrated Vault and webhooks to the new style. * Various fixes to make the animation work. * Remove extra code. * Tiny fixes 😬 i swear its tiny * Refactor IntegrationOverviewTab * chore/ update integrations routes (#30585) * init * add child support in tabs * add webhooks * Update IntegrationPageHandler.tsx * fix id issues * use messageId instead * animation tweaks * Move the description to the wrappers array. * The useInstalledIntegrations now provides integrations which could be installed. * Add static content for the various integrations. * Move the page handler logic into the integrations definitions. * Clean up some extra code. * Add logic to make the overview tab the default tab. * Don't show the header until the integration id has been checked. * Add logic to the integration pages to avoid weird loading bugs, deselecting tabs if the integration hasn't been installed etc. * Fix the webhooks overview tab. * Fix the buttons for enabling extensions. * Add padding to all custom tab contents. * Small fixes * Prettier lint * Fix icon color + add empty state for when available integrations are all installed * Fix ts errors * Fiox * Add enable webhooks cta * Fix key * Fix all lints * Fix the queues create sheet. * Fix the deletion of wrappers. * Fix the minimum version alert for the wrappers extension. * Make the queues table fit the whole container. * Fix an issue which reset the tab when installing an extension. * Address comments * Add loading state for installed integrations in side nav * Fix edit secret not rendering value in input field after subsequent openings * Fix vault keys auto filling search input with vault * Fix search input placeholder for cron * Minor fix in install database extension copy * Fix a bad redirect when reloading. * Fix bad url redirects. * Fix scrolling in create new/edit wrapper sheet. * Add y padding to the wrappers rows. * Fix merge errors. * More merge fixes. * Fix bad imports during the merge. --------- Co-authored-by: Jonathan Summers-Muir <MildTomato@users.noreply.github.com> Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
357 lines
11 KiB
TypeScript
357 lines
11 KiB
TypeScript
import dayjs from 'dayjs'
|
|
import Image from 'next/legacy/image'
|
|
import React from 'react'
|
|
|
|
import { Markdown } from 'components/interfaces/Markdown'
|
|
import { ButtonTooltip } from 'components/ui/ButtonTooltip'
|
|
import type {
|
|
Integration,
|
|
IntegrationProjectConnection,
|
|
} from 'data/integrations/integrations.types'
|
|
import { useProjectsQuery } from 'data/projects/projects-query'
|
|
import { BASE_PATH } from 'lib/constants'
|
|
import { getIntegrationConfigurationUrl } from 'lib/integration-utils'
|
|
import { ArrowRight, ExternalLink, Github } from 'lucide-react'
|
|
import Link from 'next/link'
|
|
import { Badge, Button, cn } from 'ui'
|
|
|
|
const ICON_STROKE_WIDTH = 2
|
|
const ICON_SIZE = 14
|
|
|
|
export interface IntegrationInstallationProps extends React.RefAttributes<HTMLLIElement> {
|
|
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 <Github strokeWidth={ICON_STROKE_WIDTH} size={ICON_SIZE} />
|
|
break
|
|
// case 'Netlify':
|
|
// return <Square strokeWidth={ICON_STROKE_WIDTH} size={ICON_SIZE} />
|
|
// break
|
|
case 'Vercel':
|
|
return (
|
|
<svg
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
fill="white"
|
|
viewBox="0 0 512 512"
|
|
className={cn('w-3.5', className)}
|
|
>
|
|
<path fillRule="evenodd" d="M256,48,496,464H16Z" />
|
|
</svg>
|
|
)
|
|
|
|
break
|
|
case 'Supabase':
|
|
return <img src={`${BASE_PATH}/img/supabase-logo.svg`} alt="Supabase" className="w-3.5"></img>
|
|
break
|
|
|
|
default:
|
|
return <></>
|
|
break
|
|
}
|
|
}
|
|
|
|
const Avatar = ({ src }: { src: string | undefined }) => {
|
|
return (
|
|
<div className="relative border shadow-lg w-8 h-8 rounded-full overflow-hidden">
|
|
<Image
|
|
src={src || ''}
|
|
width={30}
|
|
height={30}
|
|
layout="fill"
|
|
alt="avatar"
|
|
className="relative"
|
|
/>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
const IntegrationInstallation = React.forwardRef<HTMLLIElement, IntegrationInstallationProps>(
|
|
({ integration, disabled, ...props }, ref) => {
|
|
const IntegrationIconBlock = () => {
|
|
return (
|
|
<div className="bg-black text-white w-8 h-8 rounded flex items-center justify-center">
|
|
<HandleIcon type={integration.integration.name} />
|
|
</div>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<li
|
|
ref={ref}
|
|
key={integration.id}
|
|
className="bg-surface-100 border shadow-sm flex justify-between items-center px-8 py-4 rounded-lg"
|
|
{...props}
|
|
>
|
|
<div className="flex gap-6 items-center">
|
|
<div className="flex gap-3 items-center">
|
|
<div className="flex -space-x-1">
|
|
<IntegrationIconBlock />
|
|
<Avatar src={integration?.metadata?.account.avatar} />
|
|
</div>
|
|
</div>
|
|
<div className="flex flex-col gap-0">
|
|
<div className="flex items-center gap-2">
|
|
<span className="text-foreground text-sm font-medium">
|
|
{integration.metadata?.account.name ||
|
|
(integration.metadata !== undefined &&
|
|
'gitHubConnectionOwner' in integration.metadata &&
|
|
integration.metadata?.gitHubConnectionOwner)}
|
|
</span>
|
|
|
|
<Badge className="capitalize">{integration.metadata?.account.type}</Badge>
|
|
</div>
|
|
<div className="flex flex-col gap-0">
|
|
<span className="text-foreground-lighter text-xs">
|
|
Created {dayjs(integration.inserted_at).fromNow()}
|
|
</span>
|
|
<span className="text-foreground-lighter text-xs">
|
|
Added by {integration?.added_by?.primary_email}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<Button asChild disabled={disabled} type="default" iconRight={<ExternalLink />}>
|
|
{disabled ? (
|
|
<p>Manage</p>
|
|
) : (
|
|
<Link
|
|
href={getIntegrationConfigurationUrl(integration)}
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
>
|
|
Manage
|
|
</Link>
|
|
)}
|
|
</Button>
|
|
</li>
|
|
)
|
|
}
|
|
)
|
|
|
|
export interface IntegrationConnectionProps extends React.HTMLAttributes<HTMLLIElement> {
|
|
connection: IntegrationProjectConnection
|
|
type: Integration['integration']['name']
|
|
actions?: React.ReactNode
|
|
showNode?: boolean
|
|
orientation?: 'horizontal' | 'vertical'
|
|
}
|
|
|
|
const IntegrationConnection = React.forwardRef<HTMLLIElement, IntegrationConnectionProps>(
|
|
(
|
|
{ connection, type, actions, showNode = true, orientation = 'horizontal', className, ...props },
|
|
ref
|
|
) => {
|
|
const { data: projects } = useProjectsQuery()
|
|
const project = projects?.find((project) => project.ref === connection.supabase_project_ref)
|
|
|
|
return (
|
|
<li
|
|
ref={ref}
|
|
key={connection.id}
|
|
{...props}
|
|
className={cn(showNode && 'pl-8 ml-6 border-l border-muted', 'relative')}
|
|
>
|
|
{showNode && (
|
|
<div className="absolute w-8 rounded-bl-full border-b border-l border-muted h-10 -left-px"></div>
|
|
)}
|
|
<div
|
|
className={cn(
|
|
orientation === 'horizontal'
|
|
? 'flex items-center justify-between gap-2'
|
|
: 'flex flex-col gap-3',
|
|
'bg-surface-100 border shadow-sm px-6 py-4 rounded-lg',
|
|
className
|
|
)}
|
|
>
|
|
<div className="flex flex-col gap-1 min-w-0">
|
|
<div className="flex items-center gap-2">
|
|
<div className="flex-shrink-0 flex gap-x-2 items-center max-w-40 ">
|
|
<HandleIcon type={'Supabase'} />
|
|
<span title={project?.name} className="text-sm truncate">
|
|
{project?.name}
|
|
</span>
|
|
</div>
|
|
|
|
<ArrowRight
|
|
size={14}
|
|
className="flex-shrink-0 text-foreground-lighter"
|
|
strokeWidth={1.5}
|
|
/>
|
|
|
|
<div className="flex-1 min-w-0 flex gap-2 items-center">
|
|
{!connection?.metadata?.framework ? (
|
|
<div className="bg-black text-white w-4 h-4 rounded flex items-center justify-center">
|
|
<HandleIcon type={type} className={'!w-2.5'} />
|
|
</div>
|
|
) : (
|
|
<img
|
|
src={`${BASE_PATH}/img/icons/frameworks/${connection.metadata.framework}.svg`}
|
|
width={21}
|
|
height={21}
|
|
alt={`icon`}
|
|
/>
|
|
)}
|
|
{type === 'GitHub' ? (
|
|
<a
|
|
title={connection.metadata.name}
|
|
href={`https://github.com/${connection.metadata?.name}`}
|
|
className="text-sm truncate"
|
|
target="_blank"
|
|
rel="noreferrer"
|
|
>
|
|
{connection.metadata?.name}
|
|
</a>
|
|
) : (
|
|
<span title={connection.metadata.name} className="text-sm truncate">
|
|
{connection.metadata?.name}
|
|
</span>
|
|
)}
|
|
</div>
|
|
</div>
|
|
|
|
<div className="flex flex-col gap-0">
|
|
<span className="text-foreground-lighter text-xs">
|
|
Connected {dayjs(connection?.inserted_at).fromNow()}
|
|
</span>
|
|
<span className="text-foreground-lighter text-xs">
|
|
Added by {connection?.added_by?.primary_email}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div className="flex-shrink-0">{actions}</div>
|
|
</div>
|
|
</li>
|
|
)
|
|
}
|
|
)
|
|
|
|
const IntegrationConnectionOption = React.forwardRef<HTMLLIElement, IntegrationConnectionProps>(
|
|
({ connection, type, ...props }, ref) => {
|
|
const { data: projects } = useProjectsQuery()
|
|
const project = projects?.find((project) => project.ref === connection.supabase_project_ref)
|
|
|
|
return (
|
|
<li
|
|
ref={ref}
|
|
key={connection.id}
|
|
{...props}
|
|
className={cn(
|
|
'bg-surface-100 border shadow-sm flex justify-between items-center px-8 py-4 rounded-lg'
|
|
)}
|
|
>
|
|
<div className="flex flex-col gap-1">
|
|
<div className="flex gap-2 items-center">
|
|
<HandleIcon type={'Supabase'} />
|
|
<span className="text-sm">{project?.name}</span>
|
|
<ArrowRight size={14} className="text-foreground-lighter" strokeWidth={1.5} />
|
|
<HandleIcon type={type} />
|
|
<span className="text-sm">{connection.metadata.name}</span>
|
|
</div>
|
|
|
|
<span className="text-foreground-lighter text-xs">
|
|
Connected {dayjs(connection.inserted_at).fromNow()}
|
|
</span>
|
|
</div>
|
|
|
|
<Button type="default">Connect</Button>
|
|
</li>
|
|
)
|
|
}
|
|
)
|
|
|
|
const EmptyIntegrationConnection = React.forwardRef<
|
|
HTMLDivElement,
|
|
React.HTMLAttributes<HTMLDivElement> & {
|
|
showNode?: boolean
|
|
orgSlug?: string
|
|
onClick: () => void
|
|
disabled?: boolean
|
|
}
|
|
>(({ className, showNode = true, onClick, disabled, ...props }, ref) => {
|
|
return (
|
|
<div
|
|
ref={ref}
|
|
{...props}
|
|
className={cn(
|
|
showNode && 'ml-6 pl-8 mt-4 border-l',
|
|
'relative pb-2',
|
|
'last:border-l-transparent',
|
|
className
|
|
)}
|
|
>
|
|
{showNode && (
|
|
<div className="absolute w-8 rounded-bl-full border-b border-l border-muted h-14 -top-4 -left-px"></div>
|
|
)}
|
|
<div
|
|
className={cn(
|
|
'w-full',
|
|
'border border-dashed bg-surface-100 border-overlay',
|
|
'flex h-20 px-10 rounded-lg justify-center items-center'
|
|
)}
|
|
>
|
|
<ButtonTooltip
|
|
type="default"
|
|
disabled={disabled}
|
|
onClick={() => onClick()}
|
|
tooltip={{
|
|
content: {
|
|
side: 'bottom',
|
|
text: disabled ? 'Additional permissions required to add connection' : undefined,
|
|
},
|
|
}}
|
|
>
|
|
Add new project connection
|
|
</ButtonTooltip>
|
|
</div>
|
|
</div>
|
|
)
|
|
})
|
|
|
|
interface IntegrationConnectionHeader extends React.HTMLAttributes<HTMLDivElement> {
|
|
name?: string
|
|
markdown?: string
|
|
showNode?: boolean
|
|
}
|
|
|
|
const IntegrationConnectionHeader = React.forwardRef<HTMLDivElement, IntegrationConnectionHeader>(
|
|
({ className, markdown = '', showNode = true, ...props }, ref) => {
|
|
return (
|
|
<div
|
|
{...props}
|
|
ref={ref}
|
|
className={cn(
|
|
showNode && 'border-l border-muted ml-6 pl-8',
|
|
'py-4 prose text-sm',
|
|
className
|
|
)}
|
|
>
|
|
{props.title && <h5 className="text-foreground">{props.title}</h5>}
|
|
<Markdown content={markdown} />
|
|
</div>
|
|
)
|
|
}
|
|
)
|
|
|
|
IntegrationInstallation.displayName = 'IntegrationInstallation'
|
|
IntegrationConnection.displayName = 'IntegrationConnection'
|
|
IntegrationConnectionHeader.displayName = 'IntegrationConnectionHeader'
|
|
EmptyIntegrationConnection.displayName = 'EmptyIntegrationConnection'
|
|
IntegrationConnectionOption.displayName = 'IntegrationConnectionOption'
|
|
|
|
export {
|
|
EmptyIntegrationConnection,
|
|
IntegrationConnection,
|
|
IntegrationConnectionHeader,
|
|
IntegrationConnectionOption,
|
|
IntegrationInstallation,
|
|
}
|