| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- import { SupportCategories } from '@supabase/shared-types/out/constants'
- import { LOCAL_STORAGE_KEYS } from 'common'
- import { ExternalLink } from 'lucide-react'
- import {
- Card,
- CardContent,
- Separator,
- Table,
- TableBody,
- TableCell,
- TableHead,
- TableHeader,
- TableRow,
- } from 'ui'
- import { SupportLink } from '../Support/SupportLink'
- import { ApiKeyPill } from './ApiKeyPill'
- import { CreateNewAPIKeysButton } from './CreateNewAPIKeysButton'
- import { FeatureBanner } from '@/components/ui/FeatureBanner'
- import { InlineLink, InlineLinkClassName } from '@/components/ui/InlineLink'
- import { APIKeysData } from '@/data/api-keys/api-keys-query'
- // Mock API Keys for demo
- const mockApiKeys = [
- {
- id: 'mock-id-2',
- type: 'publishable',
- api_key: 'sb_publishable_ltaNA7nnVozoSCOcZIjg',
- name: 'web',
- },
- {
- id: 'mock-id-3',
- type: 'publishable',
- api_key: 'sb_publishable_YpotEpinEWsC2dI7FIKI',
- name: 'mobile',
- },
- {
- id: 'mock-id-1',
- type: 'secret',
- api_key: 'sb_secret_8I4Se•••••••••••••',
- name: 'backend_api',
- },
- ] as Extract<APIKeysData[number], { type: 'secret' | 'publishable' }>[]
- /**
- * Reusable table illustration component
- */
- const ApiKeysTableIllustration = () => {
- return (
- <Card className="w-full overflow-hidden opacity-60 pointer-events-none bg-surface-100">
- <CardContent className="p-0">
- <Table className="p-5">
- <TableHeader>
- <TableRow className="bg-200">
- <TableHead
- key=""
- className="text-left font-mono uppercase text-xs text-foreground-lighter h-auto py-2 overflow-hidden w-[180px]"
- >
- Name
- </TableHead>
- <TableHead className="text-left font-mono uppercase text-xs text-foreground-lighter h-auto py-2 pr-0">
- API Key
- </TableHead>
- <TableHead
- className="text-right font-mono uppercase text-xs text-foreground-lighter h-auto py-2"
- key="actions"
- />
- </TableRow>
- </TableHeader>
- <TableBody>
- {mockApiKeys.map((apiKey) => (
- <TableRow key={apiKey.id}>
- <TableCell className="py-2 w-[180px]">{apiKey.name}</TableCell>
- <TableCell className="py-2">
- <div className="flex flex-row gap-2">
- <ApiKeyPill apiKey={apiKey} />
- </div>
- </TableCell>
- <TableCell />
- </TableRow>
- ))}
- </TableBody>
- </Table>
- </CardContent>
- </Card>
- )
- }
- /**
- * Reusable illustration with gradient overlay component
- */
- const ApiKeysIllustrationWithOverlay = () => {
- return (
- <>
- {/* Gradient overlay - horizontal on desktop, vertical on mobile */}
- <div
- className="absolute inset-x-0 bottom-0 h-1/2 xl:h-full xl:inset-x-auto xl:-right-16 xl:top-3 w-full xl:w-2/3
- bg-linear-to-t xl:bg-linear-to-l
- from-background-alternative via-background-alternative/90 via-5% to-transparent
- z-3 pointer-events-none xl:max-w-[500px]"
- />
- <div className="absolute scale-100 left-10 -bottom-14 w-[720px] xl:w-[500px] xl:left-auto xl:right-[-200px] 2xl:-right-16 xl:top-[21px] xl:scale-75">
- <ApiKeysTableIllustration />
- </div>
- </>
- )
- }
- export const ApiKeysCreateCallout = () => {
- return (
- <FeatureBanner illustration={<ApiKeysIllustrationWithOverlay />} bgAlt>
- <div className="flex flex-col gap-0 z-2">
- <p className="text-sm text-foreground">Create API keys</p>
- <p className="text-sm text-foreground-lighter lg:max-w-sm 2xl:max-w-none">
- Use keys to authenticate requests to your app
- </p>
- <div className="mt-4">
- <CreateNewAPIKeysButton />
- </div>
- </div>
- </FeatureBanner>
- )
- }
- export const ApiKeysFeedbackBanner = () => {
- return (
- <FeatureBanner
- storageKey={LOCAL_STORAGE_KEYS.API_KEYS_FEEDBACK_DISMISSED}
- className="p-0! flex flex-col gap-0"
- dismissable
- >
- <div className="p-5">
- <p className="text-sm text-foreground">Your new API keys are here</p>
- <p className="text-sm text-foreground-lighter">
- We've updated our API keys to better support your application needs.{' '}
- <InlineLink
- href="https://github.com/orgs/briven/discussions/29260"
- className="inline-flex items-center gap-1"
- >
- Join the discussion on GitHub <ExternalLink aria-hidden size={14} strokeWidth={1.5} />
- </InlineLink>
- </p>
- </div>
- <Separator className="w-full" />
- <div className="px-5 py-2 bg-surface-200/30">
- <p className="text-sm text-foreground-lighter">
- Having trouble with the new API keys?{' '}
- <SupportLink
- className={InlineLinkClassName}
- queryParams={{
- category: SupportCategories.PROBLEM,
- subject: 'Help with API keys',
- }}
- >
- Contact support
- </SupportLink>
- </p>
- </div>
- </FeatureBanner>
- )
- }
|