Files
Joshen Lim c9a25cf11f Joshenlim/fe 5172 deprecate old table component (#53728)
## Context

More housekeeping - deprecates the old Table component in favor of the
Table component under `ui`

JFYI also realised as part of this that the following 2 routes are
unreachable from the dashboard and hence am opting to deprecate them
with a redirect
- /logs/explorer/recent
- /logs/explorer/saved

## Areas affected to check
- [ ] Integrations -> Webhooks
<img width="600" alt="image"
src="https://github.com/user-attachments/assets/58523cdb-6219-49be-9d2f-5bc26ae03d7f"
/>
- [ ] Database -> Column Privileges
<img width="600" alt="image"
src="https://github.com/user-attachments/assets/98bea654-24ac-4646-9c65-5bc4f18565e9"
/>
- [ ] Observability -> API  
<img width="600" alt="image"
src="https://github.com/user-attachments/assets/a6512c6f-bd04-4d25-8e3c-99c85883434a"
/>
- [ ] Observability -> Storage
  - Its a table under "Request caching" which I don't have data for 😅 🙏 
- [ ] Observability -> Database
<img width="600" alt="image"
src="https://github.com/user-attachments/assets/4f0ba203-64b3-41f7-971e-974e232bdedd"
/>
- [ ] Table Editor -> Project API Docs -> Column list
<img width="600" alt="image"
src="https://github.com/user-attachments/assets/6358e7a8-5770-46f9-a5a2-4851855ae97f"
/>
- [ ] Table Editor -> Project API Docs -> RPC parameters list
<img width="600" alt="image"
src="https://github.com/user-attachments/assets/5e45a1d6-cd29-451c-bf00-5d806ef37cec"
/>
2026-11-23 10:59:28 +07:00

109 lines
3.7 KiB
TypeScript

import { useParams } from 'common'
import { useEffect } from 'react'
import { Badge, Card, Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from 'ui'
import { DOCS_RESOURCE_CONTENT } from '../ProjectAPIDocs.constants'
import ResourceContent from '../ResourceContent'
import type { ContentProps } from './Content.types'
import { useProjectJsonSchemaQuery } from '@/data/docs/project-json-schema-query'
import { useOpenAPISpecQuery } from '@/data/open-api/api-spec-query'
import { useAppStateSnapshot } from '@/state/app-state'
export const RPC = ({ language }: ContentProps) => {
const { ref } = useParams()
const snap = useAppStateSnapshot()
const { data: jsonSchema, refetch: refetchJsonSchema } = useProjectJsonSchemaQuery({
projectRef: ref,
})
const { data, refetch: refetchOpenAPISpec } = useOpenAPISpecQuery({ projectRef: ref })
const functions = data?.functions ?? []
const rpcName = snap.activeDocsSection[1]
const rpc = functions.find((fn) => fn.name === rpcName)
const {
post: { parameters: postParameters },
} = rpc ?? {}
const rpcJsonSchema = jsonSchema?.paths[rpc?.path]
const summary = rpcJsonSchema?.post?.summary
const rpcParamsObject =
postParameters &&
postParameters[0] &&
postParameters[0].schema &&
postParameters[0].schema.properties
? postParameters[0].schema.properties
: {}
const parameters: { name: string; format: string; type: string; required: boolean }[] =
Object.entries(rpcParamsObject)
.map(([k, v]: any) => ({
name: k,
...v,
required: postParameters[0].schema.required.includes(k),
}))
.filter((x) => !!x.name)
useEffect(() => {
if (rpcName !== undefined) {
refetchJsonSchema()
refetchOpenAPISpec()
}
}, [rpcName])
if (rpc === undefined) return null
return (
<div className="divide-y">
<div className="space-y-1 px-4 py-4">
<h2>{rpc.name}</h2>
<p className="text-sm text-foreground-light">{summary ?? 'No description available'}</p>
</div>
<div className="space-y-2 px-4 py-4">
<p className="text-sm text-foreground-light">Function arguments</p>
<Card>
<Table>
<TableHeader>
<TableRow>
<TableHead key="name">Name</TableHead>
<TableHead key="format">Format</TableHead>
<TableHead key="type">Type</TableHead>
<TableHead key="required"></TableHead>
</TableRow>
</TableHeader>
<TableBody>
{parameters.map((parameter) => (
<TableRow key={parameter.name}>
<TableCell title={parameter.name}>
<p className="font-mono text-xs text-foreground truncate">{parameter.name}</p>
</TableCell>
<TableCell title={parameter.format}>{parameter.format}</TableCell>
<TableCell title={parameter.type}>{parameter.type}</TableCell>
<TableCell>
{parameter.required ? (
<Badge variant="warning">Required</Badge>
) : (
<Badge variant="default">Optional</Badge>
)}
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</Card>
</div>
<ResourceContent
selectedLanguage={language}
snippet={DOCS_RESOURCE_CONTENT.rpcSingle}
codeSnippets={DOCS_RESOURCE_CONTENT.rpcSingle.code({
rpcName,
rpcParams: parameters,
endpoint: 'endpoint',
apiKey: 'apiKey',
showBearer: true,
})}
/>
</div>
)
}