mirror of
https://github.com/supabase/supabase.git
synced 2026-06-15 08:05:21 +08:00
Feature / Refactor ## What is the current behavior? Data API docs live at the `/api` route as a standalone page. Old links point to the previous location. ## What is the new behavior? Data API docs are moved to the integrations section with a dedicated docs tab and settings tab. Old links are cleaned up, a mobile menu is added for data API docs navigation, and minor code review fixes are applied. ## Additional context Resolves FE-2517 ## Summary by CodeRabbit * **New Features** * Revamped API docs UI with reusable section layout, language toggle (JS/Bash), API key selection, and improved code snippets * Added Data API docs tab, mobile navigation, and dedicated loading/error/disabled states * **Navigation Updates** * Moved API docs and related links into the Integrations/Data API area and added redirects to new routes * Updated various internal links to the new Data API settings and overview locations * **Tests** * Added comprehensive unit tests for Data API utilities
77 lines
2.0 KiB
TypeScript
77 lines
2.0 KiB
TypeScript
import { noop } from 'lodash'
|
|
import { Badge } from 'ui'
|
|
|
|
import Description from '@/components/interfaces/Docs/Description'
|
|
|
|
function getColumnType(type: string, format: string) {
|
|
// json and jsonb both have type=undefined, so check format instead
|
|
if (type === undefined && (format === 'jsonb' || format === 'json')) return 'json'
|
|
|
|
switch (type) {
|
|
case 'string':
|
|
return 'string'
|
|
case 'integer':
|
|
return 'number'
|
|
case 'json':
|
|
return 'json'
|
|
case 'number':
|
|
return 'number'
|
|
case 'boolean':
|
|
return 'boolean'
|
|
default:
|
|
return ''
|
|
}
|
|
}
|
|
|
|
interface ParamProps {
|
|
name: string
|
|
type: string
|
|
format: string
|
|
required: boolean
|
|
description: boolean
|
|
metadata?: any
|
|
onDesciptionUpdated?: () => void
|
|
}
|
|
const Param = ({
|
|
name,
|
|
type,
|
|
format,
|
|
required,
|
|
description,
|
|
metadata = {},
|
|
onDesciptionUpdated = noop,
|
|
}: ParamProps) => {
|
|
return (
|
|
<div className="not-prose">
|
|
<div className="mb-4 flex items-center gap-4">
|
|
<h3 className="heading-default text-foreground mb-0 mt-0">{name}</h3>
|
|
|
|
<Badge variant={required ? 'warning' : 'default'}>
|
|
{required ? 'Required' : 'Optional'}
|
|
</Badge>
|
|
</div>
|
|
{format && (
|
|
<div className="grid grid-cols-[auto_1fr] gap-y-2 gap-x-10 text-sm">
|
|
<label className="text-foreground-lighter">Type</label>
|
|
<div className="text-foreground">{getColumnType(type, format)}</div>
|
|
<label className="text-foreground-lighter">Format</label>
|
|
<div className="text-foreground">{format}</div>
|
|
{description !== false && (
|
|
<>
|
|
<label className="text-foreground-lighter">Description</label>
|
|
<div className="text-foreground pt-1">
|
|
<Description
|
|
content={description?.toString()}
|
|
metadata={metadata}
|
|
onChange={onDesciptionUpdated}
|
|
/>
|
|
</div>
|
|
</>
|
|
)}
|
|
</div>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|
|
export default Param
|